Issue Details (XML | Word | Printable)

Key: NUCSPATIAL-4
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Andy Jefferson
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
DataNucleus Types : Geospatial

Adapt Spatial mappings/literals/expressions to new SQL query mechanism and API

Created: 10/Jul/09 04:27 PM   Updated: 10/May/10 08:35 AM   Resolved: 21/Apr/10 07:39 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.1.0.m2


Andy Jefferson made changes - 11/Dec/09 08:47 PM
Field Original Value New Value
Fix Version/s 2.0.1 [ 10837 ]
Fix Version/s 2.0.0.release [ 10708 ]
Andy Jefferson added a comment - 24/Dec/09 04:00 PM
Majority of the spatial method handlers are now present. Not tested

Andy Jefferson added a comment - 21/Apr/10 07:39 PM
Marking as fixed since all implemented ... but untested. Perhaps some user may whine if something doesn't work :-)

Andy Jefferson made changes - 21/Apr/10 07:39 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 2.1.0.m2 [ 10940 ]
Fix Version/s 2.0.1 [ 10837 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 26/Apr/10 03:41 PM
Status Resolved [ 5 ] Closed [ 6 ]
Jan added a comment - 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 ?

Jan added a comment - 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

Andy Jefferson added a comment - 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.

Jan added a comment - 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?

Jan added a comment - 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

Andy Jefferson added a comment - 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.

Andy Jefferson added a comment - 10/May/10 08:35 AM