Strabon

changeset 981:45539016f159

added check of the unit of measure that given in strdf:distance.
if the unit of measure is wrong an error occurs.
author Stella Giannakopoulou <sgian@di.uoa.gr>
date Fri Apr 05 15:24:38 2013 +0300 (2013-04-05)
parents 2171270604e1
children f5ca44796e2f
files postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java
line diff
     1.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Apr 05 13:09:04 2013 +0300
     1.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Fri Apr 05 15:24:38 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 @@ -1628,10 +1629,14 @@
    1.12  			if (expr.getThirdArg() instanceof GeneralDBStringValue)
    1.13  			{			
    1.14  				String unparsedUnits = ((GeneralDBStringValue)expr.getThirdArg()).getValue();
    1.15 -
    1.16 +				if(!OGCConstants.supportedUnitsOfMeasure.contains(unparsedUnits))
    1.17 +				{
    1.18 +					throw new UnsupportedRdbmsOperatorException("No such unit of measure exists");
    1.19 +				}	
    1.20  				units = unparsedUnits.substring(unparsedUnits.lastIndexOf('/')+1);
    1.21  				if(units.equals("metre") || units.equals("meter"))
    1.22 -				{					
    1.23 +				{							
    1.24 +					//if(!unparsedUnits.equals(OGCConstants.OGCmetre));
    1.25  					filter.appendFunction("GEOGRAPHY");
    1.26  					filter.openBracket();
    1.27  					filter.appendFunction("ST_TRANSFORM");
    1.28 @@ -1665,9 +1670,9 @@
    1.29  			{
    1.30  				appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
    1.31  			}
    1.32 -
    1.33 +						
    1.34  			if(units.equals("metre") || units.equals("meter"))
    1.35 -			{					
    1.36 +			{				
    1.37  				filter.appendComma();
    1.38  				filter.append(String.valueOf(GeoConstants.defaultSRID));
    1.39  				filter.closeBracket(); //close st_transform