Strabon

changeset 1038:6260271ba203

used OGCConstants when appending distance in MonetDBQueryBuilder
author Stella Giannakopoulou <sgian@di.uoa.gr>
date Tue Apr 16 14:12:15 2013 +0300 (2013-04-16)
parents 95c7633544ad
children 516d8a0ae1db
files monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java
line diff
     1.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Mon Apr 15 18:39:56 2013 +0300
     1.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Tue Apr 16 14:12:15 2013 +0300
     1.3 @@ -103,6 +103,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 @@ -111,7 +112,10 @@
    1.12   * 
    1.13   */
    1.14  public class MonetDBQueryBuilder extends GeneralDBQueryBuilder {
    1.15 -
    1.16 +	
    1.17 +	public static final String ST_TRANSFORM = "ST_Transform";	
    1.18 +	public static final String GEOGRAPHY = "Geography";
    1.19 +	
    1.20  	/**
    1.21  	 * If (spatial) label column met is null, I must not try to retrieve its srid. 
    1.22  	 * Opting to ask for 'null' instead
    1.23 @@ -1451,6 +1455,7 @@
    1.24  			boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.MonetDBSqlNull");
    1.25  			boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.MonetDBSqlNull");
    1.26  			boolean check3 = expr.getThirdArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.MonetDBSqlNull");
    1.27 +			
    1.28  			if(check1)
    1.29  			{
    1.30  				this.append((GeneralDBSqlNull)expr.getLeftArg(), filter);
    1.31 @@ -1472,19 +1477,22 @@
    1.32  				
    1.33  				if (expr.getThirdArg() instanceof GeneralDBStringValue)
    1.34  				{			
    1.35 -					String unparsedUnits = ((GeneralDBStringValue)expr.getThirdArg()).getValue();
    1.36 +					units = ((GeneralDBStringValue)expr.getThirdArg()).getValue();
    1.37 +					if(!OGCConstants.supportedUnitsOfMeasure.contains(units))
    1.38 +					{
    1.39 +						throw new UnsupportedRdbmsOperatorException("No such unit of measure exists");
    1.40 +					}	
    1.41  
    1.42 -					units = unparsedUnits.substring(unparsedUnits.lastIndexOf('/')+1);
    1.43 -					if(units.equals("metre") || units.equals("meter"))
    1.44 -					{					
    1.45 -						filter.appendFunction("GEOGRAPHY");
    1.46 +					if(units.equals(OGCConstants.OGCmetre))
    1.47 +					{
    1.48 +						filter.appendFunction(GEOGRAPHY);
    1.49  						filter.openBracket();
    1.50 -						filter.appendFunction("ST_TRANSFORM");
    1.51 +						filter.appendFunction(ST_TRANSFORM);
    1.52  						filter.openBracket();
    1.53 -					}	
    1.54 -					else if(units.equals("degree"))
    1.55 +					}
    1.56 +					else if(units.equals(OGCConstants.OGCdegree))
    1.57  					{
    1.58 -						filter.appendFunction("ST_TRANSFORM");
    1.59 +						filter.appendFunction(ST_TRANSFORM);
    1.60  						filter.openBracket();
    1.61  					}	
    1.62  				}	
    1.63 @@ -1511,8 +1519,8 @@
    1.64  					appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
    1.65  				}
    1.66  				
    1.67 -				if(units.equals("metre") || units.equals("meter"))
    1.68 -				{					
    1.69 +				if(units.equals(OGCConstants.OGCmetre))
    1.70 +				{				
    1.71  					filter.appendComma();
    1.72  					filter.append(String.valueOf(GeoConstants.defaultSRID));
    1.73  					filter.closeBracket(); //close st_transform
    1.74 @@ -1520,12 +1528,12 @@
    1.75  					
    1.76  					filter.appendComma();
    1.77  
    1.78 -					filter.appendFunction("GEOGRAPHY");
    1.79 +					filter.appendFunction(GEOGRAPHY);
    1.80  					filter.openBracket();
    1.81 -					filter.appendFunction("ST_TRANSFORM");
    1.82 -					filter.openBracket();				
    1.83 +					filter.appendFunction(ST_TRANSFORM);
    1.84 +					filter.openBracket();
    1.85  				}
    1.86 -				else if(units.equals("degree"))
    1.87 +				else if(units.equals(OGCConstants.OGCdegree))
    1.88  				{
    1.89  					filter.appendComma();
    1.90  					filter.append(String.valueOf(GeoConstants.defaultSRID));
    1.91 @@ -1533,13 +1541,13 @@
    1.92  					
    1.93  					filter.appendComma();
    1.94  					
    1.95 -					filter.appendFunction("ST_TRANSFORM");
    1.96 +					filter.appendFunction(ST_TRANSFORM);
    1.97  					filter.openBracket();
    1.98  				}	
    1.99  				else
   1.100  				{
   1.101  					filter.appendComma();
   1.102 -				}																
   1.103 +				}															
   1.104  				
   1.105  				if(expr.getRightArg() instanceof GeneralDBStringValue)
   1.106  				{
   1.107 @@ -1594,14 +1602,14 @@
   1.108  					appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter);
   1.109  				}
   1.110  
   1.111 -				if(units.equals("metre") || units.equals("meter"))
   1.112 +				if(units.equals(OGCConstants.OGCmetre))
   1.113  				{
   1.114  					filter.appendComma();
   1.115  					filter.append(String.valueOf(GeoConstants.defaultSRID));
   1.116  					filter.closeBracket();
   1.117  					filter.closeBracket();
   1.118  				}
   1.119 -				else if(units.equals("degree"))
   1.120 +				else if(units.equals(OGCConstants.OGCdegree))
   1.121  				{
   1.122  					filter.appendComma();
   1.123  					filter.append(String.valueOf(GeoConstants.defaultSRID));