Strabon

changeset 1392:64d97df71be4

correctly identify CRS URIs when present in the select clause in functions like strdf:transform
author Babis Nikolaou <charnik@di.uoa.gr>
date Thu Sep 18 14:37:10 2014 +0300 (2014-09-18)
parents a1137629f208
children b84809388dac
files endpoint/src/log4j.properties evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java
line diff
     1.1 --- a/endpoint/src/log4j.properties	Thu Sep 18 14:36:16 2014 +0300
     1.2 +++ b/endpoint/src/log4j.properties	Thu Sep 18 14:37:10 2014 +0300
     1.3 @@ -19,6 +19,7 @@
     1.4  # Sesame configuration (debug only Strabon)
     1.5  log4j.logger.org.openrdf.query.parser.QueryParserRegistry=INFO
     1.6  log4j.logger.org.openrdf.sail.generaldb.managers.TripleTableManager=INFO
     1.7 +#log4j.logger.org.openrdf.sail.postgis.evaluation.PostGISEvaluation=DEBUG
     1.8  
     1.9  # "Disable" logging for several services in Tomcat
    1.10  log4j.logger.org.springframework=WARN
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java	Thu Sep 18 14:36:16 2014 +0300
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/WKTHelper.java	Thu Sep 18 14:37:10 2014 +0300
     2.3 @@ -158,4 +158,28 @@
     2.4  		
     2.5  		return uri;
     2.6  	}
     2.7 +	
     2.8 +	/**
     2.9 +	 * Returns the SRID corresponding to the given URI identifying a CRS.
    2.10 +	 * In case of a malformed URI, it returns -1.
    2.11 +	 * 
    2.12 +	 * @param uriCRS
    2.13 +	 * @return
    2.14 +	 */
    2.15 +	public static int getSRID_forURI(String uriCRS) {
    2.16 +		if (uriCRS == null) return -1;
    2.17 +		
    2.18 +		if (GeoConstants.WGS84_LONG_LAT.equals(uriCRS)) {
    2.19 +			return GeoConstants.WGS84_LONG_LAT_SRID;
    2.20 +			
    2.21 +		} else { // should be an EPSG one, need to parse
    2.22 +			try {
    2.23 +				return Integer.parseInt(uriCRS.substring(uriCRS.lastIndexOf(CUT_DELIM) + 1).replace(URI_ENDING, ""));
    2.24 +				
    2.25 +			} catch (NumberFormatException e) {
    2.26 +				logger.warn("[Strabon.WKTHelper] Malformed URI for CRS. The URL was {}.", uriCRS);
    2.27 +				return -1;
    2.28 +			}
    2.29 +		}
    2.30 +	}
    2.31  }
     3.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Sep 18 14:36:16 2014 +0300
     3.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Sep 18 14:37:10 2014 +0300
     3.3 @@ -1314,10 +1314,9 @@
     3.4  				filter.keepSRID_part3();
     3.5  			}
     3.6  			else if(expr.getRightArg() instanceof GeneralDBStringValue)
     3.7 -			{
     3.8 -				String unparsedSRID = ((GeneralDBStringValue)expr.getRightArg()).getValue();
     3.9 -				// TODO Check for other kinds of URIs (e.g., not only for EPSG)
    3.10 -				sridExpr = String.valueOf(WKTHelper.getSRID(unparsedSRID));
    3.11 +			{ // the argument is the URI of a CRS
    3.12 +				String unparsedCRS = ((GeneralDBStringValue)expr.getRightArg()).getValue();
    3.13 +				sridExpr = String.valueOf(WKTHelper.getSRID_forURI(unparsedCRS));
    3.14  				filter.append(sridExpr);
    3.15  				filter.closeBracket();
    3.16  			}
     4.1 --- a/vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java	Thu Sep 18 14:36:16 2014 +0300
     4.2 +++ b/vocab/src/main/java/eu/earthobservatory/constants/GeoConstants.java	Thu Sep 18 14:37:10 2014 +0300
     4.3 @@ -192,7 +192,7 @@
     4.4  	public static final Integer WGS84_LONG_LAT_SRID = 84000;
     4.5  
     4.6  	/**
     4.7 -	 * Default stRDF/stSPARQL SRID (WGS84 latitude-longitude)
     4.8 +	 * Default stRDF/stSPARQL SRID (WGS84 longitude-latitude)
     4.9  	 */
    4.10  	public static final Integer default_stRDF_SRID = WGS84_LONG_LAT_SRID;
    4.11