DBBroker broker = null;
try {
pool = BrokerPool.getInstance();
assertNotNull(pool);
broker = pool.get(pool.getSecurityManager().getSystemSubject());
XQuery xquery = broker.getXQueryService();
assertNotNull(xquery);
String 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:transform((//gml:Polygon)[1], 'EPSG:4326')";
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:getWKT((//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:buffer((//gml:Polygon)[1], 100)";
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:buffer((//gml:Polygon)[1], 100, 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:getBbox((//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:convexHull((//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:boundary((//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:intersection((//gml:Polygon)[1], (//gml:Polygon)[2])";
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:union((//gml:Polygon)[1], (//gml:Polygon)[2])";
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:difference((//gml:Polygon)[1], (//gml:Polygon)[2])";
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:symetricDifference((//gml:Polygon)[1], (//gml:Polygon)[2])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
//Tests with empty sequences
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:transform((), 'EPSG:4326')";
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:getWKT(())";
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:buffer((), 100)";
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:buffer((), 100, 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:getBbox(())";
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:convexHull(())";
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:boundary(())";
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:union((), ())";
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:union((//gml:Polygon)[1], ())";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() == 1);
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:union((), (//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() == 1);
//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'; " +
"spatial:transform(" + IN_MEMORY_GML + ", 'EPSG:4326')";
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:buffer(" + IN_MEMORY_GML + ", 100)";
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:buffer(" + IN_MEMORY_GML + ", 100, 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:getBbox(" + 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:convexHull(" + 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:boundary(" + 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:intersection(" + IN_MEMORY_GML + ", (//gml:Polygon)[2])";
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:union(" + IN_MEMORY_GML + ", (//gml:Polygon)[2])";
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:difference(" + IN_MEMORY_GML + ", (//gml:Polygon)[2])";
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:symetricDifference(" + IN_MEMORY_GML + ", (//gml:Polygon)[2])";
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:intersection((//gml:Polygon)[1]," + 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:union((//gml:Polygon)[1]," + 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:difference((//gml:Polygon)[1]," + 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:symetricDifference((//gml:Polygon)[1]," + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
} catch (Exception e) {
e.printStackTrace();