Strabon

changeset 932:811b942248ee

fixed bug #33
author Babis Nikolaou <charnik@di.uoa.gr>
date Tue Mar 26 16:24:56 2013 +0200 (2013-03-26)
parents 2daceed2f0d0
children e9521141694b
files ChangeLog evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java
line diff
     1.1 --- a/ChangeLog	Tue Mar 26 13:33:50 2013 +0200
     1.2 +++ b/ChangeLog	Tue Mar 26 16:24:56 2013 +0200
     1.3 @@ -1,3 +1,11 @@
     1.4 +Day Month Date Hour:Min:Sec Year   Pyravlos Team
     1.5 +
     1.6 +	* Version 3.2.9 released.
     1.7 +
     1.8 +	* Support for parsing EPSG URIs in geometry literals with datatype
     1.9 +	geo:wktLiteral.
    1.10 +	(bug #33: http://bug.strabon.di.uoa.gr/ticket/33)
    1.11 +
    1.12  Tue Mar 26 13:28:26 2013   Pyravlos Team
    1.13  
    1.14  	* Version 3.2.8 released.
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java	Tue Mar 26 13:33:50 2013 +0200
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/AbstractWKT.java	Tue Mar 26 16:24:56 2013 +0200
     2.3 @@ -11,6 +11,9 @@
     2.4  
     2.5  import java.net.URI;
     2.6  
     2.7 +import org.slf4j.Logger;
     2.8 +import org.slf4j.LoggerFactory;
     2.9 +
    2.10  
    2.11  /**
    2.12   * This class generalizes WKT literal values that can be given according
    2.13 @@ -22,6 +25,8 @@
    2.14   */
    2.15  public class AbstractWKT {
    2.16  
    2.17 +	private static Logger logger = LoggerFactory.getLogger(org.openrdf.query.algebra.evaluation.function.spatial.AbstractWKT.class);
    2.18 +	
    2.19  	/**
    2.20  	 * WKT representation for an empty geometry
    2.21  	 * 
    2.22 @@ -91,7 +96,6 @@
    2.23  	
    2.24  	private void parseWKTLITERAL(String literalValue) {
    2.25  		wkt = literalValue.trim();
    2.26 -		// FIXME: the default value for wktLiteral
    2.27  		srid = GeoConstants.WGS84_LON_LAT_SRID;
    2.28  		
    2.29  		if (wkt.length() == 0) { // empty geometry
    2.30 @@ -100,15 +104,17 @@
    2.31  		
    2.32  		if (wkt.charAt(0) == '<') {// if a CRS URI is specified
    2.33  			int uriIndx = wkt.indexOf('>');
    2.34 +			
    2.35 +			// FIXME: handle invalid URIs
    2.36  			URI crs = URI.create(wkt.substring(1, uriIndx));
    2.37  			
    2.38 -			// FIXME: handle invalid URIs
    2.39  			// FIXME: get the SRID for crs properly. HOW??
    2.40 -			if (GeoConstants.WGS84_LAT_LON.equals(crs.toString())) {
    2.41 -				srid = GeoConstants.WGS84_LAT_LON_SRID;
    2.42 +			if (GeoConstants.WGS84_LON_LAT.equals(crs.toString())) {
    2.43 +				srid = GeoConstants.WGS84_LON_LAT_SRID;
    2.44  				
    2.45 -			} else if (GeoConstants.WGS84_LON_LAT.equals(crs.toString())) {
    2.46 -				srid = GeoConstants.WGS84_LON_LAT_SRID;
    2.47 +			} else { // parse it to get the srid
    2.48 +				// FIXME: this code assumes an EPSG URI
    2.49 +				srid = getEPSG_SRID(crs.toString());
    2.50  				
    2.51  			}
    2.52  			
    2.53 @@ -132,4 +138,27 @@
    2.54  	boolean isstRDFWKT() {
    2.55  		return isstRDFWKT;
    2.56  	}
    2.57 +	
    2.58 +	/**
    2.59 +	 * Returns the SRID corresponding to the URI of the given CRS. We assume
    2.60 +	 * EPSG URIs only.
    2.61 +	 * 
    2.62 +	 * In case of an error, the default is returned, i.e., {@link GeoConstants#defaultSRID}.
    2.63 +	 * 
    2.64 +	 * @param wkt
    2.65 +	 * @return
    2.66 +	 */
    2.67 +	protected int getEPSG_SRID(String wkt) {
    2.68 +		int srid = GeoConstants.defaultSRID;
    2.69 +		
    2.70 +		try {
    2.71 +			srid = Integer.parseInt(wkt.substring(wkt.lastIndexOf('/') + 1).replace(">", ""));
    2.72 +			
    2.73 +		} catch (NumberFormatException e) {
    2.74 +			logger.warn("[Strabon.AbstractWKT] Was expecting an integer. The URL of the EPSG SRID was {}. Continuing with the default SRID, {}", wkt, srid);
    2.75 +			
    2.76 +		}
    2.77 +		
    2.78 +		return srid;
    2.79 +	}
    2.80  }