From: <br...@us...> - 2007-05-30 18:27:43
|
Revision: 5952 http://svn.sourceforge.net/exist/?rev=5952&view=rev Author: brihaye Date: 2007-05-30 11:27:29 -0700 (Wed, 30 May 2007) Log Message: ----------- Refactored geometric properties with regard to output SRS. More test cases. Modified Paths: -------------- trunk/eXist/extensions/indexes/spatial/src/org/exist/indexing/spatial/AbstractGMLJDBCIndexWorker.java trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGMLProducers.java trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGeometricProperties.java trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/SpatialModule.java trunk/eXist/extensions/indexes/spatial/test/src/org/exist/indexing/spatial/GMLIndexTest.java Modified: trunk/eXist/extensions/indexes/spatial/src/org/exist/indexing/spatial/AbstractGMLJDBCIndexWorker.java =================================================================== --- trunk/eXist/extensions/indexes/spatial/src/org/exist/indexing/spatial/AbstractGMLJDBCIndexWorker.java 2007-05-30 16:59:40 UTC (rev 5951) +++ trunk/eXist/extensions/indexes/spatial/src/org/exist/indexing/spatial/AbstractGMLJDBCIndexWorker.java 2007-05-30 18:27:29 UTC (rev 5952) @@ -408,7 +408,7 @@ return streamedGeometry; } - public Element getGML(Geometry geometry, Receiver receiver) throws SpatialIndexException { + public Element getGML(Geometry geometry, String srsName, Receiver receiver) throws SpatialIndexException { //YES !!! String gmlString = null; try { Modified: trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGMLProducers.java =================================================================== --- trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGMLProducers.java 2007-05-30 16:59:40 UTC (rev 5951) +++ trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGMLProducers.java 2007-05-30 18:27:29 UTC (rev 5952) @@ -50,8 +50,16 @@ public class FunGMLProducers extends BasicFunction { public final static FunctionSignature[] signatures = { - //Functions that might depend from the SRS new FunctionSignature( + new QName("transform", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the GML representation of geometry $a with the SRS $b", + new SequenceType[]{ + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), + new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + }, + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) + ), + new FunctionSignature( new QName("WKTtoGML", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), "Returns the GML representation of WKT $a with the SRS $b", new SequenceType[]{ @@ -72,17 +80,6 @@ ), new FunctionSignature( new QName("buffer", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of a buffer around geometry $a having width $b in its CRS in the CRS specified by $c. " + - "Curves will be represented by 8 segments per circle quadrant.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) - }, - new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( - new QName("buffer", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), "Returns the GML representation of a buffer around geometry $a having width $b in its CRS. " + "Curves will be represented by $c segments per circle quadrant.", new SequenceType[]{ @@ -94,19 +91,6 @@ ), new FunctionSignature( new QName("buffer", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of a buffer around geometry $a having width $b in its CRS in the CRS specified by $c. " + - "Curves will be represented by $c segments per circle quadrant.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE), - new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) - }, - new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) - ) - , - new FunctionSignature( - new QName("buffer", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), "Returns the GML representation of a buffer around geometry $a having width $b in its CRS. " + "Curves will be represented by $c segments per circle quadrant.", new SequenceType[]{ @@ -117,20 +101,6 @@ }, new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) ), - new FunctionSignature( - new QName("buffer", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of a buffer around geometry $a having width $b in its CRS in the CRS specified by $c. " + - "Curves will be represented by $c segments per circle quadrant." + - "$d specifies the way line string ends are buffered : 1, as semi-circle, 2, as perpendicular straight lines, 3 as half-squares.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.DOUBLE, Cardinality.EXACTLY_ONE), - new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), - new SequenceType(Type.INTEGER, Cardinality.EXACTLY_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) - }, - new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) - ), new FunctionSignature( new QName("convexHull", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), "Returns the GML representation of the convex hull of geometry $a.", @@ -140,107 +110,49 @@ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("convexHull", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the convex hull of geometry $a in the CRS specified by $b.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) - }, - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( - new QName("boundary", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the boundary of geometry $a.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( new QName("boundary", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the boundary of geometry $a in the CRS specified by $b.", + "Returns the GML representation of the boundary of geometry $a.", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), + ), new FunctionSignature( - new QName("intersection", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the intersection of geometry $a and geometry $b.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( new QName("intersection", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the intersection of geometry $a and geometry $b in the CRS specified by $b.", + "Returns the GML representation of the intersection of geometry $a and geometry $b.", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), + ), new FunctionSignature( - new QName("union", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the union of geometry $a and geometry $b.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( new QName("union", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the union of geometry $a and geometry $b in the CRS specified by $b.", + "Returns the GML representation of the union of geometry $a and geometry $b.", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("difference", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the difference of geometry $a and geometry $b.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( new QName("difference", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the difference of geometry $a and geometry $b in the CRS specified by $b.", + "Returns the GML representation of the difference of geometry $a and geometry $b.", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), + ), new FunctionSignature( - new QName("symetricDifference", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the symetric difference of geometry $a and geometry $b.", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( new QName("symetricDifference", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the GML representation of the symetric difference of geometry $a and geometry $b in the CRS specified by $b.", + "Returns the GML representation of the symetric difference of geometry $a and geometry $b.", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - ), + ) }; public FunGMLProducers(XQueryContext context, FunctionSignature signature) { @@ -250,22 +162,42 @@ public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { Sequence result = null; try { - String originSrsName = null; - String targetSrsName = null; AbstractGMLJDBCIndexWorker indexWorker = (AbstractGMLJDBCIndexWorker) context.getBroker().getIndexController().getIndexWorkerById(AbstractGMLJDBCIndex.ID); if (indexWorker == null) throw new XPathException("Unable to find a spatial index worker"); Geometry geometry = null; - if (isCalledAs("WKTtoGML")) { + String srsName = null; + if (isCalledAs("transform")) { if (args[0].isEmpty()) result = Sequence.EMPTY_SEQUENCE; else { + NodeValue geometryNode = (NodeValue) args[0].itemAt(0); + String sourceSRS = null; + //Try to get the geometry from the index + if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) { + geometry = indexWorker.getGeometryForNode(context.getBroker(), (NodeProxy)geometryNode); + sourceSRS = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode, "SRS_NAME").getStringValue(); + //Otherwise, build it + } else { + geometry = indexWorker.streamGeometryForNode(context, geometryNode); + //Argl ! No SRS ! + //sourceSRS = ((Element)geometryNode).getAttribute("srsName").trim(); + //Erroneous workaround + sourceSRS = "osgb:BNG"; + } + srsName = args[1].itemAt(0).getStringValue().trim(); + geometry = indexWorker.transformGeometry(geometry, sourceSRS, srsName); + } + } else if (isCalledAs("WKTtoGML")) { + if (args[0].isEmpty()) + result = Sequence.EMPTY_SEQUENCE; + else { String wkt = args[0].itemAt(0).getStringValue(); - targetSrsName = args[1].itemAt(0).getStringValue().trim(); WKTReader wktReader = new WKTReader(); try { geometry = wktReader.read(wkt); + srsName = args[1].itemAt(0).getStringValue().trim(); } catch (ParseException e) { throw new XPathException(e); } @@ -276,11 +208,17 @@ else { NodeValue geometryNode = (NodeValue) args[0].itemAt(0); //Try to get the geometry from the index - if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) + if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) { geometry = indexWorker.getGeometryForNode(context.getBroker(), (NodeProxy)geometryNode); + srsName = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode, "SRS_NAME").getStringValue(); //Otherwise, build it - else - geometry = indexWorker.streamGeometryForNode(context, geometryNode); + } else { + geometry = indexWorker.streamGeometryForNode(context, geometryNode); + //Argl ! No SRS ! + //srsName = ((Element)geometryNode).getAttribute("srsName").trim(); + //Erroneous workaround + srsName = "osgb:BNG"; + } double distance = ((DoubleValue)args[1].itemAt(0)).getDouble(); int quadrantSegments = 8; int endCapStyle = BufferOp.CAP_ROUND; @@ -299,10 +237,6 @@ } geometry = geometry.buffer(distance, quadrantSegments, endCapStyle); - - //Get the SRS which is the last argument iff it is a string - if (Type.subTypeOf(args[getArgumentCount() - 1].itemAt(0).getType(), Type.STRING)) - targetSrsName = args[getArgumentCount() - 1].itemAt(0).getStringValue().trim(); } } else if (isCalledAs("convexHull")) { if (args[0].isEmpty()) @@ -310,13 +244,17 @@ else { NodeValue geometryNode = (NodeValue) args[0].itemAt(0); //Try to get the geometry from the index - if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) + if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) { geometry = indexWorker.getGeometryForNode(context.getBroker(), (NodeProxy)geometryNode); + srsName = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode, "SRS_NAME").getStringValue(); //Otherwise, build it - else - geometry = indexWorker.streamGeometryForNode(context, geometryNode); - if (getArgumentCount() > 1) - targetSrsName = args[1].itemAt(0).getStringValue().trim(); + } else { + geometry = indexWorker.streamGeometryForNode(context, geometryNode); + //Argl ! No SRS ! + //srsName = ((Element)geometryNode).getAttribute("srsName").trim(); + //Erroneous workaround + srsName = "osgb:BNG"; + } geometry = geometry.convexHull(); } } else if (isCalledAs("boundary")) { @@ -325,13 +263,17 @@ else { NodeValue geometryNode = (NodeValue) args[0].itemAt(0); //Try to get the geometry from the index - if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) + if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) { geometry = indexWorker.getGeometryForNode(context.getBroker(), (NodeProxy)geometryNode); + srsName = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode, "SRS_NAME").getStringValue(); //Otherwise, build it - else - geometry = indexWorker.streamGeometryForNode(context, geometryNode); - if (getArgumentCount() > 1) - targetSrsName = args[1].itemAt(0).getStringValue().trim(); + } else { + geometry = indexWorker.streamGeometryForNode(context, geometryNode); + //Argl ! No SRS ! + //srsName = ((Element)geometryNode).getAttribute("srsName").trim(); + //Erroneous workaround + srsName = "osgb:BNG"; + } geometry = geometry.getBoundary(); } } else { @@ -355,7 +297,7 @@ } if (geometryNode2.getImplementationType() == NodeValue.PERSISTENT_NODE) { geometry2 = indexWorker.getGeometryForNode(context.getBroker(), (NodeProxy)geometryNode2); - srsName2 = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode1, "SRS_NAME").getStringValue(); + srsName2 = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode2, "SRS_NAME").getStringValue(); } //Otherwise build them if (geometry1 == null) { @@ -363,17 +305,15 @@ //Argl ! No SRS ! //srsName1 = ((Element)geometryNode1).getAttribute("srsName").trim(); //Erroneous workaround - srsName1 = "EPSG:4326"; + srsName1 = "osgb:BNG"; } if (geometry2 == null) { geometry2 = indexWorker.streamGeometryForNode(context, geometryNode2); //Argl ! No SRS ! //srsName2 = ((Element)geometryNode2).getAttribute("srsName").trim(); //Erroneous workaround - srsName2 = "EPSG:4326"; + srsName2 = "osgb:BNG"; } - if (getArgumentCount() > 2) - targetSrsName = args[2].itemAt(0).getStringValue().trim(); //Transform the second geometry if necessary if (!srsName1.equalsIgnoreCase(srsName2)) { @@ -390,18 +330,10 @@ } else if (isCalledAs("symetricDifference")) { geometry = geometry1.symDifference(geometry2); } - - //Keep the first SRS for future use - originSrsName = srsName1; } } if (result == null) { - //Transform the geometry if necessary - if (targetSrsName != null && originSrsName != null && !originSrsName.equalsIgnoreCase(targetSrsName)) { - geometry = indexWorker.transformGeometry(geometry, originSrsName, targetSrsName) ; - } - String gmlPrefix = context.getPrefixForURI(AbstractGMLJDBCIndexWorker.GML_NS); if (gmlPrefix == null) throw new XPathException("'" + AbstractGMLJDBCIndexWorker.GML_NS + "' namespace is not defined"); @@ -410,7 +342,7 @@ try { MemTreeBuilder builder = context.getDocumentBuilder(); DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(builder); - result = (NodeValue)indexWorker.getGML(geometry, receiver); + result = (NodeValue)indexWorker.getGML(geometry, srsName, receiver); } finally { context.popDocumentContext(); } Modified: trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGeometricProperties.java =================================================================== --- trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGeometricProperties.java 2007-05-30 16:59:40 UTC (rev 5951) +++ trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/FunGeometricProperties.java 2007-05-30 18:27:29 UTC (rev 5952) @@ -30,6 +30,7 @@ import org.exist.indexing.spatial.SpatialIndexException; import org.exist.xquery.BasicFunction; import org.exist.xquery.Cardinality; +import org.exist.xquery.Constants; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XPathException; import org.exist.xquery.XQueryContext; @@ -45,17 +46,9 @@ import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.WKTWriter; -/** - * Created by IntelliJ IDEA. - * User: wolf - * Date: 28-Feb-2007 - * Time: 15:18:59 - * To change this template use File | Settings | File Templates. - */ public class FunGeometricProperties extends BasicFunction { public final static FunctionSignature[] signatures = { - //Functions that might depend from the SRS new FunctionSignature( new QName("GMLtoWKT", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), "Returns the WKT representation of geometry $a", @@ -65,142 +58,125 @@ new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("GMLtoWKT", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the WKT representation of geometry $a in the CRS specified by $b", + new QName("getMinX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the minimal X of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, - new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) + new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getMinX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the minimal X of geometry $a", + new QName("getMaxX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the maximal X of geometry $a", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getMinX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the minimal X of geometry $a in the CRS specified by $b", + new QName("getMinY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the minimal Y of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) - ), + ), new FunctionSignature( - new QName("getMaxX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the maximal X of geometry $a", + new QName("getMaxY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the maximal Y of geometry $a", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getMaxX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the maximal X of geometry $a in the CRS specified by $b", + new QName("getCentroidX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the X of centroid of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getMinY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the minimal Y of geometry $a", + new QName("getCentroidY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the Y of centroid of geometry $a", new SequenceType[]{ new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getMinY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the minimal Y of geometry $a in the CRS specified by $b", + new QName("getArea", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the area of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getMaxY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the maximal Y of geometry $a", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) - ), + new QName("getEPSG4326MinX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the minimal X of geometry $a", + new SequenceType[]{ + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) + }, + new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) + ), new FunctionSignature( - new QName("getMaxY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the maximal Y of geometry $a in the CRS specified by $b", + new QName("getEPSG4326MaxX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the maximal X of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getCentroidX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the X of centroid of geometry $a", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) - ), + new QName("getEPSG4326MinY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the minimal Y of geometry $a", + new SequenceType[]{ + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) + }, + new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) + ), new FunctionSignature( - new QName("getCentroidX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the X of centroid of geometry $a in the CRS specified by $b", + new QName("getEPSG4326MaxY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the maximal Y of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("getCentroidY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the Y of centroid of geometry $a", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) - ), + new QName("getEPSG4326CentroidX", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the X of centroid of geometry $a", + new SequenceType[]{ + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) + }, + new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) + ), new FunctionSignature( - new QName("getCentroidY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the Y of centroid of geometry $a in the CRS specified by $b", + new QName("getEPSG4326CentroidY", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the Y of centroid of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), new FunctionSignature( - new QName("area", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the area of geometry $a", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) - }, - new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) - ), - new FunctionSignature( - new QName("area", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the area of geometry $a in the CRS specified by $b", + new QName("getEPSG4326Area", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the area of geometry $a", new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE) + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE) }, new SequenceType(Type.DOUBLE, Cardinality.ZERO_OR_ONE) ), - //Functions that do no depend of the CRS new FunctionSignature( - new QName("getSRS", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), - "Returns the spatial reference system of geometry $a", - new SequenceType[]{ - new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), - }, - new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) - ), + new QName("getSRS", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), + "Returns the spatial reference system of geometry $a", + new SequenceType[]{ + new SequenceType(Type.NODE, Cardinality.ZERO_OR_ONE), + }, + new SequenceType(Type.STRING, Cardinality.ZERO_OR_ONE) + ), new FunctionSignature( new QName("getGeometryType", SpatialModule.NAMESPACE_URI, SpatialModule.PREFIX), "Returns the type of geometry $a", @@ -246,36 +222,45 @@ result = Sequence.EMPTY_SEQUENCE; else { try { - String targetSrsName= null; Geometry geometry = null; - if (getArgumentCount() == 2) - targetSrsName = args[1].itemAt(0).getStringValue().trim(); + String sourceCRS = null; AbstractGMLJDBCIndexWorker indexWorker = (AbstractGMLJDBCIndexWorker) context.getBroker().getIndexController().getIndexWorkerById(AbstractGMLJDBCIndex.ID); if (indexWorker == null) throw new XPathException("Unable to find a spatial index worker"); NodeValue geometryNode = (NodeValue) nodes.itemAt(0); if (geometryNode.getImplementationType() == NodeValue.PERSISTENT_NODE) { - boolean optimizeOnEpsg4326 = false; - //TODO : try to spot equivalent CRS - optimizeOnEpsg4326 = "EPSG:4326".equalsIgnoreCase(targetSrsName); String propertyName = null; if (isCalledAs("GMLtoWKT")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_WKT" : "WKT"; + propertyName = "WKT"; } else if (isCalledAs("getMinX")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_MINX" : "MINX"; + propertyName = "MINX"; } else if (isCalledAs("getMaxX")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_MAXX" : "MAXX"; + propertyName = "MAXX"; } else if (isCalledAs("getMinY")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_MINY" : "MINY"; + propertyName = "MINY"; } else if (isCalledAs("getMaxY")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_MAXY" : "MAXY"; + propertyName = "MAXY"; } else if (isCalledAs("getCentroidX")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_CENTROID_X" : "CENTROID_X"; + propertyName = "CENTROID_X"; } else if (isCalledAs("getCentroidY")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_CENTROID_Y" : "CENTROID_Y"; - } else if (isCalledAs("area")) { - propertyName = optimizeOnEpsg4326 ? "EPSG4326_AREA" : "AREA"; + propertyName = "CENTROID_Y"; + } else if (isCalledAs("getArea")) { + propertyName = "AREA"; + } else if (isCalledAs("getEPSG4326MinX")) { + propertyName = "EPSG4326_MINX"; + } else if (isCalledAs("getEPSG4326MaxX")) { + propertyName = "EPSG4326_MAXX"; + } else if (isCalledAs("getEPSG4326MinY")) { + propertyName = "EPSG4326_MINY"; + } else if (isCalledAs("getEPSG4326MaxY")) { + propertyName = "EPSG4326_MAXY"; + } else if (isCalledAs("getEPSG4326CentroidX")) { + propertyName = "EPSG4326_CENTROID_X"; + } else if (isCalledAs("getEPSG4326CentroidY")) { + propertyName = "EPSG4326_CENTROID_Y"; + } else if (isCalledAs("getEPSG4326Area")) { + propertyName = "EPSG4326_AREA"; } else if (isCalledAs("getSRS")) { propertyName = "SRS_NAME"; } else if (isCalledAs("getGeometryType")) { @@ -288,25 +273,44 @@ propertyName = "IS_VALID"; } else throw new XPathException("Unknown spatial property: " + mySignature.getName().getLocalName()); - if (propertyName != null) + if (propertyName != null) { //The node should be indexed : get its properties result = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode, propertyName); - else + } else { //Or, at least, its geometry for further processing geometry = indexWorker.getGeometryForNode(context.getBroker(), (NodeProxy)geometryNode); + sourceCRS = indexWorker.getGeometricPropertyForNode(context.getBroker(), (NodeProxy)geometryNode, "SRS_NAME").getStringValue(); + } } if (result == null) { - if (geometry == null) { - //builds the geometry + //builds the geometry + if (geometry == null) { geometry = indexWorker.streamGeometryForNode(context, geometryNode); + //Argl ! No SRS ! + //sourceCRS = ((Element)geometryNode).getAttribute("srsName").trim(); + //Erroneous workaround + sourceCRS = "osgb:BNG"; } - if (geometry == null) - throw new XPathException(geometryNode.getNode().getLocalName() + " is not a GML geometry node"); - //Transform the geometry if necessary - String originSrsName = ((Element)geometryNode).getAttribute("srsName").trim(); - if (targetSrsName != null && !originSrsName.equalsIgnoreCase(targetSrsName)) - geometry = indexWorker.transformGeometry(geometry, originSrsName, targetSrsName); - if (isCalledAs("GMLtoWKT")) { + + //Transform the geometry to EPSG:4326 if relevant + if (mySignature.getName().getLocalName().indexOf("EPSG4326") != Constants.STRING_NOT_FOUND) { + geometry = indexWorker.transformGeometry(geometry, sourceCRS, "EPSG:4326"); + if (isCalledAs("getEPSG4326MinX")) { + result = new DoubleValue(geometry.getEnvelopeInternal().getMinX()); + } else if (isCalledAs("getEPSG4326MaxX")) { + result = new DoubleValue(geometry.getEnvelopeInternal().getMaxX()); + } else if (isCalledAs("getEPSG4326MinY")) { + result = new DoubleValue(geometry.getEnvelopeInternal().getMinY()); + } else if (isCalledAs("getEPSG4326MaxY")) { + result = new DoubleValue(geometry.getEnvelopeInternal().getMaxY()); + } else if (isCalledAs("getEPSG4326CentroidX")) { + result = new DoubleValue(geometry.getCentroid().getX()); + } else if (isCalledAs("getEPSG4326CentroidY")) { + result = new DoubleValue(geometry.getCentroid().getY()); + } else if (isCalledAs("getEPSG4326Area")) { + result = new DoubleValue(geometry.getArea()); + } + } else if (isCalledAs("GMLtoWKT")) { WKTWriter wktWriter = new WKTWriter(); result = new StringValue(wktWriter.write(geometry)); } else if (isCalledAs("getMinX")) { @@ -321,6 +325,8 @@ result = new DoubleValue(geometry.getCentroid().getX()); } else if (isCalledAs("getCentroidY")) { result = new DoubleValue(geometry.getCentroid().getY()); + } else if (isCalledAs("getArea")) { + result = new DoubleValue(geometry.getArea()); } else if (isCalledAs("getSRS")) { result = new StringValue(((Element)geometryNode).getAttribute("srsName")); } else if (isCalledAs("getGeometryType")) { Modified: trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/SpatialModule.java =================================================================== --- trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/SpatialModule.java 2007-05-30 16:59:40 UTC (rev 5951) +++ trunk/eXist/extensions/indexes/spatial/src/org/exist/xquery/modules/spatial/SpatialModule.java 2007-05-30 18:27:29 UTC (rev 5952) @@ -60,8 +60,8 @@ new FunctionDef(FunGeometricProperties.signatures[16], FunGeometricProperties.class), new FunctionDef(FunGeometricProperties.signatures[17], FunGeometricProperties.class), new FunctionDef(FunGeometricProperties.signatures[18], FunGeometricProperties.class), + new FunctionDef(FunGeometricProperties.signatures[18], FunGeometricProperties.class), new FunctionDef(FunGeometricProperties.signatures[19], FunGeometricProperties.class), - new FunctionDef(FunGeometricProperties.signatures[20], FunGeometricProperties.class), new FunctionDef(FunGMLProducers.signatures[0], FunGMLProducers.class), new FunctionDef(FunGMLProducers.signatures[1], FunGMLProducers.class), new FunctionDef(FunGMLProducers.signatures[2], FunGMLProducers.class), @@ -72,15 +72,7 @@ new FunctionDef(FunGMLProducers.signatures[7], FunGMLProducers.class), new FunctionDef(FunGMLProducers.signatures[8], FunGMLProducers.class), new FunctionDef(FunGMLProducers.signatures[9], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[10], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[11], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[12], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[13], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[14], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[15], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[16], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[17], FunGMLProducers.class), - new FunctionDef(FunGMLProducers.signatures[18], FunGMLProducers.class) + new FunctionDef(FunGMLProducers.signatures[10], FunGMLProducers.class) }; public SpatialModule() { Modified: trunk/eXist/extensions/indexes/spatial/test/src/org/exist/indexing/spatial/GMLIndexTest.java =================================================================== --- trunk/eXist/extensions/indexes/spatial/test/src/org/exist/indexing/spatial/GMLIndexTest.java 2007-05-30 16:59:40 UTC (rev 5951) +++ trunk/eXist/extensions/indexes/spatial/test/src/org/exist/indexing/spatial/GMLIndexTest.java 2007-05-30 18:27:29 UTC (rev 5952) @@ -389,100 +389,107 @@ Sequence seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:GMLtoWKT(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getMinX(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinX(//gml:Polygon[1])"; + "spatial:getMaxX(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinX(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getMinY(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxX(//gml:Polygon[1])"; + "spatial:getMaxY(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxX(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getCentroidX(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinY(//gml:Polygon[1])"; + "spatial:getCentroidY(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinY(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getArea(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxY(//gml:Polygon[1])"; + "spatial:getEPSG4326MinX(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxY(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326MaxX(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); - assertTrue(seq.getItemCount() > 0); + assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getCentroidX(//gml:Polygon[1])"; + "spatial:getEPSG4326MinY(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getCentroidX(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326MaxY(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getCentroidY(//gml:Polygon[1])"; + "spatial:getEPSG4326CentroidX(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getCentroidY(//gml:Polygon[1], 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326CentroidY(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326Area(//gml:Polygon[1])"; + seq = xquery.execute(query, null, AccessContext.TEST); + assertNotNull(seq); + assertTrue(seq.getItemCount() > 0); + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + "spatial:getSRS(//gml:Polygon[1])"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); @@ -527,12 +534,11 @@ query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:GMLtoWKT((), 'EPSG:4326')"; + "spatial:getArea(())"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); - assertTrue(seq.getItemCount() == 0); - - //In-memory tests + assertTrue(seq.getItemCount() == 0); + //In-memory tests query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + @@ -540,98 +546,109 @@ seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:GMLtoWKT(" + IN_MEMORY_GML + ", 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getMinX(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinX(" + IN_MEMORY_GML + ")"; + "spatial:getMaxX(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinX(" + IN_MEMORY_GML + ", 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getMinY(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxX(" + IN_MEMORY_GML + ")"; + "spatial:getMaxY(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxX(" + IN_MEMORY_GML + ", 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getCentroidX(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinY(" + IN_MEMORY_GML + ")"; + "spatial:getCentroidY(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getArea(" + IN_MEMORY_GML + ")"; + seq = xquery.execute(query, null, AccessContext.TEST); + assertNotNull(seq); + assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMinY(" + IN_MEMORY_GML + ", 'EPSG:4326')"; + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326MinX(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxY(" + IN_MEMORY_GML + ")"; + "spatial:getEPSG4326MaxX(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getMaxY(" + IN_MEMORY_GML + ", 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326MinY(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); - assertTrue(seq.getItemCount() > 0); + assertTrue(seq.getItemCount() > 0); query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getCentroidX(" + IN_MEMORY_GML + ")"; + "spatial:getEPSG4326MaxY(" + IN_MEMORY_GML + ")"; seq = xquery.execute(query, null, AccessContext.TEST); assertNotNull(seq); assertTrue(seq.getItemCount() > 0); - query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + - "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + - "declare namespace gml = 'http://www.opengis.net/gml'; " + - "spatial:getCentroidX(" + IN_MEMORY_GML + ", 'EPSG:4326')"; + query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " + + "at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " + + "declare namespace gml = 'http://www.opengis.net/gml'; " + + "spatial:getEPSG4326CentroidX(" + IN_MEMORY_GML + ")... [truncated message content] |