GEOM_TYPE_MAP field in PostgisDatasStore
----------------------------------------

                 Key: GEOT-2420
                 URL: http://jira.codehaus.org/browse/GEOT-2420
             Project: GeoTools
          Issue Type: Bug
          Components: data postgis
    Affects Versions: 2.5.3
         Environment: Windows Vista Home Premium, JDK1.5.0_17
            Reporter: Tobia Di Pisa
            Assignee: Justin Deoliveira
             Fix For: 2.5.5


I have found a problem inside the PostgisDataStore. 
Using the latter to insert some geometries inside the DB only the 
geometries M are inserted. 
As an instance the DB a type POINT is always mapped as type POINTM.

Analyzing a bit more the issue I discovered that inside PostgisDataStore some 
code appears to me quite strange.
For instance at line 1315 the follwing if ... else statement

                if (geomAttribute instanceof GeometryDescriptor) {
                    typeName = getGeometrySQLTypeName(type);
                } else {
                    typeName = (String) CLASS_MAPPINGS.get(type);
                }

will never execute the else part since before at line 1279 the geomAttribute is 
defined as

              GeometryDescriptor geomAttribute = (GeometryDescriptor) 
attributeType[i];

moreover the HashMap defined at line 135 GEOM_TYPE_MAP to same classes 
different DB types (POINT and POINTM are associated to jts Point.class as an 
instance) but the HashMap GEOM_CLASS_MAPPINGS at line 175 (the one used by the 
statements above) will loose one of the values since associates to the same key 
more than one value.

Here below the code in PostgisDataStore:
    ...
    static {
        GEOM_TYPE_MAP.put("GEOMETRY", Geometry.class);
        GEOM_TYPE_MAP.put("POINT", Point.class);
        GEOM_TYPE_MAP.put("POINTM", Point.class);
        GEOM_TYPE_MAP.put("LINESTRING", LineString.class);
        GEOM_TYPE_MAP.put("LINESTRINGM", LineString.class);
        GEOM_TYPE_MAP.put("POLYGON", Polygon.class);
        GEOM_TYPE_MAP.put("POLYGONM", Polygon.class);
        GEOM_TYPE_MAP.put("MULTIPOINT", MultiPoint.class);
        GEOM_TYPE_MAP.put("MULTIPOINTM", MultiPoint.class);
        GEOM_TYPE_MAP.put("MULTILINESTRING", MultiLineString.class);
        GEOM_TYPE_MAP.put("MULTILINESTRINGM", MultiLineString.class);
        GEOM_TYPE_MAP.put("MULTIPOLYGON", MultiPolygon.class);
        GEOM_TYPE_MAP.put("MULTIPOLYGONM", MultiPolygon.class);
        GEOM_TYPE_MAP.put("GEOMETRYCOLLECTION", GeometryCollection.class);
        GEOM_TYPE_MAP.put("GEOMETRYCOLLECTIONM", GeometryCollection.class);
    }

    ....

    private static Map GEOM_CLASS_MAPPINGS = new HashMap();
    
    //why don't we just stick this in with the non-geom class mappings?
    static {
        // init the inverse map
        Set keys = GEOM_TYPE_MAP.keySet();

        for (Iterator it = keys.iterator(); it.hasNext();) {
            String name = (String) it.next();
            Class geomClass = (Class) GEOM_TYPE_MAP.get(name);
            GEOM_CLASS_MAPPINGS.put(geomClass, name);
        }
    }
    ...

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to