]> granicus.if.org Git - postgis/commitdiff
fix EWKT constructors to accept SRID=4711; representation
authorMarkus Schaber <markus@schabi.de>
Thu, 28 Jul 2005 12:23:16 +0000 (12:23 +0000)
committerMarkus Schaber <markus@schabi.de>
Thu, 28 Jul 2005 12:23:16 +0000 (12:23 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@1839 b70326c6-7e19-0410-871a-916f4a2858ee

CHANGES
jdbc2/src/org/postgis/ComposedGeom.java
jdbc2/src/org/postgis/Geometry.java
jdbc2/src/org/postgis/Point.java

diff --git a/CHANGES b/CHANGES
index c31d8e3477411f8d556a942dc8b7b5a0e71c0700..6cc6115df6be75ab5392cb69d79242a2ed83fe56 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,7 @@ PostGIS 1.1.0CVS
          + Support for (Hex)(E)wkb
          + Autoprobing DriverWrapper for HexWKB / EWKT switching
          + fix compile problems in ValueSetter for ancient jdk releases.
+         + fix EWKT constructors to accept SRID=4711; representation
        - full autoconf-based configuration
        - added scale() and transscale() companion methods to translate()
        - initial implementation of postgis_proc_upgrade script
index 3e3c27111fe046ae8a536fb4edf34c2155a5c5ee..c562a125464c996786749975a5f584d3706f1eb9 100644 (file)
@@ -68,7 +68,7 @@ public abstract class ComposedGeom extends Geometry {
     public int numGeoms() {
         return subgeoms.length;
     }
-    
+
     protected ComposedGeom(int type, Geometry[] geoms) {
         this(type);
         this.subgeoms = geoms;
@@ -82,7 +82,8 @@ public abstract class ComposedGeom extends Geometry {
 
     protected ComposedGeom(int type, String value, boolean haveM) throws SQLException {
         super(type);
-        value = value.trim();
+        value = initSRID(value);
+
         String typestring = getTypeString();
         if (value.indexOf(typestring) == 0) {
             int pfxlen = typestring.length();
index e9691db7a46495e778730ef21a562c19c3e8a322..d2552c1994141e98bf6d0fce892be72b0a7e8e69 100644 (file)
@@ -293,4 +293,24 @@ public abstract class Geometry implements Serializable {
         return (dimension >= 2 && dimension <= 3) && (type >= 0 && type <= 7);
     }
 
+    /**
+     * Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
+     * 
+     * @returns value without the SRID=4711; part
+     */
+    protected String initSRID(String value) {
+        value = value.trim();
+        if (value.startsWith("SRID=")) {
+            int index = value.indexOf(';', 5); // sridprefix length is 5
+            if (index == -1) {
+                throw new IllegalArgumentException(
+                        "Error parsing Geometry - SRID not delimited with ';' ");
+            } else {
+                this.srid = Integer.parseInt(value.substring(5, index));
+                return value.substring(index + 1).trim();
+            }
+        } else {
+            return value;
+        }
+    }
 }
index e22e9bc65b021c2d20dd3a45f3fd5698ecc22423..49a7ce31885bce20f7806a6f8303ef7a198de5e1 100644 (file)
@@ -144,7 +144,8 @@ public class Point extends Geometry {
      */
     protected Point(String value, boolean haveM) throws SQLException {
         this();
-        value = value.trim();
+        value = initSRID(value);
+
         if (value.indexOf("POINTM") == 0) {
             haveM = true;
             value = value.substring(6).trim();