Strabon

changeset 984:ec3e8a847277

merge
author Babis Nikolaou <charnik@di.uoa.gr>
date Fri Apr 05 15:42:01 2013 +0300 (2013-04-05)
parents f3fa13082d55 f5ca44796e2f
children 96dca198fcff
files
line diff
     1.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Apr 05 15:37:14 2013 +0300
     1.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Apr 05 15:42:01 2013 +0300
     1.3 @@ -105,6 +105,7 @@
     1.4  import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException;
     1.5  
     1.6  import eu.earthobservatory.constants.GeoConstants;
     1.7 +import eu.earthobservatory.constants.OGCConstants;
     1.8  
     1.9  /**
    1.10   * Constructs an SQL query from {@link GeneralDBSqlExpr}s and {@link GeneralDBFromItem}s.
    1.11 @@ -118,6 +119,7 @@
    1.12  	public static final String SRID_FIELD = "srid";
    1.13  	public static final String ST_TRANSFORM = "ST_Transform";
    1.14  	public static final String ST_ASBINARY = "ST_AsBinary";
    1.15 +	public static final String GEOGRAPHY = "Geography";
    1.16  	/**
    1.17  	 * If (spatial) label column met is null, I must not try to retrieve its srid. 
    1.18  	 * Opting to ask for 'null' instead
    1.19 @@ -1626,20 +1628,26 @@
    1.20  			filter.openBracket();
    1.21  	
    1.22  			if (expr.getThirdArg() instanceof GeneralDBStringValue)
    1.23 -			{			
    1.24 -				String unparsedUnits = ((GeneralDBStringValue)expr.getThirdArg()).getValue();
    1.25 -
    1.26 -				units = unparsedUnits.substring(unparsedUnits.lastIndexOf('/')+1);
    1.27 -				if(units.equals("metre") || units.equals("meter"))
    1.28 -				{					
    1.29 -					filter.appendFunction("GEOGRAPHY");
    1.30 +			{	
    1.31 +				
    1.32 +				units = ((GeneralDBStringValue)expr.getThirdArg()).getValue();
    1.33 +				
    1.34 +				if(!OGCConstants.supportedUnitsOfMeasure.contains(units))
    1.35 +				{
    1.36 +					throw new UnsupportedRdbmsOperatorException("No such unit of measure exists");
    1.37 +				}	
    1.38 +				
    1.39 +				if(units.equals(OGCConstants.OGCmetre))
    1.40 +				{							
    1.41 +					//if(!unparsedUnits.equals(OGCConstants.OGCmetre));
    1.42 +					filter.appendFunction(GEOGRAPHY);
    1.43  					filter.openBracket();
    1.44 -					filter.appendFunction("ST_TRANSFORM");
    1.45 +					filter.appendFunction(ST_TRANSFORM);
    1.46  					filter.openBracket();
    1.47  				}
    1.48 -				else if(units.equals("degree"))
    1.49 +				else if(units.equals(OGCConstants.OGCdegree))
    1.50  				{
    1.51 -					filter.appendFunction("ST_TRANSFORM");
    1.52 +					filter.appendFunction(ST_TRANSFORM);
    1.53  					filter.openBracket();
    1.54  				}	
    1.55  			}	
    1.56 @@ -1665,9 +1673,9 @@
    1.57  			{
    1.58  				appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
    1.59  			}
    1.60 -
    1.61 -			if(units.equals("metre") || units.equals("meter"))
    1.62 -			{					
    1.63 +						
    1.64 +			if(units.equals(OGCConstants.OGCmetre))
    1.65 +			{				
    1.66  				filter.appendComma();
    1.67  				filter.append(String.valueOf(GeoConstants.defaultSRID));
    1.68  				filter.closeBracket(); //close st_transform
    1.69 @@ -1675,12 +1683,12 @@
    1.70  				
    1.71  				filter.appendComma();
    1.72  
    1.73 -				filter.appendFunction("GEOGRAPHY");
    1.74 +				filter.appendFunction(GEOGRAPHY);
    1.75  				filter.openBracket();
    1.76 -				filter.appendFunction("ST_TRANSFORM");
    1.77 +				filter.appendFunction(ST_TRANSFORM);
    1.78  				filter.openBracket();				
    1.79  			}
    1.80 -			else if(units.equals("degree"))
    1.81 +			else if(units.equals(OGCConstants.OGCdegree))
    1.82  			{
    1.83  				filter.appendComma();
    1.84  				filter.append(String.valueOf(GeoConstants.defaultSRID));
    1.85 @@ -1688,7 +1696,7 @@
    1.86  				
    1.87  				filter.appendComma();
    1.88  				
    1.89 -				filter.appendFunction("ST_TRANSFORM");
    1.90 +				filter.appendFunction(ST_TRANSFORM);
    1.91  				filter.openBracket();
    1.92  			}	
    1.93  			else
    1.94 @@ -1740,14 +1748,14 @@
    1.95  				appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter);
    1.96  			}
    1.97  
    1.98 -			if(units.equals("metre") || units.equals("meter"))
    1.99 +			if(units.equals(OGCConstants.OGCmetre))
   1.100  			{
   1.101  				filter.appendComma();
   1.102  				filter.append(String.valueOf(GeoConstants.defaultSRID));
   1.103  				filter.closeBracket();
   1.104  				filter.closeBracket();
   1.105  			}
   1.106 -			else if(units.equals("degree"))
   1.107 +			else if(units.equals(OGCConstants.OGCdegree))
   1.108  			{
   1.109  				filter.appendComma();
   1.110  				filter.append(String.valueOf(GeoConstants.defaultSRID));