Strabon
changeset 188:e83e7ee94da5
trying to fix results indexes in MonetDB (e.g.: SpatialTests.testStrdfEnvelopeBuffer)
line diff
1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Wed May 23 13:28:04 2012 +0300 1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Wed May 23 14:25:50 2012 +0300 1.3 @@ -5,6 +5,7 @@ 1.4 */ 1.5 package org.openrdf.sail.generaldb.iteration; 1.6 1.7 +import java.sql.Blob; 1.8 import java.sql.PreparedStatement; 1.9 import java.sql.ResultSet; 1.10 import java.sql.SQLException; 1.11 @@ -26,6 +27,7 @@ 1.12 import org.openrdf.sail.rdbms.iteration.base.RdbmIterationBase; 1.13 import org.openrdf.sail.rdbms.model.RdbmsResource; 1.14 import org.openrdf.sail.rdbms.model.RdbmsValue; 1.15 +import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 1.16 import org.openrdf.sail.generaldb.schema.IdSequence; 1.17 import org.openrdf.sail.generaldb.schema.ValueTable; 1.18 1.19 @@ -108,6 +110,26 @@ 1.20 protected BindingSet convert(ResultSet rs) 1.21 throws SQLException 1.22 { 1.23 + 1.24 + /// debug 1.25 + for(int i=1; i<12;i++) { 1.26 + Object o = rs.getObject(i); 1.27 + if (o instanceof byte[] ) { 1.28 + byte[] label = rs.getBytes(i); 1.29 + int srid = rs.getInt(i + 1); 1.30 + GeneralDBPolyhedron g = vf.getRdbmsPolyhedron(114, StrabonPolyhedron.ogcGeometry, label, srid); 1.31 + System.out.println(i+": "+g.getPolyhedronStringRep()); 1.32 + } else if (o instanceof Blob ) { 1.33 + Blob labelBlob = rs.getBlob(i); 1.34 + byte[] label = labelBlob.getBytes((long)1, (int)labelBlob.length()); 1.35 + int srid = rs.getInt(i + 1); 1.36 + GeneralDBPolyhedron g = vf.getRdbmsPolyhedron(114, StrabonPolyhedron.ogcGeometry, label, srid); 1.37 + System.out.println(i+": "+g.getPolyhedronStringRep()); 1.38 + } 1.39 + else 1.40 + System.out.println(i+": "+rs.getObject(i)); 1.41 + } 1.42 + /// 1.43 1.44 QueryBindingSet result = new QueryBindingSet(bindings); 1.45 for (GeneralDBColumnVar var : projections) {
2.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java Wed May 23 13:28:04 2012 +0300 2.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/schema/GeoValueTable.java Wed May 23 14:25:50 2012 +0300 2.3 @@ -3,8 +3,6 @@ 2.4 2.5 2.6 //import org.apache.commons.codec.binary.Hex; 2.7 -import org.openrdf.sail.generaldb.GeneralDBSqlTable; 2.8 -import org.openrdf.sail.rdbms.schema.RdbmsTable; 2.9 import java.sql.PreparedStatement; 2.10 import java.sql.ResultSet; 2.11 import java.sql.SQLException; 2.12 @@ -12,7 +10,9 @@ 2.13 import java.util.ArrayList; 2.14 import java.util.List; 2.15 import java.util.concurrent.BlockingQueue; 2.16 -import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 2.17 + 2.18 +import org.openrdf.sail.generaldb.GeneralDBSqlTable; 2.19 +import org.openrdf.sail.rdbms.schema.RdbmsTable; 2.20 2.21 2.22 /**
3.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java Wed May 23 13:28:04 2012 +0300 3.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/iteration/MonetDBBindingIteration.java Wed May 23 14:25:50 2012 +0300 3.3 @@ -13,6 +13,7 @@ 3.4 import org.openrdf.query.BindingSet; 3.5 import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 3.6 import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration; 3.7 +import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 3.8 import org.openrdf.sail.rdbms.model.RdbmsValue; 3.9 3.10 /** 3.11 @@ -59,12 +60,10 @@ 3.12 protected RdbmsValue createBinaryGeoValueForSelectConstructs(ResultSet rs, int index) 3.13 throws SQLException 3.14 { 3.15 - 3.16 //Case of spatial constructs 3.17 Blob labelBlob = rs.getBlob(index + 1); 3.18 byte[] label = labelBlob.getBytes((long)1, (int)labelBlob.length()); 3.19 int srid = rs.getInt(index + 2); 3.20 return vf.getRdbmsPolyhedron(114, StrabonPolyhedron.ogcGeometry, label, srid); 3.21 - 3.22 } 3.23 } 3.24 \ No newline at end of file
4.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java Wed May 23 13:28:04 2012 +0300 4.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/iteration/PostGISBindingIteration.java Wed May 23 14:25:50 2012 +0300 4.3 @@ -13,6 +13,7 @@ 4.4 import org.openrdf.query.BindingSet; 4.5 import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 4.6 import org.openrdf.sail.generaldb.iteration.GeneralDBBindingIteration; 4.7 +import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron; 4.8 import org.openrdf.sail.rdbms.model.RdbmsValue; 4.9 4.10 /** 4.11 @@ -57,8 +58,7 @@ 4.12 @Override 4.13 protected RdbmsValue createBinaryGeoValueForSelectConstructs(ResultSet rs, int index) 4.14 throws SQLException 4.15 - { 4.16 - 4.17 + { 4.18 //Case of spatial constructs 4.19 byte[] label = rs.getBytes(index + 1); 4.20 int srid = rs.getInt(index + 2);
5.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Wed May 23 13:28:04 2012 +0300 5.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Wed May 23 14:25:50 2012 +0300 5.3 @@ -300,6 +300,7 @@ 5.4 String query = 5.5 prefixes+ 5.6 "SELECT DISTINCT ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+ 5.7 +// "SELECT DISTINCT ?g (strdf:buffer(?g, \"0.5\"^^xsd:float) as ?buf) ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+ 5.8 "WHERE { \n" + 5.9 " ?s ex:id ?id . \n"+ 5.10 " ?s ex:geometry ?g . \n" + 5.11 @@ -311,8 +312,8 @@ 5.12 5.13 assertEquals(1, bindings.size()); 5.14 5.15 - if ( -1<bindings.indexOf("[ret=\"POLYGON ((7.5 0.5, 7.5 2.5, 9.5 2.5, 9.5 0.5, 7.5 0.5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") || 5.16 - -1<bindings.indexOf("[ret=\"POLYGON ((7.542893218813453 0.5428932188134517, 9.457106781186548 0.5428932188134517, 9.457106781186548 2.4571067811865483, 7.542893218813453 2.4571067811865483, 7.542893218813453 0.5428932188134517))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") 5.17 + if ( -1<bindings.indexOf("[ret=\"POLYGON ((7.5 0.5, 7.5 2.5, 9.5 2.5, 9.5 0.5, 7.5 0.5));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") || 5.18 + -1<bindings.indexOf("[ret=\"POLYGON ((7.542893218813453 0.5428932188134517, 9.457106781186548 0.5428932188134517, 9.457106781186548 2.4571067811865483, 7.542893218813453 2.4571067811865483, 7.542893218813453 0.5428932188134517));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") 5.19 ) 5.20 assertTrue(true); 5.21 else 5.22 @@ -335,7 +336,7 @@ 5.23 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.24 5.25 assertEquals(1, bindings.size()); 5.26 - assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((50 5, 10 8, 10 10, 100 190, 150 30, 150 10, 50 5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.27 + assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((50 5, 10 8, 10 10, 100 190, 150 30, 150 10, 50 5));http://www.opengis.net/def/crs/EPSG/0/0\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.28 } 5.29 5.30 @Test 5.31 @@ -354,14 +355,14 @@ 5.32 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.33 5.34 assertEquals(1, bindings.size()); 5.35 - assertTrue(-1<bindings.indexOf("[ret=\"LINESTRING (8 1, 9 1, 9 2, 8 2, 8 1)\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); } 5.36 + assertTrue(-1<bindings.indexOf("[ret=\"LINESTRING (8 1, 9 1, 9 2, 8 2, 8 1);http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); } 5.37 5.38 @Test 5.39 public void testStrdfIntersection() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException 5.40 { 5.41 String query = 5.42 prefixes+ 5.43 - "SELECT DISTINCT ( strdf:intersection(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ 5.44 + "SELECT DISTINCT ( strdf:intersection(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^strdf:WKT) AS ?ret ) \n"+ 5.45 "WHERE { \n" + 5.46 " ?s ex:id ?id . \n"+ 5.47 " ?s ex:geometry ?g . \n" + 5.48 @@ -372,7 +373,7 @@ 5.49 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.50 5.51 assertEquals(1, bindings.size()); 5.52 - assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((10 3, 5 3, 5 8, 10 8, 10 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.53 + assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((10 3, 5 3, 5 8, 10 8, 10 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.54 } 5.55 5.56 @Test 5.57 @@ -391,7 +392,7 @@ 5.58 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.59 5.60 assertEquals(1, bindings.size()); 5.61 - assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 5 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.62 + assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 5 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.63 } 5.64 5.65 @Test 5.66 @@ -399,7 +400,7 @@ 5.67 { 5.68 String query = 5.69 prefixes+ 5.70 - "SELECT DISTINCT ( strdf:symDifference(?g, \"POLYGON((5 3, 12 3, 12 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ 5.71 + "SELECT DISTINCT ( strdf:symDifference(?g, \"POLYGON((5 3, 12 3, 12 8, 5 8, 5 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^strdf:WKT) AS ?ret ) \n"+ 5.72 "WHERE { \n" + 5.73 " ?s ex:id ?id . \n"+ 5.74 " ?s ex:geometry ?g . \n" + 5.75 @@ -410,7 +411,7 @@ 5.76 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.77 5.78 assertEquals(1, bindings.size()); 5.79 - assertTrue(-1<bindings.indexOf("[ret=\"MULTIPOLYGON (((5 3, 3 3, 3 8, 5 8, 5 3)), ((10 3, 10 8, 12 8, 12 3, 10 3)))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.80 + assertTrue(-1<bindings.indexOf("[ret=\"MULTIPOLYGON (((5 3, 3 3, 3 8, 5 8, 5 3)), ((10 3, 10 8, 12 8, 12 3, 10 3)));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.81 } 5.82 5.83 // // -- Spatial Metric Functions -- // 5.84 @@ -622,7 +623,7 @@ 5.85 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.86 5.87 assertEquals(1, bindings.size()); 5.88 - assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((50 5, 10 8, 10 10, 100 190, 150 30, 150 10, 50 5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.89 + assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((50 5, 10 8, 10 10, 100 190, 150 30, 150 10, 50 5));http://www.opengis.net/def/crs/EPSG/0/0\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.90 } 5.91 5.92 @Test 5.93 @@ -641,7 +642,7 @@ 5.94 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.95 5.96 assertEquals(1, bindings.size()); 5.97 - assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((10 3, 5 3, 5 8, 10 8, 10 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.98 + assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((10 3, 5 3, 5 8, 10 8, 10 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.99 } 5.100 5.101 @Test 5.102 @@ -660,7 +661,7 @@ 5.103 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.104 5.105 assertEquals(1, bindings.size()); 5.106 - assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 5 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.107 + assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 5 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.108 } 5.109 5.110 @Test 5.111 @@ -679,7 +680,7 @@ 5.112 ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection()); 5.113 5.114 assertEquals(1, bindings.size()); 5.115 - assertTrue(-1<bindings.indexOf("[ret=\"MULTIPOLYGON (((5 3, 3 3, 3 8, 5 8, 5 3)), ((10 3, 10 8, 12 8, 12 3, 10 3)))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.116 + assertTrue(-1<bindings.indexOf("[ret=\"MULTIPOLYGON (((5 3, 3 3, 3 8, 5 8, 5 3)), ((10 3, 10 8, 12 8, 12 3, 10 3)));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")); 5.117 } 5.118 5.119 @Test 5.120 @@ -699,8 +700,8 @@ 5.121 5.122 assertEquals(1, bindings.size()); 5.123 5.124 - if ( -1<bindings.indexOf("[ret=\"POLYGON ((7.5 0.5, 7.5 2.5, 9.5 2.5, 9.5 0.5, 7.5 0.5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") || 5.125 - -1<bindings.indexOf("[ret=\"POLYGON ((7.542893218813453 0.5428932188134517, 9.457106781186548 0.5428932188134517, 9.457106781186548 2.4571067811865483, 7.542893218813453 2.4571067811865483, 7.542893218813453 0.5428932188134517))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") 5.126 + if ( -1<bindings.indexOf("[ret=\"POLYGON ((7.5 0.5, 7.5 2.5, 9.5 2.5, 9.5 0.5, 7.5 0.5));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") || 5.127 + -1<bindings.indexOf("[ret=\"POLYGON ((7.542893218813453 0.5428932188134517, 9.457106781186548 0.5428932188134517, 9.457106781186548 2.4571067811865483, 7.542893218813453 2.4571067811865483, 7.542893218813453 0.5428932188134517));http://www.opengis.net/def/crs/EPSG/0/4326\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") 5.128 ) 5.129 assertTrue(true); 5.130 else
6.1 --- a/runtime/src/test/resources/spatial-tests-srid.nt Wed May 23 13:28:04 2012 +0300 6.2 +++ b/runtime/src/test/resources/spatial-tests-srid.nt Wed May 23 14:25:50 2012 +0300 6.3 @@ -18,13 +18,13 @@ 6.4 <http://example.org/pol7> <http://example.org/id> "G"^^<http://www.w3.org/2001/XMLSchema#string>. 6.5 <http://example.org/pol8> <http://example.org/id> "H"^^<http://www.w3.org/2001/XMLSchema#string>. 6.6 <http://example.org/pol9> <http://example.org/id> "Z"^^<http://www.w3.org/2001/XMLSchema#string>. 6.7 -<http://example.org/pol1> <http://example.org/geometry> "POLYGON((1 6, 2 6, 2 7, 1 7, 1 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.8 +<http://example.org/pol1> <http://example.org/geometry> "POLYGON((1 6, 2 6, 2 7, 1 7, 1 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.9 <http://example.org/pol11> <http://example.org/geometry> "POLYGON((1 6, 2 6, 2 7, 1 7, 1 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.10 -<http://example.org/pol2> <http://example.org/geometry> "POLYGON((4 2, 5 2, 5 4, 4 4, 4 2))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.11 -<http://example.org/pol3> <http://example.org/geometry> "POLYGON((8 1, 9 1, 9 2, 8 2, 8 1))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.12 -<http://example.org/pol4> <http://example.org/geometry> "POLYGON((11 6, 12 6, 12 7, 11 7, 11 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.13 -<http://example.org/pol5> <http://example.org/geometry> "POLYGON((8 6, 9 6, 9 7, 8 7, 8 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.14 -<http://example.org/pol6> <http://example.org/geometry> "POLYGON((6 7, 7 7, 7 8, 6 8, 6 7))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.15 -<http://example.org/pol7> <http://example.org/geometry> "POLYGON((4 8, 5 8, 5 9, 4 9, 4 8))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.16 -<http://example.org/pol8> <http://example.org/geometry> "POLYGON((8 9, 9 9, 9 10, 8 10, 8 9))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.17 -<http://example.org/pol9> <http://example.org/geometry> "POLYGON((3 3, 10 3, 10 8, 3 8, 3 3))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.18 +<http://example.org/pol2> <http://example.org/geometry> "POLYGON((4 2, 5 2, 5 4, 4 4, 4 2))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.19 +<http://example.org/pol3> <http://example.org/geometry> "POLYGON((8 1, 9 1, 9 2, 8 2, 8 1))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.20 +<http://example.org/pol4> <http://example.org/geometry> "POLYGON((11 6, 12 6, 12 7, 11 7, 11 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.21 +<http://example.org/pol5> <http://example.org/geometry> "POLYGON((8 6, 9 6, 9 7, 8 7, 8 6))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.22 +<http://example.org/pol6> <http://example.org/geometry> "POLYGON((6 7, 7 7, 7 8, 6 8, 6 7))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.23 +<http://example.org/pol7> <http://example.org/geometry> "POLYGON((4 8, 5 8, 5 9, 4 9, 4 8))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.24 +<http://example.org/pol8> <http://example.org/geometry> "POLYGON((8 9, 9 9, 9 10, 8 10, 8 9))"^^<http://strdf.di.uoa.gr/ontology#WKT>. 6.25 +<http://example.org/pol9> <http://example.org/geometry> "POLYGON((3 3, 10 3, 10 8, 3 8, 3 3))"^^<http://strdf.di.uoa.gr/ontology#WKT>.