You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/03/26 18:21:00 UTC

[2/6] [OLINGO-194] geospatial literals

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
index 2501d4e..6d93ef2 100644
--- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
+++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/geo/Polygon.java
@@ -32,18 +32,12 @@ public class Polygon extends Geospatial {
 
   final ComposedGeospatial<Point> exterior;
 
-  /**
-   * Constructor.
-   *
-   * @param dimension dimension.
-   * @param crs crs.
-   * @param interior interior points.
-   * @param exterior exterior points.
-   */
-  public Polygon(final Dimension dimension, final String crs, final List<Point> interior, final List<Point> exterior) {
-    super(dimension, Type.POLYGON, crs);
-    this.interior = new MultiPoint(dimension, crs, interior);
-    this.exterior = new MultiPoint(dimension, crs, exterior);
+  public Polygon(final Dimension dimension, final Integer srid, 
+          final List<Point> interior, final List<Point> exterior) {
+    
+    super(dimension, Type.POLYGON, srid);
+    this.interior = new MultiPoint(dimension, srid, interior);
+    this.exterior = new MultiPoint(dimension, srid, exterior);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
index 458e4cc..0444fba 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueDeserializer.java
@@ -44,7 +44,7 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
 class AtomGeoValueDeserializer {
 
   private List<Point> points(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
     final List<Point> result = new ArrayList<Point>();
 
@@ -55,7 +55,7 @@ class AtomGeoValueDeserializer {
       if (event.isCharacters() && !event.asCharacters().isWhiteSpace()) {
         final String[] pointInfo = event.asCharacters().getData().split(" ");
 
-        final Point point = new Point(GeoUtils.getDimension(type), crs);
+        final Point point = new Point(GeoUtils.getDimension(type), srid);
         try {
           point.setX(EdmDouble.getInstance().valueOfString(pointInfo[0], null, null,
                   Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
@@ -76,7 +76,7 @@ class AtomGeoValueDeserializer {
   }
 
   private MultiPoint multipoint(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
     List<Point> points = Collections.<Point>emptyList();
 
@@ -93,17 +93,17 @@ class AtomGeoValueDeserializer {
       }
     }
 
-    return new MultiPoint(GeoUtils.getDimension(type), crs, points);
+    return new MultiPoint(GeoUtils.getDimension(type), srid, points);
   }
 
   private LineString lineString(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
-    return new LineString(GeoUtils.getDimension(type), crs, points(reader, start, type, null));
+    return new LineString(GeoUtils.getDimension(type), srid, points(reader, start, type, null));
   }
 
   private Polygon polygon(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
     List<Point> extPoints = null;
     List<Point> intPoints = null;
@@ -126,11 +126,11 @@ class AtomGeoValueDeserializer {
       }
     }
 
-    return new Polygon(GeoUtils.getDimension(type), crs, intPoints, extPoints);
+    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
   }
 
   private MultiLineString multiLineString(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
     final List<LineString> lineStrings = new ArrayList<LineString>();
 
@@ -147,11 +147,11 @@ class AtomGeoValueDeserializer {
       }
     }
 
-    return new MultiLineString(GeoUtils.getDimension(type), crs, lineStrings);
+    return new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
   }
 
   private MultiPolygon multiPolygon(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
     final List<Polygon> polygons = new ArrayList<Polygon>();
 
@@ -168,11 +168,11 @@ class AtomGeoValueDeserializer {
       }
     }
 
-    return new MultiPolygon(GeoUtils.getDimension(type), crs, polygons);
+    return new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
   }
 
   private GeospatialCollection collection(final XMLEventReader reader, final StartElement start,
-          final EdmPrimitiveTypeKind type, final String crs) throws XMLStreamException {
+          final EdmPrimitiveTypeKind type, final Integer srid) throws XMLStreamException {
 
     final List<Geospatial> geospatials = new ArrayList<Geospatial>();
 
@@ -201,16 +201,16 @@ class AtomGeoValueDeserializer {
       }
     }
 
-    return new GeospatialCollection(GeoUtils.getDimension(type), crs, geospatials);
+    return new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
   }
 
   public Geospatial deserialize(final XMLEventReader reader, final StartElement start,
           final EdmPrimitiveTypeKind type) throws XMLStreamException {
 
-    String crs = null;
+    Integer srid = null;
     final Attribute srsName = start.getAttributeByName(Constants.QNAME_ATTR_SRSNAME);
     if (srsName != null) {
-      crs = StringUtils.substringAfterLast(srsName.getValue(), "/");
+      srid = Integer.valueOf(StringUtils.substringAfterLast(srsName.getValue(), "/"));
     }
 
     Geospatial value;
@@ -218,37 +218,37 @@ class AtomGeoValueDeserializer {
     switch (type) {
       case GeographyPoint:
       case GeometryPoint:
-        value = points(reader, start, type, crs).get(0);
+        value = points(reader, start, type, srid).get(0);
         break;
 
       case GeographyMultiPoint:
       case GeometryMultiPoint:
-        value = multipoint(reader, start, type, crs);
+        value = multipoint(reader, start, type, srid);
         break;
 
       case GeographyLineString:
       case GeometryLineString:
-        value = lineString(reader, start, type, crs);
+        value = lineString(reader, start, type, srid);
         break;
 
       case GeographyMultiLineString:
       case GeometryMultiLineString:
-        value = multiLineString(reader, start, type, crs);
+        value = multiLineString(reader, start, type, srid);
         break;
 
       case GeographyPolygon:
       case GeometryPolygon:
-        value = polygon(reader, start, type, crs);
+        value = polygon(reader, start, type, srid);
         break;
 
       case GeographyMultiPolygon:
       case GeometryMultiPolygon:
-        value = multiPolygon(reader, start, type, crs);
+        value = multiPolygon(reader, start, type, srid);
         break;
 
       case GeographyCollection:
       case GeometryCollection:
-        value = collection(reader, start, type, crs);
+        value = collection(reader, start, type, srid);
         break;
 
       default:

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
index 624bcfa..d1636d4 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/AtomGeoValueSerializer.java
@@ -118,9 +118,9 @@ class AtomGeoValueSerializer {
   }
 
   private void writeSrsName(final XMLStreamWriter writer, final Geospatial value) throws XMLStreamException {
-    if (value.getCrs() != null) {
+    if (value.getSrid() != null) {
       writer.writeAttribute(Constants.PREFIX_GML, Constants.NS_GML, Constants.ATTR_SRSNAME,
-              Constants.SRS_URLPREFIX + value.getCrs());
+              Constants.SRS_URLPREFIX + value.getSrid());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
index c544f73..09ecbdf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueDeserializer.java
@@ -47,11 +47,11 @@ class JSONGeoValueDeserializer {
     this.version = version;
   }
 
-  private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final String crs) {
+  private Point point(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final Integer srid) {
     Point point = null;
 
     if (itor.hasNext()) {
-      point = new Point(GeoUtils.getDimension(type), crs);
+      point = new Point(GeoUtils.getDimension(type), srid);
       try {
         point.setX(EdmDouble.getInstance().valueOfString(itor.next().asText(), null, null,
                 Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, Double.class));
@@ -65,46 +65,42 @@ class JSONGeoValueDeserializer {
     return point;
   }
 
-  private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final String crs) {
-
+  private MultiPoint multipoint(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final Integer srid) {
     final MultiPoint multiPoint;
 
     if (itor.hasNext()) {
       final List<Point> points = new ArrayList<Point>();
       while (itor.hasNext()) {
         final Iterator<JsonNode> mpItor = itor.next().elements();
-        points.add(point(mpItor, type, crs));
+        points.add(point(mpItor, type, srid));
       }
-      multiPoint = new MultiPoint(GeoUtils.getDimension(type), crs, points);
+      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, points);
     } else {
-      multiPoint = new MultiPoint(GeoUtils.getDimension(type), crs, Collections.<Point>emptyList());
+      multiPoint = new MultiPoint(GeoUtils.getDimension(type), srid, Collections.<Point>emptyList());
     }
 
     return multiPoint;
   }
 
-  private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final String crs) {
-
+  private LineString lineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type, final Integer srid) {
     final LineString lineString;
 
     if (itor.hasNext()) {
       final List<Point> points = new ArrayList<Point>();
       while (itor.hasNext()) {
         final Iterator<JsonNode> mpItor = itor.next().elements();
-        points.add(point(mpItor, type, crs));
+        points.add(point(mpItor, type, srid));
       }
-      lineString = new LineString(GeoUtils.getDimension(type), crs, points);
+      lineString = new LineString(GeoUtils.getDimension(type), srid, points);
     } else {
-      lineString = new LineString(GeoUtils.getDimension(type), crs, Collections.<Point>emptyList());
+      lineString = new LineString(GeoUtils.getDimension(type), srid, Collections.<Point>emptyList());
     }
 
     return lineString;
   }
 
   private MultiLineString multiLineString(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final String crs) {
+          final Integer srid) {
 
     final MultiLineString multiLineString;
 
@@ -112,18 +108,18 @@ class JSONGeoValueDeserializer {
       final List<LineString> lineStrings = new ArrayList<LineString>();
       while (itor.hasNext()) {
         final Iterator<JsonNode> mlsItor = itor.next().elements();
-        lineStrings.add(lineString(mlsItor, type, crs));
+        lineStrings.add(lineString(mlsItor, type, srid));
       }
-      multiLineString = new MultiLineString(GeoUtils.getDimension(type), crs, lineStrings);
+      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, lineStrings);
     } else {
-      multiLineString = new MultiLineString(GeoUtils.getDimension(type), crs, Collections.<LineString>emptyList());
+      multiLineString = new MultiLineString(GeoUtils.getDimension(type), srid, Collections.<LineString>emptyList());
     }
 
     return multiLineString;
   }
 
   private Polygon polygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final String crs) {
+          final Integer srid) {
 
     List<Point> extPoints = null;
     if (itor.hasNext()) {
@@ -132,7 +128,7 @@ class JSONGeoValueDeserializer {
         extPoints = new ArrayList<Point>();
         while (extItor.hasNext()) {
           final Iterator<JsonNode> mpItor = extItor.next().elements();
-          extPoints.add(point(mpItor, type, crs));
+          extPoints.add(point(mpItor, type, srid));
         }
       }
     }
@@ -144,16 +140,16 @@ class JSONGeoValueDeserializer {
         intPoints = new ArrayList<Point>();
         while (intItor.hasNext()) {
           final Iterator<JsonNode> mpItor = intItor.next().elements();
-          intPoints.add(point(mpItor, type, crs));
+          intPoints.add(point(mpItor, type, srid));
         }
       }
     }
 
-    return new Polygon(GeoUtils.getDimension(type), crs, intPoints, extPoints);
+    return new Polygon(GeoUtils.getDimension(type), srid, intPoints, extPoints);
   }
 
   private MultiPolygon multiPolygon(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final String crs) {
+          final Integer srid) {
 
     final MultiPolygon multiPolygon;
 
@@ -161,18 +157,18 @@ class JSONGeoValueDeserializer {
       final List<Polygon> polygons = new ArrayList<Polygon>();
       while (itor.hasNext()) {
         final Iterator<JsonNode> mpItor = itor.next().elements();
-        polygons.add(polygon(mpItor, type, crs));
+        polygons.add(polygon(mpItor, type, srid));
       }
-      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), crs, polygons);
+      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, polygons);
     } else {
-      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), crs, Collections.<Polygon>emptyList());
+      multiPolygon = new MultiPolygon(GeoUtils.getDimension(type), srid, Collections.<Polygon>emptyList());
     }
 
     return multiPolygon;
   }
 
   private GeospatialCollection collection(final Iterator<JsonNode> itor, final EdmPrimitiveTypeKind type,
-          final String crs) {
+          final Integer srid) {
 
     final GeospatialCollection collection;
 
@@ -195,9 +191,9 @@ class JSONGeoValueDeserializer {
         geospatials.add(deserialize(geo, new EdmTypeInfo.Builder().setTypeExpression(callAsType).build()));
       }
 
-      collection = new GeospatialCollection(GeoUtils.getDimension(type), crs, geospatials);
+      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, geospatials);
     } else {
-      collection = new GeospatialCollection(GeoUtils.getDimension(type), crs, Collections.<Geospatial>emptyList());
+      collection = new GeospatialCollection(GeoUtils.getDimension(type), srid, Collections.<Geospatial>emptyList());
     }
 
     return collection;
@@ -223,46 +219,47 @@ class JSONGeoValueDeserializer {
             ? node.get(Constants.JSON_COORDINATES).elements()
             : Collections.<JsonNode>emptyList().iterator();
 
-    String crs = null;
+    Integer srid = null;
     if (node.has(Constants.JSON_CRS)) {
-      crs = node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1];
+      srid = Integer.valueOf(
+              node.get(Constants.JSON_CRS).get(Constants.PROPERTIES).get(Constants.JSON_NAME).asText().split(":")[1]);
     }
 
     Geospatial value = null;
     switch (actualType) {
       case GeographyPoint:
       case GeometryPoint:
-        value = point(cooItor, actualType, crs);
+        value = point(cooItor, actualType, srid);
         break;
 
       case GeographyMultiPoint:
       case GeometryMultiPoint:
-        value = multipoint(cooItor, actualType, crs);
+        value = multipoint(cooItor, actualType, srid);
         break;
 
       case GeographyLineString:
       case GeometryLineString:
-        value = lineString(cooItor, actualType, crs);
+        value = lineString(cooItor, actualType, srid);
         break;
 
       case GeographyMultiLineString:
       case GeometryMultiLineString:
-        value = multiLineString(cooItor, actualType, crs);
+        value = multiLineString(cooItor, actualType, srid);
         break;
 
       case GeographyPolygon:
       case GeometryPolygon:
-        value = polygon(cooItor, actualType, crs);
+        value = polygon(cooItor, actualType, srid);
         break;
 
       case GeographyMultiPolygon:
       case GeometryMultiPolygon:
-        value = multiPolygon(cooItor, actualType, crs);
+        value = multiPolygon(cooItor, actualType, srid);
         break;
 
       case GeographyCollection:
       case GeometryCollection:
-        value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, crs);
+        value = collection(node.get(Constants.JSON_GEOMETRIES).elements(), actualType, srid);
         break;
 
       default:

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
index 95c30d4..470872e 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/data/JSONGeoValueSerializer.java
@@ -37,11 +37,11 @@ import org.apache.olingo.commons.core.edm.primitivetype.EdmDouble;
 
 class JSONGeoValueSerializer {
 
-  private void crs(final JsonGenerator jgen, final String crs) throws IOException {
+  private void srid(final JsonGenerator jgen, final Integer srid) throws IOException {
     jgen.writeObjectFieldStart(Constants.JSON_CRS);
     jgen.writeStringField(Constants.ATTR_TYPE, Constants.JSON_NAME);
     jgen.writeObjectFieldStart(Constants.PROPERTIES);
-    jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + crs);
+    jgen.writeStringField(Constants.JSON_NAME, "EPSG:" + srid);
     jgen.writeEndObject();
     jgen.writeEndObject();
   }
@@ -175,8 +175,8 @@ class JSONGeoValueSerializer {
       default:
     }
 
-    if (value.getCrs() != null) {
-      crs(jgen, value.getCrs());
+    if (value.getSrid() != null) {
+      srid(jgen, value.getSrid());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
new file mode 100644
index 0000000..ad60494
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ODataPrimitiveValueImpl.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.domain;
+
+import java.sql.Timestamp;
+import java.util.Calendar;
+import org.apache.olingo.commons.api.Constants;
+import org.apache.olingo.commons.api.domain.AbstractODataValue;
+import org.apache.olingo.commons.api.domain.ODataPrimitiveValue;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveType;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
+import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
+import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory;
+
+public class ODataPrimitiveValueImpl extends AbstractODataValue implements ODataPrimitiveValue {
+
+  private static final long serialVersionUID = 8889282662298376036L;
+
+  public static class BuilderImpl implements Builder {
+
+    private final ODataServiceVersion version;
+
+    private final ODataPrimitiveValueImpl instance;
+
+    public BuilderImpl(final ODataServiceVersion version) {
+      this.version = version;
+      this.instance = new ODataPrimitiveValueImpl();
+    }
+
+    @Override
+    public BuilderImpl setType(final EdmPrimitiveTypeKind type) {
+      if (type != null && !type.getSupportedVersions().contains(version)) {
+        throw new IllegalArgumentException(String.format(
+                "Type %s not supported by OData version %s", type.toString(), version));
+      }
+      if (type == EdmPrimitiveTypeKind.Stream) {
+        throw new IllegalArgumentException(String.format(
+                "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString()));
+      }
+      if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) {
+        throw new IllegalArgumentException(
+                type + "is not an instantiable type. "
+                + "An entity can declare a property to be of type Geometry. "
+                + "An instance of an entity MUST NOT have a value of type Geometry. "
+                + "Each value MUST be of some subtype.");
+      }
+
+      this.instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type;
+      this.instance.type = EdmPrimitiveTypeFactory.getInstance(this.instance.typeKind);
+
+      return this;
+    }
+
+    @Override
+    public BuilderImpl setText(final String text) {
+      this.instance.text = text;
+      return this;
+    }
+
+    @Override
+    public BuilderImpl setValue(final Object value) {
+      this.instance.value = value;
+      return this;
+    }
+
+    @Override
+    public ODataPrimitiveValueImpl build() {
+      if (this.instance.text == null && this.instance.value == null) {
+        throw new IllegalArgumentException("Must provide either text or value");
+      }
+      if (this.instance.text != null && this.instance.value != null) {
+        throw new IllegalArgumentException("Cannot provide both text and value");
+      }
+
+      if (this.instance.type == null) {
+        setType(EdmPrimitiveTypeKind.String);
+      }
+
+      if (this.instance.text != null) {
+        final Class<?> returnType = this.instance.type.getDefaultType().isAssignableFrom(Calendar.class)
+                ? Timestamp.class : this.instance.type.getDefaultType();
+        try {
+          // TODO: when Edm is available, set facets when calling this method
+          this.instance.value = this.instance.type.valueOfString(
+                  this.instance.text, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null,
+                  returnType);
+        } catch (EdmPrimitiveTypeException e) {
+          throw new IllegalArgumentException(e);
+        }
+      }
+      if (this.instance.value != null) {
+        try {
+          // TODO: when Edm is available, set facets when calling this method
+          this.instance.text = this.instance.type.valueToString(
+                  this.instance.value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null);
+        } catch (EdmPrimitiveTypeException e) {
+          throw new IllegalArgumentException(e);
+        }
+      }
+
+      return this.instance;
+    }
+  }
+
+  /**
+   * Type kind.
+   */
+  private EdmPrimitiveTypeKind typeKind;
+
+  /**
+   * Type.
+   */
+  private EdmPrimitiveType type;
+
+  /**
+   * Text value.
+   */
+  private String text;
+
+  /**
+   * Actual value.
+   */
+  private Object value;
+
+  @Override
+  public EdmPrimitiveTypeKind getTypeKind() {
+    return typeKind;
+  }
+
+  @Override
+  public EdmPrimitiveType getType() {
+    return type;
+  }
+
+  @Override
+  public Object toValue() {
+    return this.value;
+  }
+
+  @Override
+  public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException {
+    return typeKind.isGeospatial()
+            ? reference.cast(this.value)
+            // TODO: when Edm is available, set facets when calling this method
+            : type.valueOfString(this.text,
+                    null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference);
+  }
+
+  @Override
+  public String toString() {
+    return this.text;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java
index 09bd8ce..90761a7 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/AbstractEdmParameter.java
@@ -44,7 +44,7 @@ public abstract class AbstractEdmParameter extends EdmElementImpl implements Edm
     if (typeImpl == null) {
       if (EdmPrimitiveType.EDM_NAMESPACE.equals(paramType.getNamespace())) {
         try {
-          typeImpl = EdmPrimitiveTypeFactory.getNonGeoInstance(EdmPrimitiveTypeKind.valueOf(paramType.getName()));
+          typeImpl = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.valueOf(paramType.getName()));
         } catch (IllegalArgumentException e) {
           throw new EdmException("Cannot find type with name: " + paramType, e);
         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java
deleted file mode 100644
index 8e5cb6f..0000000
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractEdmGeospatialType.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.olingo.commons.core.edm.primitivetype;
-
-import org.apache.olingo.commons.api.edm.EdmGeospatialType;
-import org.apache.olingo.commons.api.edm.FullQualifiedName;
-import org.apache.olingo.commons.api.edm.constants.EdmTypeKind;
-import org.apache.olingo.commons.api.edm.geo.Geospatial;
-import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
-import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-
-public abstract class AbstractEdmGeospatialType<T extends Geospatial> implements EdmGeospatialType {
-
-  private final Class<T> reference;
-
-  protected final Dimension dimension;
-
-  protected final Type type;
-
-  protected AbstractEdmGeospatialType(final Class<T> reference, final Dimension dimension, final Type type) {
-    this.reference = reference;
-    this.dimension = dimension;
-    this.type = type;
-  }
-
-  @Override
-  public Class<? extends Geospatial> getJavaType() {
-    return reference;
-  }
-
-  @Override
-  public String getNamespace() {
-    return EDM_NAMESPACE;
-  }
-
-  @Override
-  public String getName() {
-    return getClass().getSimpleName().substring(3);
-  }
-
-  @Override
-  public EdmTypeKind getKind() {
-    return EdmTypeKind.PRIMITIVE;
-  }
-
-  @Override
-  public boolean equals(final Object obj) {
-    return this == obj || obj != null && getClass() == obj.getClass();
-  }
-
-  @Override
-  public int hashCode() {
-    return getClass().hashCode();
-  }
-
-  @Override
-  public String toString() {
-    return new FullQualifiedName(getNamespace(), getName()).getFullQualifiedNameAsString();
-  }
-}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java
new file mode 100644
index 0000000..7a61a53
--- /dev/null
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/AbstractGeospatialType.java
@@ -0,0 +1,539 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.olingo.commons.core.edm.primitivetype;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
+import org.apache.olingo.commons.api.edm.geo.Geospatial;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
+import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
+import org.apache.olingo.commons.api.edm.geo.LineString;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
+import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
+
+public abstract class AbstractGeospatialType<T extends Geospatial> extends SingletonPrimitiveType {
+
+  private static final Pattern PATTERN =
+          Pattern.compile("([a-z]+)'SRID=([0-9]+);([a-zA-Z]+)\\((.*)\\)'");
+
+  private static final Pattern COLLECTION_PATTERN =
+          Pattern.compile("([a-z]+)'SRID=([0-9]+);Collection\\(([a-zA-Z]+)\\((.*)\\)\\)'");
+
+  private final Class<T> reference;
+
+  protected final Dimension dimension;
+
+  protected final Type type;
+
+  protected AbstractGeospatialType(final Class<T> reference, final Dimension dimension, final Type type) {
+    this.reference = reference;
+    this.dimension = dimension;
+    this.type = type;
+  }
+
+  @Override
+  public Class<?> getDefaultType() {
+    return reference;
+  }
+
+  private Matcher getMatcher(final Pattern pattern, final String value) throws EdmPrimitiveTypeException {
+    final Matcher matcher = pattern.matcher(value);
+    if (!matcher.matches()) {
+      throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    Geospatial.Dimension _dimension = null;
+    Geospatial.Type _type = null;
+    try {
+      _dimension = Geospatial.Dimension.valueOf(matcher.group(1).toUpperCase());
+      _type = Geospatial.Type.valueOf(matcher.group(3).toUpperCase());
+    } catch (IllegalArgumentException e) {
+      throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)", e);
+    }
+    if (_dimension != this.dimension || (!pattern.equals(COLLECTION_PATTERN) && _type != this.type)) {
+      throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    return matcher;
+  }
+
+  private Point newPoint(final Integer srid, final String point, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final String[] pointCoo = StringUtils.split(point, ' ');
+    if (pointCoo == null || pointCoo.length != 2) {
+      throw new EdmPrimitiveTypeException("EdmPrimitiveTypeException.LITERAL_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    final Point result = new Point(this.dimension, srid);
+    result.setX(EdmDouble.getInstance().valueOfString(pointCoo[0],
+            isNullable, maxLength, precision, scale, isUnicode, Double.class));
+    result.setY(EdmDouble.getInstance().valueOfString(pointCoo[1],
+            isNullable, maxLength, precision, scale, isUnicode, Double.class));
+
+    return result;
+  }
+
+  protected Point stringToPoint(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(PATTERN, value);
+
+    return newPoint(Integer.valueOf(matcher.group(2)), matcher.group(4),
+            isNullable, maxLength, precision, scale, isUnicode);
+  }
+
+  protected MultiPoint stringToMultiPoint(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(PATTERN, value);
+
+    final List<Point> points = new ArrayList<Point>();
+    for (String pointCoo : StringUtils.split(matcher.group(4), ',')) {
+      points.add(newPoint(null, pointCoo.substring(1, pointCoo.length() - 1),
+              isNullable, maxLength, precision, scale, isUnicode));
+    }
+
+    return new MultiPoint(dimension, Integer.valueOf(matcher.group(2)), points);
+  }
+
+  private LineString newLineString(final Integer srid, final String lineString, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final List<Point> points = new ArrayList<Point>();
+    for (String pointCoo : StringUtils.split(lineString, ',')) {
+      points.add(newPoint(null, pointCoo, isNullable, maxLength, precision, scale, isUnicode));
+    }
+
+    return new LineString(this.dimension, srid, points);
+  }
+
+  protected LineString stringToLineString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(PATTERN, value);
+
+    return newLineString(Integer.valueOf(matcher.group(2)), matcher.group(4),
+            isNullable, maxLength, precision, scale, isUnicode);
+  }
+
+  protected MultiLineString stringToMultiLineString(final String value, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(PATTERN, value);
+
+    final List<LineString> lineStrings = new ArrayList<LineString>();
+    for (String coo : matcher.group(4).contains("),(")
+            ? matcher.group(4).split("\\),\\(") : new String[] {matcher.group(4)}) {
+
+      String lineString = coo;
+      if (lineString.charAt(0) == '(') {
+        lineString = lineString.substring(1);
+      }
+      if (lineString.endsWith(")")) {
+        lineString = StringUtils.substringBeforeLast(lineString, ")");
+      }
+
+      lineStrings.add(newLineString(null, lineString, isNullable, maxLength, precision, scale, isUnicode));
+    }
+
+    return new MultiLineString(this.dimension, Integer.valueOf(matcher.group(2)), lineStrings);
+  }
+
+  private Polygon newPolygon(final Integer srid, final String polygon, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final String[] first = polygon.split("\\),\\(");
+
+    final List<Point> interior = new ArrayList<Point>();
+    for (String pointCoo : StringUtils.split(first[0].substring(1, first[0].length()), ',')) {
+      interior.add(newPoint(null, pointCoo, isNullable, maxLength, precision, scale, isUnicode));
+    }
+    final List<Point> exterior = new ArrayList<Point>();
+    for (String pointCoo : StringUtils.split(first[1].substring(0, first[1].length() - 1), ',')) {
+      exterior.add(newPoint(null, pointCoo, isNullable, maxLength, precision, scale, isUnicode));
+    }
+
+    return new Polygon(dimension, srid, interior, exterior);
+  }
+
+  protected Polygon stringToPolygon(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(PATTERN, value);
+
+    return newPolygon(Integer.valueOf(matcher.group(2)), matcher.group(4),
+            isNullable, maxLength, precision, scale, isUnicode);
+  }
+
+  protected MultiPolygon stringToMultiPolygon(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(PATTERN, value);
+
+    final List<Polygon> polygons = new ArrayList<Polygon>();
+    for (String coo : matcher.group(4).contains(")),((")
+            ? matcher.group(4).split("\\)\\),\\(\\(") : new String[] {matcher.group(4)}) {
+
+      String polygon = coo;
+      if (polygon.startsWith("((")) {
+        polygon = polygon.substring(1);
+      }
+      if (polygon.endsWith("))")) {
+        polygon = StringUtils.substringBeforeLast(polygon, ")");
+      }
+      if (polygon.charAt(0) != '(') {
+        polygon = "(" + polygon;
+      }
+      if (!polygon.endsWith(")")) {
+        polygon += ")";
+      }
+
+      polygons.add(newPolygon(null, polygon, isNullable, maxLength, precision, scale, isUnicode));
+    }
+
+    return new MultiPolygon(dimension, Integer.valueOf(matcher.group(2)), polygons);
+  }
+
+  protected GeospatialCollection stringToCollection(final String value, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final Matcher matcher = getMatcher(COLLECTION_PATTERN, value);
+
+    Geospatial item = null;
+    switch (Geospatial.Type.valueOf(matcher.group(3).toUpperCase())) {
+      case POINT:
+        item = newPoint(Integer.valueOf(matcher.group(2)), matcher.group(4),
+                isNullable, maxLength, precision, scale, isUnicode);
+        break;
+
+      case MULTIPOINT:
+        final List<Point> points = new ArrayList<Point>();
+        for (String pointCoo : StringUtils.split(matcher.group(4), ',')) {
+          points.add(newPoint(null, pointCoo.substring(1, pointCoo.length() - 1),
+                  isNullable, maxLength, precision, scale, isUnicode));
+        }
+
+        item = new MultiPoint(dimension, Integer.valueOf(matcher.group(2)), points);
+        break;
+
+      case LINESTRING:
+        item = newLineString(Integer.valueOf(matcher.group(2)), matcher.group(4),
+                isNullable, maxLength, precision, scale, isUnicode);
+        break;
+
+      case MULTILINESTRING:
+        final List<LineString> lineStrings = new ArrayList<LineString>();
+        for (String coo : StringUtils.split(matcher.group(4), ',')) {
+          lineStrings.add(newLineString(null, coo.substring(1, coo.length() - 1),
+                  isNullable, maxLength, precision, scale, isUnicode));
+        }
+
+        item = new MultiLineString(this.dimension, Integer.valueOf(matcher.group(2)), lineStrings);
+        break;
+
+      case POLYGON:
+        item = newPolygon(Integer.valueOf(matcher.group(2)), matcher.group(4),
+                isNullable, maxLength, precision, scale, isUnicode);
+        break;
+
+      case MULTIPOLYGON:
+        final List<Polygon> polygons = new ArrayList<Polygon>();
+        for (String coo : StringUtils.split(matcher.group(4), ',')) {
+          polygons.add(newPolygon(null, coo.substring(1, coo.length() - 1),
+                  isNullable, maxLength, precision, scale, isUnicode));
+        }
+
+        item = new MultiPolygon(dimension, Integer.valueOf(matcher.group(2)), polygons);
+        break;
+
+      default:
+    }
+
+    return new GeospatialCollection(dimension, Integer.valueOf(matcher.group(2)),
+            Collections.<Geospatial>singletonList(item));
+  }
+
+  private StringBuilder toStringBuilder(final Integer srid) {
+    return new StringBuilder(dimension.name().toLowerCase()).append('\'').
+            append("SRID=").append(srid).append(';');
+  }
+
+  private String point(final Point point, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    return new StringBuilder().
+            append(EdmDouble.getInstance().valueToString(point.getX(),
+                            isNullable, maxLength, precision, scale, isUnicode)).
+            append(' ').
+            append(EdmDouble.getInstance().valueToString(point.getY(),
+                            isNullable, maxLength, precision, scale, isUnicode)).
+            toString();
+  }
+
+  protected String toString(final Point point, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != point.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    return toStringBuilder(point.getSrid()).
+            append(reference.getSimpleName()).
+            append('(').
+            append(point(point, isNullable, maxLength, precision, scale, isUnicode)).
+            append(")'").
+            toString();
+  }
+
+  protected String toString(final MultiPoint multiPoint, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != multiPoint.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    final StringBuilder result = toStringBuilder(multiPoint.getSrid()).
+            append(reference.getSimpleName()).
+            append('(');
+
+    for (final Iterator<Point> itor = multiPoint.iterator(); itor.hasNext();) {
+      result.append('(').
+              append(point(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
+              append(')');
+      if (itor.hasNext()) {
+        result.append(',');
+      }
+    }
+
+    return result.append(")'").toString();
+  }
+
+  private String lineString(final LineString lineString, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final StringBuilder result = new StringBuilder();
+
+    for (final Iterator<Point> itor = lineString.iterator(); itor.hasNext();) {
+      result.append(point(itor.next(), isNullable, maxLength, precision, scale, isUnicode));
+      if (itor.hasNext()) {
+        result.append(',');
+      }
+    }
+
+    return result.toString();
+  }
+
+  protected String toString(final LineString lineString, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != lineString.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    return toStringBuilder(lineString.getSrid()).
+            append(reference.getSimpleName()).
+            append('(').
+            append(lineString(lineString, isNullable, maxLength, precision, scale, isUnicode)).
+            append(")'").toString();
+  }
+
+  protected String toString(final MultiLineString multiLineString, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != multiLineString.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    final StringBuilder result = toStringBuilder(multiLineString.getSrid()).
+            append(reference.getSimpleName()).
+            append('(');
+
+    for (final Iterator<LineString> itor = multiLineString.iterator(); itor.hasNext();) {
+      result.append('(').
+              append(lineString(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
+              append(')');
+      if (itor.hasNext()) {
+        result.append(',');
+      }
+    }
+
+    return result.append(")'").toString();
+  }
+
+  private String polygon(final Polygon polygon, final Boolean isNullable,
+          final Integer maxLength, final Integer precision, final Integer scale, final Boolean isUnicode)
+          throws EdmPrimitiveTypeException {
+
+    final StringBuilder result = new StringBuilder();
+
+    result.append('(');
+    for (final Iterator<Point> itor = polygon.getInterior().iterator(); itor.hasNext();) {
+      result.append(point(itor.next(), isNullable, maxLength, precision, scale, isUnicode));
+      if (itor.hasNext()) {
+        result.append(',');
+      }
+    }
+    result.append("),(");
+    for (final Iterator<Point> itor = polygon.getExterior().iterator(); itor.hasNext();) {
+      result.append(point(itor.next(), isNullable, maxLength, precision, scale, isUnicode));
+      if (itor.hasNext()) {
+        result.append(',');
+      }
+    }
+
+    return result.append(')').toString();
+  }
+
+  protected String toString(final Polygon polygon, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != polygon.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    return toStringBuilder(polygon.getSrid()).
+            append(reference.getSimpleName()).
+            append('(').
+            append(polygon(polygon, isNullable, maxLength, precision, scale, isUnicode)).
+            append(")'").toString();
+  }
+
+  protected String toString(final MultiPolygon multiPolygon, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != multiPolygon.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    final StringBuilder result = toStringBuilder(multiPolygon.getSrid()).
+            append(reference.getSimpleName()).
+            append('(');
+
+    for (final Iterator<Polygon> itor = multiPolygon.iterator(); itor.hasNext();) {
+      result.append('(').
+              append(polygon(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
+              append(')');
+      if (itor.hasNext()) {
+        result.append(',');
+      }
+    }
+
+    return result.append(")'").toString();
+  }
+
+  protected String toString(final GeospatialCollection collection, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (dimension != collection.getDimension()) {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_ILLEGAL_CONTENT.addContent(value)");
+    }
+
+    final StringBuilder result = toStringBuilder(collection.getSrid()).
+            append("Collection(");
+
+    if (collection.iterator().hasNext()) {
+      final Geospatial item = collection.iterator().next();
+      result.append(item.getClass().getSimpleName()).append('(');
+
+      switch (item.getEdmPrimitiveTypeKind()) {
+        case GeographyPoint:
+        case GeometryPoint:
+          result.append(point((Point) item, isNullable, maxLength, precision, scale, isUnicode));
+          break;
+
+        case GeographyMultiPoint:
+        case GeometryMultiPoint:
+          for (final Iterator<Point> itor = ((MultiPoint) item).iterator(); itor.hasNext();) {
+            result.append('(').
+                    append(point(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
+                    append(')');
+            if (itor.hasNext()) {
+              result.append(',');
+            }
+          }
+          break;
+
+        case GeographyLineString:
+        case GeometryLineString:
+          result.append(lineString((LineString) item, isNullable, maxLength, precision, scale, isUnicode));
+          break;
+
+        case GeographyMultiLineString:
+        case GeometryMultiLineString:
+          for (final Iterator<LineString> itor = ((MultiLineString) item).iterator(); itor.hasNext();) {
+            result.append('(').
+                    append(lineString(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
+                    append(')');
+            if (itor.hasNext()) {
+              result.append(',');
+            }
+          }
+          break;
+
+        case GeographyPolygon:
+        case GeometryPolygon:
+          result.append(polygon((Polygon) item, isNullable, maxLength, precision, scale, isUnicode));
+          break;
+
+        case GeographyMultiPolygon:
+        case GeometryMultiPolygon:
+          for (final Iterator<Polygon> itor = ((MultiPolygon) item).iterator(); itor.hasNext();) {
+            result.append('(').
+                    append(polygon(itor.next(), isNullable, maxLength, precision, scale, isUnicode)).
+                    append(')');
+            if (itor.hasNext()) {
+              result.append(',');
+            }
+          }
+          break;
+
+        default:
+      }
+
+      result.append(')');
+    }
+
+    return result.append(")'").toString();
+  }
+}

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java
index f5951cb..4fc8dcf 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeography.java
@@ -18,10 +18,11 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 
-public final class EdmGeography extends AbstractEdmGeospatialType<Geospatial> {
+public final class EdmGeography extends AbstractGeospatialType<Geospatial> {
 
   private static final EdmGeography INSTANCE = new EdmGeography();
 
@@ -33,4 +34,20 @@ public final class EdmGeography extends AbstractEdmGeospatialType<Geospatial> {
     super(Geospatial.class, Dimension.GEOGRAPHY, null);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode, final Class<T> returnType)
+          throws EdmPrimitiveTypeException {
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java
index aab7210..7c4f446 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyCollection.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
 
-public final class EdmGeographyCollection extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyCollection extends AbstractGeospatialType<GeospatialCollection> {
 
   private static final EdmGeographyCollection INSTANCE = new EdmGeographyCollection();
 
@@ -31,7 +32,33 @@ public final class EdmGeographyCollection extends AbstractEdmGeospatialType<Poin
   }
 
   public EdmGeographyCollection() {
-    super(Point.class, Dimension.GEOGRAPHY, Type.GEOSPATIALCOLLECTION);
+    super(GeospatialCollection.class, Dimension.GEOGRAPHY, Type.GEOSPATIALCOLLECTION);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final GeospatialCollection collection =
+            stringToCollection(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(GeospatialCollection.class)) {
+      return returnType.cast(collection);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof GeospatialCollection) {
+      return toString((GeospatialCollection) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java
index 23c92cc..85f1b7b 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyLineString.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.LineString;
 
-public final class EdmGeographyLineString extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyLineString extends AbstractGeospatialType<LineString> {
 
   private static final EdmGeographyLineString INSTANCE = new EdmGeographyLineString();
 
@@ -31,7 +32,32 @@ public final class EdmGeographyLineString extends AbstractEdmGeospatialType<Poin
   }
 
   public EdmGeographyLineString() {
-    super(Point.class, Dimension.GEOGRAPHY, Type.LINESTRING);
+    super(LineString.class, Dimension.GEOGRAPHY, Type.LINESTRING);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final LineString lineString = stringToLineString(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(LineString.class)) {
+      return returnType.cast(lineString);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof LineString) {
+      return toString((LineString) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java
index 9b5901d..90c65eb 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiLineString.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
 
-public final class EdmGeographyMultiLineString extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyMultiLineString extends AbstractGeospatialType<MultiLineString> {
 
   private static final EdmGeographyMultiLineString INSTANCE = new EdmGeographyMultiLineString();
 
@@ -31,7 +32,33 @@ public final class EdmGeographyMultiLineString extends AbstractEdmGeospatialType
   }
 
   public EdmGeographyMultiLineString() {
-    super(Point.class, Dimension.GEOGRAPHY, Type.MULTILINESTRING);
+    super(MultiLineString.class, Dimension.GEOGRAPHY, Type.MULTILINESTRING);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final MultiLineString multiLineString =
+            stringToMultiLineString(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(MultiLineString.class)) {
+      return returnType.cast(multiLineString);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof MultiLineString) {
+      return toString((MultiLineString) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java
index db66041..9249055 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPoint.java
@@ -18,11 +18,13 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.MultiPoint;
 import org.apache.olingo.commons.api.edm.geo.Point;
 
-public final class EdmGeographyMultiPoint extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyMultiPoint extends AbstractGeospatialType<MultiPoint> {
 
   private static final EdmGeographyMultiPoint INSTANCE = new EdmGeographyMultiPoint();
 
@@ -31,7 +33,34 @@ public final class EdmGeographyMultiPoint extends AbstractEdmGeospatialType<Poin
   }
 
   public EdmGeographyMultiPoint() {
-    super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOINT);
+    super(MultiPoint.class, Dimension.GEOGRAPHY, Type.MULTIPOINT);
+  }
+
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode, final Class<T> returnType)
+          throws EdmPrimitiveTypeException {
+
+    final MultiPoint point = stringToMultiPoint(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(MultiPoint.class)) {
+      return returnType.cast(point);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof MultiPoint) {
+      return toString((MultiPoint) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
   }
 
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java
index 4b53a30..9dde107 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyMultiPolygon.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.MultiPolygon;
 
-public final class EdmGeographyMultiPolygon extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyMultiPolygon extends AbstractGeospatialType<MultiPolygon> {
 
   private static final EdmGeographyMultiPolygon INSTANCE = new EdmGeographyMultiPolygon();
 
@@ -31,7 +32,32 @@ public final class EdmGeographyMultiPolygon extends AbstractEdmGeospatialType<Po
   }
 
   public EdmGeographyMultiPolygon() {
-    super(Point.class, Dimension.GEOGRAPHY, Type.MULTIPOLYGON);
+    super(MultiPolygon.class, Dimension.GEOGRAPHY, Type.MULTIPOLYGON);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final MultiPolygon multiPolygon = stringToMultiPolygon(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(MultiPolygon.class)) {
+      return returnType.cast(multiPolygon);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof MultiPolygon) {
+      return toString((MultiPolygon) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java
index 61abce3..637709d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPoint.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
 import org.apache.olingo.commons.api.edm.geo.Point;
 
-public final class EdmGeographyPoint extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyPoint extends AbstractGeospatialType<Point> {
 
   private static final EdmGeographyPoint INSTANCE = new EdmGeographyPoint();
 
@@ -34,4 +35,30 @@ public final class EdmGeographyPoint extends AbstractEdmGeospatialType<Point> {
     super(Point.class, Dimension.GEOGRAPHY, Type.POINT);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final Point point = stringToPoint(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(Point.class)) {
+      return returnType.cast(point);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof Point) {
+      return toString((Point) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java
index a7a1a6c..5f5e2db 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeographyPolygon.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.Polygon;
 
-public final class EdmGeographyPolygon extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeographyPolygon extends AbstractGeospatialType<Polygon> {
 
   private static final EdmGeographyPolygon INSTANCE = new EdmGeographyPolygon();
 
@@ -31,7 +32,32 @@ public final class EdmGeographyPolygon extends AbstractEdmGeospatialType<Point>
   }
 
   public EdmGeographyPolygon() {
-    super(Point.class, Dimension.GEOGRAPHY, Type.POLYGON);
+    super(Polygon.class, Dimension.GEOGRAPHY, Type.POLYGON);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final Polygon polygon = stringToPolygon(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(Polygon.class)) {
+      return returnType.cast(polygon);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof Polygon) {
+      return toString((Polygon) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java
index 2f16e24..3c19186 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometry.java
@@ -18,10 +18,11 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 
-public final class EdmGeometry extends AbstractEdmGeospatialType<Geospatial> {
+public final class EdmGeometry extends AbstractGeospatialType<Geospatial> {
 
   private static final EdmGeometry INSTANCE = new EdmGeometry();
 
@@ -33,4 +34,20 @@ public final class EdmGeometry extends AbstractEdmGeospatialType<Geospatial> {
     super(Geospatial.class, Dimension.GEOMETRY, null);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode, final Class<T> returnType)
+          throws EdmPrimitiveTypeException {
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java
index 12c6c01..3c5a0e2 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryCollection.java
@@ -18,11 +18,13 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
+import org.apache.olingo.commons.api.edm.geo.GeospatialCollection;
 import org.apache.olingo.commons.api.edm.geo.Point;
 
-public final class EdmGeometryCollection extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeometryCollection extends AbstractGeospatialType<GeospatialCollection> {
 
   private static final EdmGeometryCollection INSTANCE = new EdmGeometryCollection();
 
@@ -31,7 +33,33 @@ public final class EdmGeometryCollection extends AbstractEdmGeospatialType<Point
   }
 
   public EdmGeometryCollection() {
-    super(Point.class, Dimension.GEOMETRY, Type.GEOSPATIALCOLLECTION);
+    super(GeospatialCollection.class, Dimension.GEOMETRY, Type.GEOSPATIALCOLLECTION);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final GeospatialCollection collection =
+            stringToCollection(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(GeospatialCollection.class)) {
+      return returnType.cast(collection);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof GeospatialCollection) {
+      return toString((GeospatialCollection) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java
index db8cfb0..dbe0eda 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryLineString.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.LineString;
 
-public final class EdmGeometryLineString extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeometryLineString extends AbstractGeospatialType<LineString> {
 
   private static final EdmGeometryLineString INSTANCE = new EdmGeometryLineString();
 
@@ -31,7 +32,32 @@ public final class EdmGeometryLineString extends AbstractEdmGeospatialType<Point
   }
 
   public EdmGeometryLineString() {
-    super(Point.class, Dimension.GEOMETRY, Type.LINESTRING);
+    super(LineString.class, Dimension.GEOMETRY, Type.LINESTRING);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final LineString lineString = stringToLineString(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(LineString.class)) {
+      return returnType.cast(lineString);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof LineString) {
+      return toString((LineString) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/76513508/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java
index 7bf89e6..5ed7ed0 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmGeometryMultiLineString.java
@@ -18,11 +18,12 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Dimension;
 import org.apache.olingo.commons.api.edm.geo.Geospatial.Type;
-import org.apache.olingo.commons.api.edm.geo.Point;
+import org.apache.olingo.commons.api.edm.geo.MultiLineString;
 
-public final class EdmGeometryMultiLineString extends AbstractEdmGeospatialType<Point> {
+public final class EdmGeometryMultiLineString extends AbstractGeospatialType<MultiLineString> {
 
   private static final EdmGeometryMultiLineString INSTANCE = new EdmGeometryMultiLineString();
 
@@ -31,7 +32,33 @@ public final class EdmGeometryMultiLineString extends AbstractEdmGeospatialType<
   }
 
   public EdmGeometryMultiLineString() {
-    super(Point.class, Dimension.GEOMETRY, Type.MULTILINESTRING);
+    super(MultiLineString.class, Dimension.GEOMETRY, Type.MULTILINESTRING);
   }
 
+  @Override
+  protected <T> T internalValueOfString(final String value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode,
+          final Class<T> returnType) throws EdmPrimitiveTypeException {
+
+    final MultiLineString multiLineString =
+             stringToMultiLineString(value, isNullable, maxLength, precision, scale, isUnicode);
+    if (returnType.isAssignableFrom(MultiLineString.class)) {
+      return returnType.cast(multiLineString);
+    } else {
+      throw new EdmPrimitiveTypeException(
+              "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(returnType)");
+    }
+  }
+
+  @Override
+  protected <T> String internalValueToString(final T value, final Boolean isNullable, final Integer maxLength,
+          final Integer precision, final Integer scale, final Boolean isUnicode) throws EdmPrimitiveTypeException {
+
+    if (value instanceof MultiLineString) {
+      return toString((MultiLineString) value, isNullable, maxLength, precision, scale, isUnicode);
+    }
+
+    throw new EdmPrimitiveTypeException(
+            "EdmPrimitiveTypeException.VALUE_TYPE_NOT_SUPPORTED.addContent(value.getClass())");
+  }
 }