PostgisDatastore createSchema creates table with wrong geometrytype
-------------------------------------------------------------------

                 Key: GEOT-3218
                 URL: http://jira.codehaus.org/browse/GEOT-3218
             Project: GeoTools
          Issue Type: Bug
          Components: data postgis
    Affects Versions: 2.6.4
            Reporter: Roy Braam
            Assignee: Justin Deoliveira


The PostgisDataStore.createSchema(SimpleFeatureType) is creating the wrong 
insert script for the geometry table.

The cause is the function:
{noformat} 
private String getGeometrySQLTypeName(Class type) {
    String res = (String) GEOM_CLASS_MAPPINGS.get(type);

    if (res == null) {
        throw new RuntimeException("Unknown type name for class " + type
            + " please update GEOMETRY_MAPPINGS");
    }

    return res;
}
{noformat}
That uses the static GEOM_CLASS_MAPPINGS:
But that one is created with the GEOM_TYPE_MAP like:
{noformat} 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);
        }
    }
{noformat} 

The GEOM_CLASS_MAPPINGS looks like this:
{noformat}
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);

        // SQL MM "Curve" extensions
        GEOM_TYPE_MAP.put("CIRCULARSTRING", LineString.class);
        GEOM_TYPE_MAP.put("COMPOUNDCURVE", LineString.class);
        GEOM_TYPE_MAP.put("CURVEPOLYGON", Polygon.class);
    }
{noformat}

The result is something like this:
{noformat}
GEOM_CLASS_MAPPINGS=
{
Polygon.class:"CURVEPOLYGON",
LineString.class:"COMPOUNDCURVE",
GeometryCollection.class:"GEOMETRYCOLLECTIONM",
MultiPolygon.class:"MULTIPOLYGONM",
MultiLineString.class:"MULTILINESTRINGM",
Point.class:"POINTM",
Geometry.class:"GEOMETRY"
}
{noformat}

So the command
{noformat}
GEOM_CLASS_MAPPINGS.get(LineString.class);
{noformat}
results in a "COMPOUNDCURVE".


-- 
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

        

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share 
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to