Strabon
changeset 1406:53c61cf49ed2
revert the behaviour of considering EPSG:4326 as lat/long in order to be in line with PostGIS; this is because PostGIS defines several of their functions, like ST_Buffer(Geometry, meters) on SRID 4326. Therefore, if we change this semantics, we would get 4326 lat/long and that would be chaotic
line diff
1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java Sun Sep 21 00:05:40 2014 +0300 1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java Sun Sep 21 14:36:42 2014 +0300 1.3 @@ -144,8 +144,8 @@ 1.4 // FIXME: handle invalid URIs 1.5 URI crs = URI.create(wkt.substring(1, uriIndx)); 1.6 1.7 - if (GeoConstants.WGS84_LONG_LAT.equals(crs.toString())) { 1.8 - srid = GeoConstants.WGS84_LONG_LAT_SRID; 1.9 + if (GeoConstants.CRS84_URI.equals(crs.toString())) { 1.10 + srid = GeoConstants.EPSG4326_SRID; 1.11 1.12 } else { // parse it to get the srid 1.13 // FIXME: this code assumes an EPSG URI
2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java Sun Sep 21 00:05:40 2014 +0300 2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java Sun Sep 21 14:36:42 2014 +0300 2.3 @@ -116,7 +116,7 @@ 2.4 return plainWKT; 2.5 2.6 } else { 2.7 - return plainWKT + ";" + getURI_forSRID(srid); 2.8 + return plainWKT + ";" + getEPSGURI_forSRID(srid); 2.9 } 2.10 } 2.11 2.12 @@ -134,29 +134,25 @@ 2.13 return plainWKT; 2.14 2.15 } else { 2.16 - return "<" + getURI_forSRID(srid) + "> " + plainWKT; 2.17 + return "<" + getEPSGURI_forSRID(srid) + "> " + plainWKT; 2.18 } 2.19 } 2.20 2.21 /** 2.22 * Returns the URI corresponding to the given SRID. 2.23 - * The given SRID might be an EPSG one or our custom 84000 2.24 - * corresponding to CRS84. If the given SRID is less than 2.25 + * The given SRID might only be an EPSG one. 2.26 + * If the given SRID is less than 2.27 * or equal to 0, then an empty string is returned. 2.28 * 2.29 * @param srid 2.30 * @return 2.31 */ 2.32 - public static String getURI_forSRID(int srid) { 2.33 - String uri = ""; 2.34 - if (srid == GeoConstants.WGS84_LONG_LAT_SRID) { 2.35 - uri = GeoConstants.WGS84_LONG_LAT; 2.36 - 2.37 - } else if (srid > 0) { // assuming EPSG now 2.38 - uri = GeoConstants.EPSG_URI_PREFIX + srid; 2.39 + public static String getEPSGURI_forSRID(int srid) { 2.40 + if (srid > 0) { // assuming EPSG now 2.41 + return GeoConstants.EPSG_URI_PREFIX + srid; 2.42 } 2.43 2.44 - return uri; 2.45 + return ""; 2.46 } 2.47 2.48 /** 2.49 @@ -169,8 +165,8 @@ 2.50 public static int getSRID_forURI(String uriCRS) { 2.51 if (uriCRS == null) return -1; 2.52 2.53 - if (GeoConstants.WGS84_LONG_LAT.equals(uriCRS)) { 2.54 - return GeoConstants.WGS84_LONG_LAT_SRID; 2.55 + if (GeoConstants.CRS84_URI.equals(uriCRS)) { 2.56 + return GeoConstants.EPSG4326_SRID; 2.57 2.58 } else { // should be an EPSG one, need to parse 2.59 try {
3.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java Sun Sep 21 00:05:40 2014 +0300 3.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java Sun Sep 21 14:36:42 2014 +0300 3.3 @@ -17,7 +17,6 @@ 3.4 3.5 import org.geotools.geometry.jts.JTS; 3.6 import org.geotools.referencing.CRS; 3.7 -import org.geotools.referencing.crs.DefaultGeographicCRS; 3.8 import org.opengis.geometry.MismatchedDimensionException; 3.9 import org.opengis.referencing.FactoryException; 3.10 import org.opengis.referencing.NoSuchAuthorityCodeException; 3.11 @@ -36,8 +35,6 @@ 3.12 import com.vividsolutions.jts.io.gml2.GMLReader; 3.13 import com.vividsolutions.jts.io.gml2.GMLWriter; 3.14 3.15 -import eu.earthobservatory.constants.GeoConstants; 3.16 - 3.17 /** 3.18 * This class is a singleton and provides access to the readers/writers 3.19 * of Java Topology Suite. 3.20 @@ -95,14 +92,14 @@ 3.21 return instance; 3.22 } 3.23 3.24 - protected CoordinateReferenceSystem getCRS(int srid) throws NoSuchAuthorityCodeException, FactoryException { 3.25 - if (srid == GeoConstants.WGS84_LONG_LAT_SRID) { 3.26 - return DefaultGeographicCRS.WGS84; 3.27 - 3.28 - } else { // otherwise lookup for EPSG code 3.29 + protected CoordinateReferenceSystem getEPSG_CRS(int srid) throws NoSuchAuthorityCodeException, FactoryException { 3.30 +// if (srid == GeoConstants.WGS84_LONG_LAT_SRID) { 3.31 +// return DefaultGeographicCRS.WGS84; 3.32 +// 3.33 +// } else { // otherwise lookup for EPSG code 3.34 // TODO: is there a way to be more general (than EPSG)? 3.35 return CRS.decode("EPSG:" + srid); 3.36 - } 3.37 +// } 3.38 } 3.39 3.40 public synchronized Geometry WKTread(String wkt) throws ParseException { 3.41 @@ -156,8 +153,8 @@ 3.42 3.43 MathTransform transform; 3.44 try { 3.45 - sourceCRS = getCRS(sourceSRID); 3.46 - targetCRS = getCRS(targetSRID); 3.47 + sourceCRS = getEPSG_CRS(sourceSRID); 3.48 + targetCRS = getEPSG_CRS(targetSRID); 3.49 transform = CRS.findMathTransform(sourceCRS, targetCRS, true); 3.50 3.51 output = JTS.transform(input, transform);
4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Sun Sep 21 00:05:40 2014 +0300 4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Sun Sep 21 14:36:42 2014 +0300 4.3 @@ -438,7 +438,7 @@ 4.4 ValueFactory localvf = ValueFactoryImpl.getInstance(); 4.5 4.6 if (function instanceof GeoSparqlGetSRIDFunc) { 4.7 - return localvf.createURI(WKTHelper.getURI_forSRID(getSRIDFromValue(leftResult))); 4.8 + return localvf.createURI(WKTHelper.getEPSGURI_forSRID(getSRIDFromValue(leftResult))); 4.9 4.10 } else if (function instanceof SridFunc) { 4.11 return localvf.createLiteral(getSRIDFromValue(leftResult));
5.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Sun Sep 21 00:05:40 2014 +0300 5.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/iteration/GeneralDBBindingIteration.java Sun Sep 21 14:36:42 2014 +0300 5.3 @@ -272,7 +272,7 @@ 5.4 // the result to a URI 5.5 // this is called for GeoSPARQL's getSRID, thus the column would be of type Integer 5.6 int srid = rs.getInt(index + 1); 5.7 - uri = WKTHelper.getURI_forSRID(srid); 5.8 + uri = WKTHelper.getEPSGURI_forSRID(srid); 5.9 5.10 } else { // we get this as a string first, and then we shall construct the URI 5.11 uri = rs.getString(index + 1);
6.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java Sun Sep 21 00:05:40 2014 +0300 6.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/PostGISSqlTable.java Sun Sep 21 14:36:42 2014 +0300 6.3 @@ -9,8 +9,6 @@ 6.4 6.5 import org.openrdf.sail.generaldb.GeneralDBSqlTable; 6.6 6.7 -import eu.earthobservatory.constants.GeoConstants; 6.8 - 6.9 /** 6.10 * Converts table names to lower-case and include the analyse optimisation. 6.11 * 6.12 @@ -20,7 +18,12 @@ 6.13 */ 6.14 public class PostGISSqlTable extends GeneralDBSqlTable { 6.15 6.16 - public static final int DEFAULT_SRID = GeoConstants.WGS84_LONG_LAT_SRID; 6.17 + /** 6.18 + * This value should not be changed whatever the semantics of Strabon 6.19 + * is for EPSG:4326. This number is hardcoded in PostGIS's SQL statements 6.20 + * that define several of their ST_ methods. 6.21 + */ 6.22 + public static final int DEFAULT_SRID = 4326; 6.23 6.24 public PostGISSqlTable(String name) { 6.25 super(name.toLowerCase());
7.1 --- a/resultio-spatial/sparqlgeojson/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java Sun Sep 21 00:05:40 2014 +0300 7.2 +++ b/resultio-spatial/sparqlgeojson/src/main/java/org/openrdf/query/resultio/sparqlgeojson/stSPARQLResultsGeoJSONWriter.java Sun Sep 21 14:36:42 2014 +0300 7.3 @@ -184,12 +184,12 @@ 7.4 sftb.setName("Feature_" + nresults + "_" + nfeatures); 7.5 sftb.add("geometry", Geometry.class); 7.6 7.7 - // CRS84 (or EPSG:4326 Long/Lat) is the default CRS for GeoJSON features 7.8 + // EPSG:4326 Long/Lat) is the default CRS for GeoJSON features 7.9 // we transform explicitly, because searching for "EPSG:<code>" CRSs is 7.10 // not the preferred way for GeoJSON (see here 7.11 // http://geojson.org/geojson-spec.html#coordinate-reference-system-objects). 7.12 // Instead the OGC CRS URNs should be preferred. 7.13 - geom = jts.transform(geom, srid, GeoConstants.WGS84_LONG_LAT_SRID); 7.14 + geom = jts.transform(geom, srid, GeoConstants.EPSG4326_SRID); 7.15 //sftb.setCRS(CRS.decode("EPSG:" + srid)); 7.16 //sftb.setSRS("EPSG:" + srid); 7.17
8.1 --- a/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Sun Sep 21 00:05:40 2014 +0300 8.2 +++ b/resultio-spatial/sparqlkml/src/main/java/org/openrdf/query/resultio/sparqlkml/stSPARQLResultsKMLWriter.java Sun Sep 21 14:36:42 2014 +0300 8.3 @@ -353,8 +353,8 @@ 8.4 } 8.5 } 8.6 8.7 - // transform the geometry to {@link GeoConstants#WGS84_LONG_LAT_SRID} 8.8 - geom = jts.transform(geom, srid, GeoConstants.WGS84_LONG_LAT_SRID); 8.9 + // transform the geometry to {@link GeoConstants#EPSG4326_SRID} 8.10 + geom = jts.transform(geom, srid, GeoConstants.EPSG4326_SRID); 8.11 8.12 if (geom instanceof Point) { 8.13 geometryType = KML.Point;
9.1 --- a/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Sun Sep 21 00:05:40 2014 +0300 9.2 +++ b/runtime/src/main/java/eu/earthobservatory/runtime/generaldb/Strabon.java Sun Sep 21 14:36:42 2014 +0300 9.3 @@ -115,8 +115,8 @@ 9.4 //Setting up store 9.5 9.6 //Used for the conversions taking place involving JTS + WGS84 (4326) 9.7 - Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE); 9.8 - //System.setProperty("org.geotools.referencing.forceXY", "true"); 9.9 + //Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.FALSE); 9.10 + System.setProperty("org.geotools.referencing.forceXY", "true"); 9.11 9.12 //our repository 9.13 repo = new GeneralDBSailRepository(db_store);
10.1 --- a/testsuite/src/test/resources/databases.properties Sun Sep 21 00:05:40 2014 +0300 10.2 +++ b/testsuite/src/test/resources/databases.properties Sun Sep 21 14:36:42 2014 +0300 10.3 @@ -1,5 +1,5 @@ 10.4 # PostGIS 10.5 -postgis.databaseTemplateName = template_strabon 10.6 +postgis.databaseTemplateName = template_postgis 10.7 postgis.serverName = localhost 10.8 postgis.username = postgres 10.9 postgis.password = postgres
11.1 --- a/testsuite/src/test/resources/geoSPARQL/GeometryLiteralsTest/DefaultCRS.srx Sun Sep 21 00:05:40 2014 +0300 11.2 +++ b/testsuite/src/test/resources/geoSPARQL/GeometryLiteralsTest/DefaultCRS.srx Sun Sep 21 14:36:42 2014 +0300 11.3 @@ -6,7 +6,7 @@ 11.4 <results> 11.5 <result> 11.6 <binding name='srid'> 11.7 - <uri>http://www.opengis.net/def/crs/OGC/1.3/CRS84</uri> 11.8 + <uri>http://www.opengis.net/def/crs/EPSG/0/4326</uri> 11.9 </binding> 11.10 </result> 11.11 </results>
12.1 --- a/testsuite/src/test/resources/stSPARQL/BasicFunctionsTest/AsGMLTest.srx Sun Sep 21 00:05:40 2014 +0300 12.2 +++ b/testsuite/src/test/resources/stSPARQL/BasicFunctionsTest/AsGMLTest.srx Sun Sep 21 14:36:42 2014 +0300 12.3 @@ -6,7 +6,7 @@ 12.4 <results> 12.5 <result> 12.6 <binding name='gml'> 12.7 - <literal><gml:Polygon srsName="CUSTOM:84000"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,0 1,0 1,1 0,1 0,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></literal> 12.8 + <literal><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,0 1,0 1,1 0,1 0,0</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></literal> 12.9 </binding> 12.10 </result> 12.11 </results>
13.1 --- a/testsuite/src/test/resources/stSPARQL/BasicFunctionsTest/SridTest.srx Sun Sep 21 00:05:40 2014 +0300 13.2 +++ b/testsuite/src/test/resources/stSPARQL/BasicFunctionsTest/SridTest.srx Sun Sep 21 14:36:42 2014 +0300 13.3 @@ -6,7 +6,7 @@ 13.4 <results> 13.5 <result> 13.6 <binding name='srid'> 13.7 - <literal datatype='http://www.w3.org/2001/XMLSchema#int'>84000</literal> 13.8 + <literal datatype='http://www.w3.org/2001/XMLSchema#int'>4326</literal> 13.9 </binding> 13.10 </result> 13.11 </results>
14.1 --- a/vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java Sun Sep 21 00:05:40 2014 +0300 14.2 +++ b/vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java Sun Sep 21 14:36:42 2014 +0300 14.3 @@ -168,43 +168,41 @@ 14.4 14.5 /** 14.6 * WGS 84 latitude-longitude (EPSG:4326) 14.7 + * 14.8 + * NOTICE: 14.9 + * We treat this CRS with long/lat semantics however, like 14.10 + * most of the world does. This is in contrast to what EPSG considers. 14.11 */ 14.12 - public static final String WGS84_LAT_LONG = EPSG_URI_PREFIX + "4326"; 14.13 + public static final String EPSG4326_URI = EPSG_URI_PREFIX + "4326"; 14.14 14.15 /** 14.16 * WGS 84 longitude-latitude 14.17 + * 14.18 + * NOTICE: 14.19 + * Yes, since we treat EPSG:4326 with a long/lat ordering, then OGC CRS84 14.20 + * is synonmous to EPSG:4326. 14.21 */ 14.22 - public static final String WGS84_LONG_LAT = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; 14.23 + public static final String CRS84_URI = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"; 14.24 14.25 /** 14.26 * EPSG:4326 14.27 */ 14.28 - public static final Integer WGS84_LAT_LONG_SRID = 4326; 14.29 + public static final Integer EPSG4326_SRID = 4326; 14.30 14.31 /** 14.32 - * The SRID for WGS84 long/lat does not exist, because no such CRS 14.33 - * exist in the EPSG database. Geotools return the same code, i.e., 14.34 - * EPSG:4326, but this is wrong to have here. Therefore, we use a 14.35 - * custom SRID inspired by the devil, and thus, it is our custom and 14.36 - * internal code for referencing the LONG/LAT version of EPSG:4326 14.37 - * (i.e., WGS84 lat/long). 14.38 + * Default stRDF/stSPARQL SRID 14.39 */ 14.40 - public static final Integer WGS84_LONG_LAT_SRID = 84000; 14.41 - 14.42 - /** 14.43 - * Default stRDF/stSPARQL SRID (WGS84 longitude-latitude) 14.44 - */ 14.45 - public static final Integer default_stRDF_SRID = WGS84_LONG_LAT_SRID; 14.46 + public static final Integer default_stRDF_SRID = EPSG4326_SRID; 14.47 14.48 /** 14.49 - * Default GeoSPARQL SRID (WGS84 longitude-latitude) 14.50 + * Default GeoSPARQL SRID 14.51 */ 14.52 - public static final Integer default_GeoSPARQL_SRID = WGS84_LONG_LAT_SRID; 14.53 + public static final Integer default_GeoSPARQL_SRID = EPSG4326_SRID; 14.54 14.55 /** 14.56 - * Default SRID (WGS84 longitude/latitude) 14.57 + * Default SRID 14.58 */ 14.59 - public static final Integer defaultSRID = WGS84_LONG_LAT_SRID; 14.60 + public static final Integer defaultSRID = EPSG4326_SRID; 14.61 14.62 /** 14.63 * Default datatype for creating new well-known text literals