<< Back to previous view

[NUCSPATIAL-4] Adapt Spatial mappings/literals/expressions to new SQL query mechanism and API Created: 10/Jul/09  Updated: 10/May/10  Resolved: 21/Apr/10

Status: Closed
Project: DataNucleus Types : Geospatial
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1.0.m2

Type: Task Priority: Major
Reporter: Andy Jefferson Assignee: Unassigned
Resolution: Fixed Votes: 1


 Comments   
Comment by Andy Jefferson [ 24/Dec/09 04:00 PM ]
Majority of the spatial method handlers are now present. Not tested
Comment by Andy Jefferson [ 21/Apr/10 07:39 PM ]
Marking as fixed since all implemented ... but untested. Perhaps some user may whine if something doesn't work :-)
Comment by Jan [ 07/May/10 09:38 AM ]
I'd volunteer to test it. I just have to enable the maven artifact datanucleus-spatial 2.1.0.m2 ?
Comment by Jan [ 07/May/10 10:34 AM ]
Ok I need some migration help. I updated my maven dependencies from 2.0.0-release to 2.1.0.m2.

When executing a spatial query ""Spatial.bboxTest(point,:buffer) && Spatial.within(point, :buffer)"" I got the exception: Unable to create SQLExpression for mapping of type "org.datanucleus.store.mapped.mapping.jts.PointMapping" since not supported]]

I looked at the previous debug messages and found: "DEBUG - Adding RDBMS support for Java type com.vividsolutions.jts.geom.Point (jdbc-type=OTHER, sql-type=geometry, datastore-mapping-type=org.datanucleus.store.rdbms.mapping.jts2postgis.PointRDBMSMapping, default=true)"

Clearly both Mapping classes are different so either I have a mix of the old/new dependencies in the classpath (checked it, restarted eclipse, but had maven issues like this before, so could still be). Or I have to enable the "new" version? Should I open a new report with full strack traces?

Cheers, Jan
Comment by Andy Jefferson [ 07/May/10 10:41 AM ]
Open up the spatial jar and try adding some entries to plugin.xml in the section for
<extension point="org.datanucleus.store.rdbms.sql_expression">

Add a block like this

        <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.GeometryMapping"
            literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
            expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>

replacing the mapping-class with the ones that it says are missing.
Comment by Jan [ 07/May/10 12:00 PM ]
Ok, first, here is a path against the current svn trunk (tested with Point and Polygon):

Index: plugin.xml
===================================================================
--- plugin.xml (revision 9771)
+++ plugin.xml (working copy)
@@ -33,6 +33,31 @@
         <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.GeometryMapping"
             literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
             expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.PointMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.PolygonMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.LineStringMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.GeometryCollectionMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.LinearRingMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.MultiLineStringMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.MultiPointMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+ <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.jts.MultiPolygonMapping"
+ literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
+ expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>
+
         <sql-expression mapping-class="org.datanucleus.store.mapped.mapping.ao.GeometryMapping"
             literal-class="org.datanucleus.store.rdbms.sql.expression.GeometryLiteral"
             expression-class="org.datanucleus.store.rdbms.sql.expression.GeometryExpression"/>


Now, another issue:

In GeometryLiteral Line 50:

    public GeometryLiteral(SQLStatement stmt, JavaTypeMapping mapping, Object value, String parameterName)
    {
        super(stmt, null, mapping);
        this.parameterName = parameterName;

        if (value == null)
        {
            this.value = null;
        }
        else
        {
            this.value = (Number)value; //Here is a class cast exception
        }
...
The actual type of value is a jts Polygon.class. Is it safe to remove the cast? Or what das the Number type mean at this point?
Comment by Jan [ 07/May/10 12:33 PM ]
Ok, removing the cast works for simple retrieval by primary key. Now, I tested the Spatial methods but got:

IllegalExpressionOperationException: Cannot perform operation ".within" on org.datanucleus.store.rdbms.sql.expression.UnboundExpression@1f140cf6]]

Do I also have to enable the "Spatial." expression in the plugin.xml? Plus I'll add the bboxTest method which is missing. Hope it will work ;-)

Jan
Comment by Andy Jefferson [ 09/May/10 07:15 PM ]
If there are updates needed in order to make this work (which there likely are) then raise a new JIRA and attach your patches there. This JIRA here was for the work needed in 2.1 m2 to add outline support for those expressions, and was closed because it is complete.
Comment by Andy Jefferson [ 10/May/10 08:35 AM ]
See NUCSPATIAL-10.
Generated at Sat Nov 18 11:02:39 CET 2017 using JIRA 4.0#466.