Strabon
changeset 1480:4435a397080a
Removed from JTSWrapper.java the function getSRIDfromGMLString() and from AbstractWKT.java the function getEPSG_SRID() and altered the function getSRID() in WKTHelper.java to cover all three cases.
author | George Stamoulis <gstam@di.uoa.gr> |
---|---|
date | Fri Feb 13 13:29:40 2015 +0200 (2015-02-13) |
parents | 1decd8c5c45d |
children | 82f0d492d319 |
files | evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java |
line diff
1.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java Thu Feb 12 13:36:46 2015 +0200 1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java Fri Feb 13 13:29:40 2015 +0200 1.3 @@ -152,15 +152,17 @@ 1.4 // FIXME: handle invalid URIs 1.5 URI crs = URI.create(wkt.substring(1, uriIndx)); 1.6 1.7 + /* 1.8 if (GeoConstants.CRS84_URI.equals(crs.toString())) { 1.9 srid = GeoConstants.EPSG4326_SRID; 1.10 - 1.11 - } else { // parse it to get the srid 1.12 - // FIXME: this code assumes an EPSG URI 1.13 + } 1.14 + else { 1.15 srid = getEPSG_SRID(crs.toString()); 1.16 - 1.17 - } 1.18 + }*/ 1.19 1.20 + // FIXME: this code assumes an EPSG URI or CRS84 1.21 + srid = WKTHelper.getSRID(crs.toString()); 1.22 + 1.23 // trim spaces after URI and get the WKT value 1.24 wkt = wkt.substring(uriIndx + 1).trim(); 1.25 } 1.26 @@ -190,13 +192,13 @@ 1.27 * 1.28 * @param wkt 1.29 * @return 1.30 - */ 1.31 - protected int getEPSG_SRID(String wkt) { 1.32 + 1.33 + protected Integer getEPSG_SRID(String wkt) { 1.34 int srid = GeoConstants.defaultSRID; 1.35 1.36 try { 1.37 srid = Integer.parseInt(wkt.substring(wkt.lastIndexOf('/') + 1).replace(">", "")); 1.38 - 1.39 + 1.40 } catch (NumberFormatException e) { 1.41 logger.warn("[Strabon.AbstractWKT] Was expecting an integer. The URL of the EPSG SRID was {}. Continuing with the default SRID, {}", wkt, srid); 1.42 1.43 @@ -204,4 +206,5 @@ 1.44 1.45 return srid; 1.46 } 1.47 + */ 1.48 }
2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java Thu Feb 12 13:36:46 2015 +0200 2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java Fri Feb 13 13:29:40 2015 +0200 2.3 @@ -63,14 +63,20 @@ 2.4 2.5 if (wkt == null) return srid; 2.6 2.7 - int pos = wkt.lastIndexOf(STRDF_SRID_DELIM); 2.8 - if (pos != -1) { 2.9 - try { 2.10 + try { 2.11 + if (GeoConstants.CRS84_URI.equals(wkt)) { 2.12 + srid = GeoConstants.EPSG4326_SRID; 2.13 + } 2.14 + else { 2.15 srid = Integer.parseInt(wkt.substring(wkt.lastIndexOf(CUT_DELIM) + 1).replace(URI_ENDING, "")); 2.16 - 2.17 - } catch (NumberFormatException e) { 2.18 + } 2.19 + } catch (NumberFormatException e) { 2.20 + int pos = wkt.lastIndexOf(STRDF_SRID_DELIM); 2.21 + if (pos != -1) { 2.22 logger.warn("[Strabon.WKTHelper] Was expecting an integer. The URL of the SRID was {}. Continuing with the default SRID, {}", wkt.substring(pos + 1), srid); 2.23 - 2.24 + } 2.25 + else { 2.26 + logger.warn("[Strabon.WKTHelper] Was expecting an integer. The URL of the SRID was {}. Continuing with the default SRID, {}", wkt, srid); 2.27 } 2.28 } 2.29
3.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java Thu Feb 12 13:36:46 2015 +0200 3.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/util/JTSWrapper.java Fri Feb 13 13:29:40 2015 +0200 3.3 @@ -23,6 +23,8 @@ 3.4 import org.opengis.referencing.crs.CoordinateReferenceSystem; 3.5 import org.opengis.referencing.operation.MathTransform; 3.6 import org.opengis.referencing.operation.TransformException; 3.7 +import org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT; 3.8 +import org.openrdf.query.algebra.evaluation.function.spatial.WKTHelper; 3.9 import org.slf4j.Logger; 3.10 import org.slf4j.LoggerFactory; 3.11 3.12 @@ -226,7 +228,7 @@ 3.13 * then we have the string that represents the srid and we need to extract it and set it in the geometry inastance. 3.14 */ 3.15 if (geometry.getUserData() != null) { 3.16 - geometry.setSRID(getSRIDfromGMLString((String)geometry.getUserData())); 3.17 + geometry.setSRID(WKTHelper.getSRID((String)geometry.getUserData())); 3.18 return geometry; 3.19 } 3.20 else { 3.21 @@ -234,26 +236,6 @@ 3.22 } 3.23 } 3.24 3.25 - /** 3.26 - * Parse the userData string to find the SRID of the represented geometry. 3.27 - * We assume that the string represents an EPSG srid as defined in http://www.opengis.net/def/crs/EPSG/0 3.28 - * 3.29 - * @param gml 3.30 - * @return 3.31 - */ 3.32 - private int getSRIDfromGMLString(String reference) { 3.33 - int srid = GeoConstants.defaultSRID; 3.34 - 3.35 - try { 3.36 - srid = Integer.parseInt(reference.substring(reference.lastIndexOf('/') + 1)); 3.37 - 3.38 - } catch (NumberFormatException e) { 3.39 - logger.warn("[Strabon.AbstractWKT] Was expecting an integer. The URL of the EPSG SRID was {}. Continuing with the default SRID, {}", reference, srid); 3.40 - } 3.41 - 3.42 - return srid; 3.43 - } 3.44 - 3.45 public synchronized String GMLWrite(Geometry geom) { 3.46 return gmlw.write(geom); 3.47 }