Strabon

changeset 180:e1d79c8814ad

First attempt to add srid support in MonetDB query builder
author George Garbis <ggarbis@di.uoa.gr>
date Tue May 22 12:18:12 2012 +0300 (2012-05-22)
parents 8521941bf589
children 439c5e28e3bc
files monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java
line diff
     1.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Mon May 21 18:12:58 2012 +0300
     1.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Tue May 22 12:18:12 2012 +0300
     1.3 @@ -58,6 +58,7 @@
     1.4  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialProperty;
     1.5  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlTouch;
     1.6  import org.openrdf.sail.generaldb.algebra.GeneralDBStringValue;
     1.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBURIColumn;
     1.8  import org.openrdf.sail.generaldb.algebra.GeneralDBUnionItem;
     1.9  import org.openrdf.sail.generaldb.algebra.base.BinaryGeneralDBOperator;
    1.10  import org.openrdf.sail.generaldb.algebra.base.GeneralDBFromItem;
    1.11 @@ -104,6 +105,13 @@
    1.12   */
    1.13  public class MonetDBQueryBuilder extends GeneralDBQueryBuilder {
    1.14  
    1.15 +	/**
    1.16 +	 * If (spatial) label column met is null, I must not try to retrieve its srid. 
    1.17 +	 * Opting to ask for 'null' instead
    1.18 +	 */
    1.19 +	
    1.20 +	boolean nullLabel = false;
    1.21 +	
    1.22  	public enum SpatialOperandsMonetDB { left, right, above, below; }
    1.23  	public enum SpatialFunctionsMonetDB 
    1.24  	{ 	//Spatial Relationships
    1.25 @@ -352,6 +360,8 @@
    1.26  		{
    1.27  			dispatchUnarySqlOperator((UnaryGeneralDBOperator) expr, (MonetDBSqlExprBuilder)query.select);
    1.28  		}
    1.29 +		
    1.30 +		//SRID support must be explicitly added!
    1.31  		return this;
    1.32  	}
    1.33  
    1.34 @@ -654,11 +664,13 @@
    1.35  		appendMonetDBSpatialFunctionBinary(expr, filter, SpatialFunctionsMonetDB.ST_Buffer);
    1.36  	}
    1.37  	
    1.38 +	//XXX Different Behavior
    1.39  	@Override
    1.40  	protected void append(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
    1.41  	throws UnsupportedRdbmsOperatorException
    1.42  	{
    1.43 -		appendMonetDBSpatialFunctionBinary(expr, filter, SpatialFunctionsMonetDB.ST_Transform);
    1.44 +//		appendMonetDBSpatialFunctionBinary(expr, filter, SpatialFunctionsMonetDB.ST_Transform);
    1.45 +		appendTransformFunc(expr, filter);
    1.46  	}
    1.47  
    1.48  	@Override
    1.49 @@ -744,7 +756,122 @@
    1.50  	protected void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter)
    1.51  	throws UnsupportedRdbmsOperatorException
    1.52  	{
    1.53 -		appendMonetDBSpatialFunctionUnary(expr, filter, SpatialFunctionsMonetDB.ST_SRID);
    1.54 +		//		appendMonetDBSpatialFunctionUnary(expr, filter, SpatialFunctionsMonetDB.ST_SRID);
    1.55 +
    1.56 +		boolean sridNeeded = true;
    1.57 +		filter.openBracket();
    1.58 +
    1.59 +		boolean check1 = expr.getArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
    1.60 +		boolean check2 = false;
    1.61 +		if(expr.getArg() instanceof GeneralDBLabelColumn)
    1.62 +		{
    1.63 +			if(((GeneralDBLabelColumn) expr.getArg()).getRdbmsVar().isResource())
    1.64 +			{
    1.65 +				check2 = true;
    1.66 +			}
    1.67 +		}
    1.68 +		if(check1)
    1.69 +		{
    1.70 +			this.append((GeneralDBSqlNull)expr.getArg(), filter);
    1.71 +
    1.72 +		}
    1.73 +		else if (check2)
    1.74 +		{
    1.75 +			appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter);
    1.76 +		}
    1.77 +		else
    1.78 +		{
    1.79 +			//XXX Incorporating SRID
    1.80 +			GeneralDBSqlExpr tmp = expr;
    1.81 +			if(tmp.getParentNode() == null)
    1.82 +			{
    1.83 +				String sridExpr;
    1.84 +				while(true)
    1.85 +				{
    1.86 +					GeneralDBSqlExpr child = null;
    1.87 +
    1.88 +					if(tmp instanceof BinaryGeneralDBOperator)
    1.89 +					{
    1.90 +						child = ((BinaryGeneralDBOperator) tmp).getLeftArg();
    1.91 +					}
    1.92 +					else if(tmp instanceof UnaryGeneralDBOperator)
    1.93 +					{
    1.94 +						child = ((UnaryGeneralDBOperator) tmp).getArg();
    1.95 +					}
    1.96 +					else if(tmp instanceof GeneralDBStringValue)
    1.97 +					{
    1.98 +						//Constant!!
    1.99 +						sridNeeded  = false;
   1.100 +						break;
   1.101 +					}
   1.102 +
   1.103 +					tmp = child;
   1.104 +					if(tmp instanceof GeneralDBLabelColumn)
   1.105 +					{
   1.106 +						//Reached the innermost left var -> need to capture its SRID
   1.107 +						String alias;
   1.108 +						if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) {
   1.109 +							//Predicates used in triple patterns non-existent in db
   1.110 +							alias="NULL";
   1.111 +						}
   1.112 +						else
   1.113 +						{
   1.114 +							//Reached the innermost left var -> need to capture its SRID
   1.115 +							alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
   1.116 +							alias=alias+".srid";
   1.117 +						}
   1.118 +						sridExpr = alias;
   1.119 +						filter.append(sridExpr);
   1.120 +						filter.closeBracket();
   1.121 +						return;
   1.122 +						//break;
   1.123 +					}
   1.124 +					else if(tmp instanceof GeneralDBStringValue)
   1.125 +					{
   1.126 +						//Constant!!
   1.127 +						sridNeeded  = false;
   1.128 +						break;
   1.129 +					}
   1.130 +
   1.131 +				}
   1.132 +			}
   1.133 +
   1.134 +			if(sridNeeded)
   1.135 +			{
   1.136 +				filter.appendFunction("ST_SRID");
   1.137 +				filter.openBracket();
   1.138 +				if(expr.getArg() instanceof GeneralDBStringValue)
   1.139 +				{
   1.140 +					appendWKT(expr.getArg(),filter);
   1.141 +				}
   1.142 +				else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructBinary)
   1.143 +				{
   1.144 +					appendConstructFunction(expr.getArg(), filter);
   1.145 +				}
   1.146 +				else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructUnary)
   1.147 +				{
   1.148 +					appendConstructFunction(expr.getArg(), filter);
   1.149 +				}
   1.150 +				else if(expr.getArg() instanceof GeneralDBSqlCase)
   1.151 +				{
   1.152 +					GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getArg()).getEntries().get(0).getResult();
   1.153 +					appendMBB(onlyLabel,filter); 
   1.154 +				}
   1.155 +				else
   1.156 +				{
   1.157 +					appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter);
   1.158 +				}
   1.159 +
   1.160 +				filter.closeBracket();
   1.161 +			}
   1.162 +			else
   1.163 +			{
   1.164 +				//4326 by default - Software House additions
   1.165 +				filter.append("4326");
   1.166 +			}
   1.167 +		}
   1.168 +
   1.169 +		filter.closeBracket();
   1.170  	}
   1.171  
   1.172  	@Override
   1.173 @@ -784,11 +911,159 @@
   1.174  		return raw;
   1.175  	}
   1.176  
   1.177 +	//Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   1.178 +	protected void appendTransformFunc(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   1.179 +	throws UnsupportedRdbmsOperatorException
   1.180 +	{
   1.181 +		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   1.182 +		boolean sridNeeded = true;
   1.183 +		//XXX Incorporating SRID
   1.184 +		String sridExpr = null;
   1.185 +
   1.186 +		filter.openBracket();
   1.187 +		filter.appendFunction("Transform");
   1.188 +		filter.openBracket();
   1.189 +
   1.190 +		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
   1.191 +		boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
   1.192 +
   1.193 +		if(check1)
   1.194 +		{
   1.195 +			this.append((GeneralDBSqlNull)expr.getLeftArg(), filter);
   1.196 +
   1.197 +		}
   1.198 +		else if(check2)
   1.199 +		{
   1.200 +			this.append((GeneralDBSqlNull)expr.getRightArg(), filter);
   1.201 +		}
   1.202 +		else
   1.203 +		{
   1.204 +			GeneralDBSqlExpr tmp = expr;
   1.205 +			if(tmp instanceof GeneralDBSqlSpatialConstructBinary && tmp.getParentNode() == null)
   1.206 +			{
   1.207 +				while(true)
   1.208 +				{
   1.209 +					GeneralDBSqlExpr child;
   1.210 +
   1.211 +					if(tmp instanceof BinaryGeneralDBOperator)
   1.212 +					{
   1.213 +						child = ((BinaryGeneralDBOperator) tmp).getLeftArg();
   1.214 +					}
   1.215 +					else //(tmp instanceof UnaryGeneralDBOperator)
   1.216 +					{
   1.217 +						child = ((UnaryGeneralDBOperator) tmp).getArg();
   1.218 +					}
   1.219 +
   1.220 +					tmp = child;
   1.221 +					if(tmp instanceof GeneralDBLabelColumn)
   1.222 +					{
   1.223 +						String alias;
   1.224 +						if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) {
   1.225 +							//Predicates used in triple patterns non-existent in db
   1.226 +							alias="NULL";
   1.227 +						}
   1.228 +						else
   1.229 +						{
   1.230 +							//Reached the innermost left var -> need to capture its SRID
   1.231 +							alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
   1.232 +							alias=alias+".srid";
   1.233 +						}
   1.234 +						sridExpr = alias;
   1.235 +						break;
   1.236 +					}
   1.237 +					else if (tmp instanceof GeneralDBStringValue) //Constant!!
   1.238 +					{
   1.239 +						sridNeeded  = false;
   1.240 +						break;
   1.241 +					}
   1.242 +
   1.243 +				}
   1.244 +				if(sridNeeded)
   1.245 +				{
   1.246 +					filter.appendFunction("Transform");
   1.247 +					filter.openBracket();
   1.248 +				}
   1.249 +			}
   1.250 +
   1.251 +			if(expr.getLeftArg() instanceof GeneralDBStringValue)
   1.252 +			{
   1.253 +				appendWKT(expr.getLeftArg(),filter);
   1.254 +			}
   1.255 +			else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary)
   1.256 +			{
   1.257 +				appendConstructFunction(expr.getLeftArg(), filter);
   1.258 +			}
   1.259 +			else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary)
   1.260 +			{
   1.261 +				appendConstructFunction(expr.getLeftArg(), filter);
   1.262 +			}
   1.263 +			else if(expr.getLeftArg() instanceof GeneralDBSqlCase)
   1.264 +			{
   1.265 +				GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getLeftArg()).getEntries().get(0).getResult();
   1.266 +				appendMBB(onlyLabel,filter); 
   1.267 +			}
   1.268 +			else
   1.269 +			{
   1.270 +				appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
   1.271 +			}
   1.272 +
   1.273 +			//SRID Support
   1.274 +			if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
   1.275 +			{
   1.276 +				filter.appendComma();
   1.277 +				//filter.append(((GeneralDBSqlSpatialConstructBinary)expr).getSrid());
   1.278 +				filter.append(sridExpr);
   1.279 +				filter.closeBracket();
   1.280 +			}
   1.281 +
   1.282 +			filter.appendComma();
   1.283 +
   1.284 +			if(expr.getRightArg() instanceof GeneralDBSqlCase) //case met in transform!
   1.285 +			{
   1.286 +				GeneralDBURIColumn plainURI = (GeneralDBURIColumn)((GeneralDBSqlCase)expr.getRightArg()).getEntries().get(0).getResult();
   1.287 +
   1.288 +				//XXX This case would be met if we recovered the SRID URI from the db!!!
   1.289 +				//Need to set sridExpr to the value of this new URI, otherwise the appended uri
   1.290 +				//to the spatial object will be the wrong one!!!! (Seee following case)
   1.291 +				filter.keepSRID_part1();
   1.292 +				append(plainURI, filter);
   1.293 +				filter.keepSRID_part2();
   1.294 +				append(plainURI, filter);
   1.295 +				filter.keepSRID_part3();
   1.296 +			}
   1.297 +			else if(expr.getRightArg() instanceof GeneralDBStringValue)
   1.298 +			{
   1.299 +				String unparsedSRID = ((GeneralDBStringValue)expr.getRightArg()).getValue();
   1.300 +				//				int srid = Integer.parseInt(unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1));
   1.301 +				sridExpr = unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1);
   1.302 +				filter.append(sridExpr);
   1.303 +				filter.closeBracket();
   1.304 +			}
   1.305 +
   1.306 +
   1.307 +		}
   1.308 +		filter.closeBracket();
   1.309 +		//In this case, SRID is the one that has been provided by the user!! 
   1.310 +		//I am including this extra binding to be used in subsequent (Aggregate) steps
   1.311 +		if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
   1.312 +		{
   1.313 +			filter.appendComma();
   1.314 +			filter.append(sridExpr);
   1.315 +		}
   1.316 +
   1.317 +	}
   1.318 +	
   1.319 +	
   1.320  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   1.321 -	
   1.322 +	//EXCEPT ST_Transform!!!
   1.323  	protected void appendMonetDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsMonetDB func)
   1.324  	throws UnsupportedRdbmsOperatorException
   1.325  	{
   1.326 +		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   1.327 +		boolean sridNeeded = true;
   1.328 +		//XXX Incorporating SRID
   1.329 +		String sridExpr = null;
   1.330 +		
   1.331  		filter.openBracket();
   1.332  
   1.333  		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.MonetDBSqlNull");
   1.334 @@ -799,6 +1074,57 @@
   1.335  		}
   1.336  		else
   1.337  		{
   1.338 +			
   1.339 +			GeneralDBSqlExpr tmp = expr;
   1.340 +			if(tmp instanceof GeneralDBSqlSpatialConstructBinary && tmp.getParentNode() == null)
   1.341 +			{
   1.342 +				while(true)
   1.343 +				{
   1.344 +					GeneralDBSqlExpr child;
   1.345 +
   1.346 +					if(tmp instanceof BinaryGeneralDBOperator)
   1.347 +					{
   1.348 +						child = ((BinaryGeneralDBOperator) tmp).getLeftArg();
   1.349 +					}
   1.350 +					else //(tmp instanceof UnaryGeneralDBOperator)
   1.351 +					{
   1.352 +						child = ((UnaryGeneralDBOperator) tmp).getArg();
   1.353 +					}
   1.354 +
   1.355 +					tmp = child;
   1.356 +					if(tmp instanceof GeneralDBLabelColumn)
   1.357 +					{
   1.358 +						//Reached the innermost left var -> need to capture its SRID
   1.359 +						String alias;
   1.360 +						if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) {
   1.361 +							//Predicates used in triple patterns non-existent in db
   1.362 +							alias="NULL";
   1.363 +						}
   1.364 +						else
   1.365 +						{
   1.366 +							//Reached the innermost left var -> need to capture its SRID
   1.367 +							alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
   1.368 +							alias=alias+".srid";
   1.369 +						}
   1.370 +						sridExpr = alias;
   1.371 +						break;
   1.372 +					}
   1.373 +					else if (tmp instanceof GeneralDBStringValue) //Constant!!
   1.374 +					{
   1.375 +						sridNeeded  = false;
   1.376 +						break;
   1.377 +					}
   1.378 +
   1.379 +				}
   1.380 +				if(sridNeeded)
   1.381 +				{
   1.382 +					filter.appendFunction("Transform");
   1.383 +					filter.openBracket();
   1.384 +				}
   1.385 +			}
   1.386 +			/////
   1.387 +			
   1.388 +			
   1.389  			switch(func)
   1.390  			{
   1.391  			//XXX Careful: ST_Transform support MISSING!!!
   1.392 @@ -818,7 +1144,6 @@
   1.393  			case contains: filter.appendFunction("Contains"); break;
   1.394  			case inside: filter.appendFunction("Within"); break;
   1.395  			}
   1.396 -			//filter.appendFunction("ST_Union");
   1.397  			filter.openBracket();
   1.398  			if(expr.getLeftArg() instanceof GeneralDBStringValue)
   1.399  			{
   1.400 @@ -874,6 +1199,14 @@
   1.401  				{
   1.402  					append(((GeneralDBNumericColumn)expr.getRightArg()), filter);
   1.403  				}
   1.404 +				else if(expr.getRightArg() instanceof GeneralDBURIColumn) //case met in transform!
   1.405 +				{
   1.406 +					filter.keepSRID_part1();
   1.407 +					append(((GeneralDBURIColumn)expr.getRightArg()), filter);
   1.408 +					filter.keepSRID_part2();
   1.409 +					append(((GeneralDBURIColumn)expr.getRightArg()), filter);
   1.410 +					filter.keepSRID_part3();
   1.411 +				}
   1.412  				//case met in buffer when in select -> buffer(?spatial,?thematic)
   1.413  				else if(expr.getRightArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getRightArg()).isSpatial())
   1.414  				{
   1.415 @@ -896,15 +1229,34 @@
   1.416  
   1.417  			}
   1.418  			filter.closeBracket();
   1.419 +			//SRID Support
   1.420 +			if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
   1.421 +			{
   1.422 +				filter.appendComma();
   1.423 +				//filter.append(((GeneralDBSqlSpatialConstructBinary)expr).getSrid());
   1.424 +				filter.append(sridExpr);
   1.425 +				filter.closeBracket();
   1.426 +			}
   1.427 +			///
   1.428  		}
   1.429  
   1.430  		filter.closeBracket();
   1.431 +		//Used to explicitly include SRID
   1.432 +		if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
   1.433 +		{
   1.434 +			filter.appendComma();
   1.435 +			filter.append(sridExpr);
   1.436 +		}
   1.437  	}
   1.438  
   1.439  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1) 
   1.440  	protected void appendMonetDBSpatialFunctionUnary(UnaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsMonetDB func)
   1.441  	throws UnsupportedRdbmsOperatorException
   1.442  	{
   1.443 +		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   1.444 +		boolean sridNeeded = true;
   1.445 +		String sridExpr = null;
   1.446 +		
   1.447  		filter.openBracket();
   1.448  
   1.449  		boolean check1 = expr.getArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.MonetDBSqlNull");
   1.450 @@ -915,6 +1267,63 @@
   1.451  		}
   1.452  		else
   1.453  		{
   1.454 +
   1.455 +			GeneralDBSqlExpr tmp = expr;
   1.456 +
   1.457 +
   1.458 +			if(tmp instanceof GeneralDBSqlSpatialConstructUnary && tmp.getParentNode() == null)
   1.459 +			{
   1.460 +				while(true)
   1.461 +				{
   1.462 +					GeneralDBSqlExpr child = null;
   1.463 +
   1.464 +					if(tmp instanceof BinaryGeneralDBOperator)
   1.465 +					{
   1.466 +						child = ((BinaryGeneralDBOperator) tmp).getLeftArg();
   1.467 +					}
   1.468 +					else if(tmp instanceof UnaryGeneralDBOperator)
   1.469 +					{
   1.470 +						child = ((UnaryGeneralDBOperator) tmp).getArg();
   1.471 +					}
   1.472 +					else if(tmp instanceof GeneralDBStringValue)
   1.473 +					{
   1.474 +						sridNeeded  = false;
   1.475 +						break;
   1.476 +					}
   1.477 +
   1.478 +					tmp = child;
   1.479 +					if(tmp instanceof GeneralDBLabelColumn)
   1.480 +					{
   1.481 +						//Reached the innermost left var -> need to capture its SRID
   1.482 +						String alias;
   1.483 +						if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) {
   1.484 +							//Predicates used in triple patterns non-existent in db
   1.485 +							alias="NULL";
   1.486 +						}
   1.487 +						else
   1.488 +						{
   1.489 +							//Reached the innermost left var -> need to capture its SRID
   1.490 +							alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
   1.491 +							alias=alias+".srid";
   1.492 +						}
   1.493 +						sridExpr = alias;
   1.494 +						break;
   1.495 +					}
   1.496 +					else if (tmp instanceof GeneralDBStringValue) //Constant!!
   1.497 +					{
   1.498 +						sridNeeded  = false;
   1.499 +						break;
   1.500 +					}
   1.501 +
   1.502 +				}
   1.503 +				if(sridNeeded)
   1.504 +				{
   1.505 +					filter.appendFunction("Transform");
   1.506 +					filter.openBracket();
   1.507 +				}
   1.508 +			}
   1.509 +			/////
   1.510 +			
   1.511  			switch(func)
   1.512  			{
   1.513  			case ST_Envelope: filter.appendFunction("Envelope"); break;
   1.514 @@ -928,7 +1337,6 @@
   1.515  			case ST_IsEmpty: filter.appendFunction("IsEmpty"); break;
   1.516  			case ST_IsSimple: filter.appendFunction("IsSimple"); break;
   1.517  			}
   1.518 -			//filter.appendFunction("ST_Union");
   1.519  			filter.openBracket();
   1.520  			if(expr.getArg() instanceof GeneralDBStringValue)
   1.521  			{
   1.522 @@ -953,9 +1361,27 @@
   1.523  			}
   1.524  
   1.525  			filter.closeBracket();
   1.526 +//			//SRID Support
   1.527 +			if(sridNeeded)
   1.528 +			{
   1.529 +				if(expr instanceof GeneralDBSqlSpatialConstructUnary && expr.getParentNode() == null)
   1.530 +				{
   1.531 +					filter.appendComma();
   1.532 +					//				filter.append(((GeneralDBSqlSpatialConstructUnary)expr).getSrid());
   1.533 +					filter.append(sridExpr);
   1.534 +					filter.closeBracket();
   1.535 +				}
   1.536 +			}
   1.537 +			///
   1.538  		}
   1.539  
   1.540  		filter.closeBracket();
   1.541 +		//Used to explicitly include SRID
   1.542 +		if(expr instanceof GeneralDBSqlSpatialConstructUnary && expr.getParentNode() == null)
   1.543 +		{
   1.544 +			filter.appendComma();
   1.545 +			filter.append(sridExpr);
   1.546 +		}
   1.547  	}
   1.548  	
   1.549  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
     2.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Mon May 21 18:12:58 2012 +0300
     2.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Tue May 22 12:18:12 2012 +0300
     2.3 @@ -191,16 +191,16 @@
     2.4  
     2.5  	@Override
     2.6  	protected void append(GeneralDBSqlIsNull expr, GeneralDBSqlExprBuilder filter)
     2.7 -			throws UnsupportedRdbmsOperatorException
     2.8 -			{
     2.9 +	throws UnsupportedRdbmsOperatorException
    2.10 +	{
    2.11  		dispatch(expr.getArg(), filter);
    2.12  		filter.isNull();
    2.13 -			}
    2.14 +	}
    2.15  
    2.16  	@Override
    2.17  	protected void append(GeneralDBSqlNot expr, GeneralDBSqlExprBuilder filter)
    2.18 -			throws UnsupportedRdbmsOperatorException
    2.19 -			{
    2.20 +	throws UnsupportedRdbmsOperatorException
    2.21 +	{
    2.22  		if (expr.getArg() instanceof GeneralDBSqlIsNull) {
    2.23  			GeneralDBSqlIsNull arg = (GeneralDBSqlIsNull)expr.getArg();
    2.24  			dispatch(arg.getArg(), filter);
    2.25 @@ -211,7 +211,7 @@
    2.26  			dispatch(expr.getArg(), (GeneralDBSqlExprBuilder) open);
    2.27  			open.close();
    2.28  		}
    2.29 -			}
    2.30 +	}
    2.31  
    2.32  	@Override
    2.33  	protected void append(GeneralDBLabelColumn var, GeneralDBSqlExprBuilder filter) {
    2.34 @@ -253,16 +253,16 @@
    2.35  
    2.36  	@Override
    2.37  	protected void append(GeneralDBSqlAnd expr, GeneralDBSqlExprBuilder filter)
    2.38 -			throws UnsupportedRdbmsOperatorException
    2.39 -			{
    2.40 +	throws UnsupportedRdbmsOperatorException
    2.41 +	{
    2.42  		dispatch(expr.getLeftArg(), filter);
    2.43  		filter.and();
    2.44  		dispatch(expr.getRightArg(), filter);
    2.45 -			}
    2.46 +	}
    2.47  
    2.48  	protected GeneralDBSqlJoinBuilder subJoinAndFilter(GeneralDBSqlJoinBuilder query, GeneralDBFromItem from)
    2.49 -			throws RdbmsException, UnsupportedRdbmsOperatorException
    2.50 -			{
    2.51 +	throws RdbmsException, UnsupportedRdbmsOperatorException
    2.52 +	{
    2.53  		if (from instanceof GeneralDBUnionItem) {
    2.54  			GeneralDBUnionItem union = (GeneralDBUnionItem)from;
    2.55  			List<String> names = union.getSelectVarNames();
    2.56 @@ -294,7 +294,7 @@
    2.57  			dispatch(expr, query.on().and());
    2.58  		}
    2.59  		return query;
    2.60 -			}
    2.61 +	}
    2.62  
    2.63  	//FIXME my addition from here on
    2.64  
    2.65 @@ -330,375 +330,375 @@
    2.66  	//Spatial Relationship Functions
    2.67  	@Override
    2.68  	protected void append(GeneralDBSqlAnyInteract expr, GeneralDBSqlExprBuilder filter)
    2.69 -			throws UnsupportedRdbmsOperatorException
    2.70 -			{
    2.71 +	throws UnsupportedRdbmsOperatorException
    2.72 +	{
    2.73  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Intersects);
    2.74 -			}
    2.75 +	}
    2.76  
    2.77  	@Override
    2.78  	protected void append(GeneralDBSqlContains expr, GeneralDBSqlExprBuilder filter)
    2.79 -			throws UnsupportedRdbmsOperatorException {
    2.80 +	throws UnsupportedRdbmsOperatorException {
    2.81  
    2.82  		appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.contains);
    2.83  	}
    2.84  
    2.85  	@Override
    2.86  	protected void append(GeneralDBSqlEqualsSpatial expr, GeneralDBSqlExprBuilder filter)
    2.87 -			throws UnsupportedRdbmsOperatorException {
    2.88 +	throws UnsupportedRdbmsOperatorException {
    2.89  
    2.90  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Equals);
    2.91  	}
    2.92  
    2.93  	@Override
    2.94  	protected void append(GeneralDBSqlInside expr, GeneralDBSqlExprBuilder filter)
    2.95 -			throws UnsupportedRdbmsOperatorException {
    2.96 +	throws UnsupportedRdbmsOperatorException {
    2.97  
    2.98  		appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.inside);
    2.99  	}
   2.100  
   2.101  	@Override
   2.102  	protected void append(GeneralDBSqlCovers expr, GeneralDBSqlExprBuilder filter)
   2.103 -			throws UnsupportedRdbmsOperatorException {
   2.104 +	throws UnsupportedRdbmsOperatorException {
   2.105  
   2.106  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Covers);
   2.107  	}
   2.108  
   2.109  	@Override
   2.110  	protected void append(GeneralDBSqlCoveredBy expr, GeneralDBSqlExprBuilder filter)
   2.111 -			throws UnsupportedRdbmsOperatorException {
   2.112 +	throws UnsupportedRdbmsOperatorException {
   2.113  
   2.114  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_CoveredBy);
   2.115  	}
   2.116  
   2.117  	@Override
   2.118  	protected void append(GeneralDBSqlTouch expr, GeneralDBSqlExprBuilder filter)
   2.119 -			throws UnsupportedRdbmsOperatorException {
   2.120 +	throws UnsupportedRdbmsOperatorException {
   2.121  
   2.122  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Touches);
   2.123  	}
   2.124  
   2.125  	@Override
   2.126  	protected void append(GeneralDBSqlOverlap expr, GeneralDBSqlExprBuilder filter)
   2.127 -			throws UnsupportedRdbmsOperatorException {
   2.128 +	throws UnsupportedRdbmsOperatorException {
   2.129  
   2.130  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Overlaps);
   2.131  	}
   2.132  
   2.133  	@Override
   2.134  	protected void append(GeneralDBSqlDisjoint expr, GeneralDBSqlExprBuilder filter)
   2.135 -			throws UnsupportedRdbmsOperatorException {
   2.136 +	throws UnsupportedRdbmsOperatorException {
   2.137  
   2.138  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Disjoint);
   2.139  	}
   2.140  
   2.141  	@Override
   2.142  	protected void append(GeneralDBSqlRelate expr, GeneralDBSqlExprBuilder filter)
   2.143 -			throws UnsupportedRdbmsOperatorException
   2.144 -			{
   2.145 +	throws UnsupportedRdbmsOperatorException
   2.146 +	{
   2.147  		appendGeneralDBSpatialFunctionTriple(expr, filter, SpatialFunctionsPostGIS.ST_Relate);
   2.148 -			}
   2.149 +	}
   2.150  
   2.151  	@Override	
   2.152  	protected void append(GeneralDBSqlLeft expr, GeneralDBSqlExprBuilder filter)
   2.153 -			throws UnsupportedRdbmsOperatorException
   2.154 -			{
   2.155 +	throws UnsupportedRdbmsOperatorException
   2.156 +	{
   2.157  		appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.left);
   2.158 -			}
   2.159 +	}
   2.160  
   2.161  	@Override
   2.162  	protected void append(GeneralDBSqlRight expr, GeneralDBSqlExprBuilder filter)
   2.163 -			throws UnsupportedRdbmsOperatorException
   2.164 -			{
   2.165 +	throws UnsupportedRdbmsOperatorException
   2.166 +	{
   2.167  		appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.right);
   2.168 -			}
   2.169 +	}
   2.170  
   2.171  	@Override
   2.172  	protected void append(GeneralDBSqlAbove expr, GeneralDBSqlExprBuilder filter)
   2.173 -			throws UnsupportedRdbmsOperatorException
   2.174 -			{
   2.175 +	throws UnsupportedRdbmsOperatorException
   2.176 +	{
   2.177  		appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.above);
   2.178 -			}
   2.179 +	}
   2.180  
   2.181  	@Override
   2.182  	protected void append(GeneralDBSqlBelow expr, GeneralDBSqlExprBuilder filter)
   2.183 -			throws UnsupportedRdbmsOperatorException
   2.184 -			{
   2.185 +	throws UnsupportedRdbmsOperatorException
   2.186 +	{
   2.187  		appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.below);
   2.188 -			}
   2.189 +	}
   2.190  
   2.191  	//GeoSPARQL - Spatial Relationship Functions 
   2.192  	//Simple Features
   2.193  	@Override
   2.194  	protected void append(GeneralDBSqlSF_Contains expr, GeneralDBSqlExprBuilder filter)
   2.195 -			throws UnsupportedRdbmsOperatorException
   2.196 -			{
   2.197 +	throws UnsupportedRdbmsOperatorException
   2.198 +	{
   2.199  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Contains);
   2.200 -			}
   2.201 +	}
   2.202  
   2.203  	@Override
   2.204  	protected void append(GeneralDBSqlSF_Crosses expr, GeneralDBSqlExprBuilder filter)
   2.205 -			throws UnsupportedRdbmsOperatorException
   2.206 -			{
   2.207 +	throws UnsupportedRdbmsOperatorException
   2.208 +	{
   2.209  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Crosses);
   2.210 -			}
   2.211 +	}
   2.212  
   2.213  	@Override
   2.214  	protected void append(GeneralDBSqlSF_Disjoint expr, GeneralDBSqlExprBuilder filter)
   2.215 -			throws UnsupportedRdbmsOperatorException
   2.216 -			{
   2.217 +	throws UnsupportedRdbmsOperatorException
   2.218 +	{
   2.219  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Disjoint);
   2.220 -			}
   2.221 +	}
   2.222  
   2.223  	@Override
   2.224  	protected void append(GeneralDBSqlSF_Equals expr, GeneralDBSqlExprBuilder filter)
   2.225 -			throws UnsupportedRdbmsOperatorException
   2.226 -			{
   2.227 +	throws UnsupportedRdbmsOperatorException
   2.228 +	{
   2.229  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Equals);
   2.230 -			}
   2.231 +	}
   2.232  
   2.233  	@Override
   2.234  	protected void append(GeneralDBSqlSF_Intersects expr, GeneralDBSqlExprBuilder filter)
   2.235 -			throws UnsupportedRdbmsOperatorException
   2.236 -			{
   2.237 +	throws UnsupportedRdbmsOperatorException
   2.238 +	{
   2.239  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Intersects);
   2.240 -			}
   2.241 +	}
   2.242  
   2.243  	@Override
   2.244  	protected void append(GeneralDBSqlSF_Overlaps expr, GeneralDBSqlExprBuilder filter)
   2.245 -			throws UnsupportedRdbmsOperatorException
   2.246 -			{
   2.247 +	throws UnsupportedRdbmsOperatorException
   2.248 +	{
   2.249  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Overlaps);
   2.250 -			}
   2.251 +	}
   2.252  
   2.253  	@Override
   2.254  	protected void append(GeneralDBSqlSF_Touches expr, GeneralDBSqlExprBuilder filter)
   2.255 -			throws UnsupportedRdbmsOperatorException
   2.256 -			{
   2.257 +	throws UnsupportedRdbmsOperatorException
   2.258 +	{
   2.259  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Touches);
   2.260 -			}
   2.261 +	}
   2.262  
   2.263  	@Override
   2.264  	protected void append(GeneralDBSqlSF_Within expr, GeneralDBSqlExprBuilder filter)
   2.265 -			throws UnsupportedRdbmsOperatorException
   2.266 -			{
   2.267 +	throws UnsupportedRdbmsOperatorException
   2.268 +	{
   2.269  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Within);
   2.270 -			}
   2.271 +	}
   2.272  
   2.273  	//Egenhofer
   2.274  	@Override
   2.275  	protected void append(GeneralDBSqlEgenhofer_CoveredBy expr, GeneralDBSqlExprBuilder filter)
   2.276 -			throws UnsupportedRdbmsOperatorException
   2.277 -			{
   2.278 +	throws UnsupportedRdbmsOperatorException
   2.279 +	{
   2.280  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_CoveredBy);
   2.281 -			}
   2.282 +	}
   2.283  
   2.284  	@Override
   2.285  	protected void append(GeneralDBSqlEgenhofer_Covers expr, GeneralDBSqlExprBuilder filter)
   2.286 -			throws UnsupportedRdbmsOperatorException
   2.287 -			{
   2.288 +	throws UnsupportedRdbmsOperatorException
   2.289 +	{
   2.290  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Covers);
   2.291 -			}
   2.292 +	}
   2.293  
   2.294  	@Override
   2.295  	protected void append(GeneralDBSqlEgenhofer_Contains expr, GeneralDBSqlExprBuilder filter)
   2.296 -			throws UnsupportedRdbmsOperatorException
   2.297 -			{
   2.298 +	throws UnsupportedRdbmsOperatorException
   2.299 +	{
   2.300  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Contains);
   2.301 -			}
   2.302 +	}
   2.303  
   2.304  	@Override
   2.305  	protected void append(GeneralDBSqlEgenhofer_Disjoint expr, GeneralDBSqlExprBuilder filter)
   2.306 -			throws UnsupportedRdbmsOperatorException
   2.307 -			{
   2.308 +	throws UnsupportedRdbmsOperatorException
   2.309 +	{
   2.310  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Disjoint);
   2.311 -			}
   2.312 +	}
   2.313  
   2.314  	@Override
   2.315  	protected void append(GeneralDBSqlEgenhofer_Equals expr, GeneralDBSqlExprBuilder filter)
   2.316 -			throws UnsupportedRdbmsOperatorException
   2.317 -			{
   2.318 +	throws UnsupportedRdbmsOperatorException
   2.319 +	{
   2.320  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Equals);
   2.321 -			}
   2.322 +	}
   2.323  
   2.324  	@Override
   2.325  	protected void append(GeneralDBSqlEgenhofer_Inside expr, GeneralDBSqlExprBuilder filter)
   2.326 -			throws UnsupportedRdbmsOperatorException
   2.327 -			{
   2.328 +	throws UnsupportedRdbmsOperatorException
   2.329 +	{
   2.330  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Inside);
   2.331 -			}
   2.332 +	}
   2.333  
   2.334  	@Override
   2.335  	protected void append(GeneralDBSqlEgenhofer_Meet expr, GeneralDBSqlExprBuilder filter)
   2.336 -			throws UnsupportedRdbmsOperatorException
   2.337 -			{
   2.338 +	throws UnsupportedRdbmsOperatorException
   2.339 +	{
   2.340  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Meet);
   2.341 -			}
   2.342 +	}
   2.343  
   2.344  	@Override
   2.345  	protected void append(GeneralDBSqlEgenhofer_Overlap expr, GeneralDBSqlExprBuilder filter)
   2.346 -			throws UnsupportedRdbmsOperatorException
   2.347 -			{
   2.348 +	throws UnsupportedRdbmsOperatorException
   2.349 +	{
   2.350  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Overlap);
   2.351 -			}
   2.352 +	}
   2.353  
   2.354  	//RCC8
   2.355  	@Override
   2.356  	protected void append(GeneralDBSqlRCC8_Dc expr, GeneralDBSqlExprBuilder filter)
   2.357 -			throws UnsupportedRdbmsOperatorException
   2.358 -			{
   2.359 +	throws UnsupportedRdbmsOperatorException
   2.360 +	{
   2.361  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Dc);
   2.362 -			}
   2.363 +	}
   2.364  
   2.365  	@Override
   2.366  	protected void append(GeneralDBSqlRCC8_Eq expr, GeneralDBSqlExprBuilder filter)
   2.367 -			throws UnsupportedRdbmsOperatorException
   2.368 -			{
   2.369 +	throws UnsupportedRdbmsOperatorException
   2.370 +	{
   2.371  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Eq);
   2.372 -			}
   2.373 +	}
   2.374  
   2.375  	@Override
   2.376  	protected void append(GeneralDBSqlRCC8_Ec expr, GeneralDBSqlExprBuilder filter)
   2.377 -			throws UnsupportedRdbmsOperatorException
   2.378 -			{
   2.379 +	throws UnsupportedRdbmsOperatorException
   2.380 +	{
   2.381  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Ec);
   2.382 -			}
   2.383 +	}
   2.384  
   2.385  	@Override
   2.386  	protected void append(GeneralDBSqlRCC8_Po expr, GeneralDBSqlExprBuilder filter)
   2.387 -			throws UnsupportedRdbmsOperatorException
   2.388 -			{
   2.389 +	throws UnsupportedRdbmsOperatorException
   2.390 +	{
   2.391  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Po);
   2.392 -			}
   2.393 +	}
   2.394  
   2.395  	@Override
   2.396  	protected void append(GeneralDBSqlRCC8_Tppi expr, GeneralDBSqlExprBuilder filter)
   2.397 -			throws UnsupportedRdbmsOperatorException
   2.398 -			{
   2.399 +	throws UnsupportedRdbmsOperatorException
   2.400 +	{
   2.401  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Tppi);
   2.402 -			}
   2.403 +	}
   2.404  
   2.405  	@Override
   2.406  	protected void append(GeneralDBSqlRCC8_Tpp expr, GeneralDBSqlExprBuilder filter)
   2.407 -			throws UnsupportedRdbmsOperatorException
   2.408 -			{
   2.409 +	throws UnsupportedRdbmsOperatorException
   2.410 +	{
   2.411  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Tpp);
   2.412 -			}
   2.413 +	}
   2.414  
   2.415  	@Override
   2.416  	protected void append(GeneralDBSqlRCC8_Ntpp expr, GeneralDBSqlExprBuilder filter)
   2.417 -			throws UnsupportedRdbmsOperatorException
   2.418 -			{
   2.419 +	throws UnsupportedRdbmsOperatorException
   2.420 +	{
   2.421  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Ntpp);
   2.422 -			}
   2.423 +	}
   2.424  
   2.425  	@Override
   2.426  	protected void append(GeneralDBSqlRCC8_Ntppi expr, GeneralDBSqlExprBuilder filter)
   2.427 -			throws UnsupportedRdbmsOperatorException
   2.428 -			{
   2.429 +	throws UnsupportedRdbmsOperatorException
   2.430 +	{
   2.431  		appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Ntppi);
   2.432 -			}
   2.433 +	}
   2.434  
   2.435  	//Spatial Construct Functions
   2.436  	@Override
   2.437  	protected void append(GeneralDBSqlGeoUnion expr, GeneralDBSqlExprBuilder filter)
   2.438 -			throws UnsupportedRdbmsOperatorException
   2.439 -			{
   2.440 +	throws UnsupportedRdbmsOperatorException
   2.441 +	{
   2.442  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Union);
   2.443 -			}
   2.444 +	}
   2.445  
   2.446  	@Override
   2.447  	protected void append(GeneralDBSqlGeoBuffer expr, GeneralDBSqlExprBuilder filter)
   2.448 -			throws UnsupportedRdbmsOperatorException
   2.449 -			{
   2.450 +	throws UnsupportedRdbmsOperatorException
   2.451 +	{
   2.452  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Buffer);
   2.453 -			}
   2.454 +	}
   2.455  
   2.456  	//XXX Different Behavior
   2.457  	@Override
   2.458  	protected void append(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   2.459 -			throws UnsupportedRdbmsOperatorException
   2.460 -			{
   2.461 +	throws UnsupportedRdbmsOperatorException
   2.462 +	{
   2.463  		appendTransformFunc(expr, filter);
   2.464 -			}
   2.465 +	}
   2.466  
   2.467  	@Override
   2.468  	protected void append(GeneralDBSqlGeoEnvelope expr, GeneralDBSqlExprBuilder filter)
   2.469 -			throws UnsupportedRdbmsOperatorException
   2.470 -			{
   2.471 +	throws UnsupportedRdbmsOperatorException
   2.472 +	{
   2.473  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Envelope);
   2.474 -			}
   2.475 +	}
   2.476  
   2.477  	@Override
   2.478  	protected void append(GeneralDBSqlGeoConvexHull expr, GeneralDBSqlExprBuilder filter)
   2.479 -			throws UnsupportedRdbmsOperatorException
   2.480 -			{
   2.481 +	throws UnsupportedRdbmsOperatorException
   2.482 +	{
   2.483  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_ConvexHull);
   2.484 -			}
   2.485 +	}
   2.486  
   2.487  	@Override
   2.488  	protected void append(GeneralDBSqlGeoBoundary expr, GeneralDBSqlExprBuilder filter)
   2.489 -			throws UnsupportedRdbmsOperatorException
   2.490 -			{
   2.491 +	throws UnsupportedRdbmsOperatorException
   2.492 +	{
   2.493  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Boundary);
   2.494 -			}
   2.495 +	}
   2.496  
   2.497  	@Override
   2.498  	protected void append(GeneralDBSqlGeoIntersection expr, GeneralDBSqlExprBuilder filter)
   2.499 -			throws UnsupportedRdbmsOperatorException
   2.500 -			{
   2.501 +	throws UnsupportedRdbmsOperatorException
   2.502 +	{
   2.503  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Intersection);
   2.504 -			}
   2.505 +	}
   2.506  
   2.507  	@Override
   2.508  	protected void append(GeneralDBSqlGeoDifference expr, GeneralDBSqlExprBuilder filter)
   2.509 -			throws UnsupportedRdbmsOperatorException
   2.510 -			{
   2.511 +	throws UnsupportedRdbmsOperatorException
   2.512 +	{
   2.513  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Difference);
   2.514 -			}
   2.515 +	}
   2.516  
   2.517  	@Override
   2.518  	protected void append(GeneralDBSqlGeoSymDifference expr, GeneralDBSqlExprBuilder filter)
   2.519 -			throws UnsupportedRdbmsOperatorException
   2.520 -			{
   2.521 +	throws UnsupportedRdbmsOperatorException
   2.522 +	{
   2.523  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_SymDifference);
   2.524 -			}
   2.525 +	}
   2.526  
   2.527  	//Spatial Metric Functions
   2.528  	@Override
   2.529  	protected void append(GeneralDBSqlGeoDistance expr, GeneralDBSqlExprBuilder filter)
   2.530 -			throws UnsupportedRdbmsOperatorException
   2.531 -			{
   2.532 +	throws UnsupportedRdbmsOperatorException
   2.533 +	{
   2.534  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Distance);
   2.535 -			}
   2.536 +	}
   2.537  
   2.538  	@Override
   2.539  	protected void append(GeneralDBSqlGeoArea expr, GeneralDBSqlExprBuilder filter)
   2.540 -			throws UnsupportedRdbmsOperatorException
   2.541 -			{
   2.542 +	throws UnsupportedRdbmsOperatorException
   2.543 +	{
   2.544  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Area);
   2.545 -			}
   2.546 +	}
   2.547  
   2.548  	//Spatial Property Functions
   2.549  	@Override
   2.550  	protected void append(GeneralDBSqlGeoDimension expr, GeneralDBSqlExprBuilder filter)
   2.551 -			throws UnsupportedRdbmsOperatorException
   2.552 -			{
   2.553 +	throws UnsupportedRdbmsOperatorException
   2.554 +	{
   2.555  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Dimension);
   2.556 -			}
   2.557 +	}
   2.558  
   2.559  	@Override
   2.560  	protected void append(GeneralDBSqlGeoGeometryType expr, GeneralDBSqlExprBuilder filter)
   2.561 -			throws UnsupportedRdbmsOperatorException
   2.562 -			{
   2.563 +	throws UnsupportedRdbmsOperatorException
   2.564 +	{
   2.565  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_GeometryType);
   2.566 -			}
   2.567 +	}
   2.568  
   2.569  	@Override
   2.570  	protected void append(GeneralDBSqlGeoAsText expr, GeneralDBSqlExprBuilder filter)
   2.571 -			throws UnsupportedRdbmsOperatorException
   2.572 -			{
   2.573 +	throws UnsupportedRdbmsOperatorException
   2.574 +	{
   2.575  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_AsText);
   2.576 -			}
   2.577 +	}
   2.578  
   2.579  	//	@Override
   2.580  	//	protected void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter)
   2.581 @@ -713,8 +713,8 @@
   2.582  	 */
   2.583  	@Override
   2.584  	protected void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter)
   2.585 -			throws UnsupportedRdbmsOperatorException
   2.586 -			{
   2.587 +	throws UnsupportedRdbmsOperatorException
   2.588 +	{
   2.589  		boolean sridNeeded = true;
   2.590  		filter.openBracket();
   2.591  
   2.592 @@ -829,21 +829,21 @@
   2.593  		}
   2.594  
   2.595  		filter.closeBracket();
   2.596 -			}
   2.597 +	}
   2.598  
   2.599  	@Override
   2.600  	protected void append(GeneralDBSqlGeoIsSimple expr, GeneralDBSqlExprBuilder filter)
   2.601 -			throws UnsupportedRdbmsOperatorException
   2.602 -			{
   2.603 +	throws UnsupportedRdbmsOperatorException
   2.604 +	{
   2.605  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_IsSimple);
   2.606 -			}
   2.607 +	}
   2.608  
   2.609  	@Override
   2.610  	protected void append(GeneralDBSqlGeoIsEmpty expr, GeneralDBSqlExprBuilder filter)
   2.611 -			throws UnsupportedRdbmsOperatorException
   2.612 -			{
   2.613 +	throws UnsupportedRdbmsOperatorException
   2.614 +	{
   2.615  		appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_IsEmpty);
   2.616 -			}
   2.617 +	}
   2.618  
   2.619  
   2.620  	/**
   2.621 @@ -1041,7 +1041,6 @@
   2.622  		}
   2.623  		filter.closeBracket();
   2.624  	}
   2.625 -	//	
   2.626  
   2.627  	//Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   2.628  	protected void appendTransformFunc(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   2.629 @@ -1190,8 +1189,8 @@
   2.630  	//Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   2.631  	//EXCEPT ST_Transform!!!
   2.632  	protected void appendGeneralDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
   2.633 -			throws UnsupportedRdbmsOperatorException
   2.634 -			{
   2.635 +	throws UnsupportedRdbmsOperatorException
   2.636 +	{
   2.637  		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   2.638  		boolean sridNeeded = true;
   2.639  		//XXX Incorporating SRID
   2.640 @@ -1267,6 +1266,7 @@
   2.641  
   2.642  			switch(func)
   2.643  			{
   2.644 +			//XXX Careful: ST_Transform support MISSING!!!
   2.645  			case ST_Difference: filter.appendFunction("ST_Difference"); break;
   2.646  			case ST_Intersection: filter.appendFunction("ST_Intersection"); break;
   2.647  			case ST_Union: filter.appendFunction("ST_Union"); break;
   2.648 @@ -1378,12 +1378,12 @@
   2.649  			filter.append(sridExpr);
   2.650  		}
   2.651  
   2.652 -			}
   2.653 +	}
   2.654  
   2.655  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1) 
   2.656  	protected void appendGeneralDBSpatialFunctionUnary(UnaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
   2.657 -			throws UnsupportedRdbmsOperatorException
   2.658 -			{
   2.659 +	throws UnsupportedRdbmsOperatorException
   2.660 +	{
   2.661  		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   2.662  		boolean sridNeeded = true;
   2.663  		String sridExpr = null;
   2.664 @@ -1504,7 +1504,7 @@
   2.665  			}
   2.666  
   2.667  			filter.closeBracket();
   2.668 -			//			//SRID Support
   2.669 +//			//SRID Support
   2.670  			if(sridNeeded)
   2.671  			{
   2.672  				if(expr instanceof GeneralDBSqlSpatialConstructUnary && expr.getParentNode() == null)
   2.673 @@ -1525,15 +1525,12 @@
   2.674  			filter.appendComma();
   2.675  			filter.append(sridExpr);
   2.676  		}
   2.677 -
   2.678 -			}
   2.679 -
   2.680 -
   2.681 +	}
   2.682  
   2.683  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   2.684  	protected void appendGeneralDBSpatialFunctionTriple(TripleGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
   2.685 -			throws UnsupportedRdbmsOperatorException
   2.686 -			{
   2.687 +	throws UnsupportedRdbmsOperatorException
   2.688 +	{
   2.689  		filter.openBracket();
   2.690  
   2.691  		boolean check1a = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
   2.692 @@ -1665,14 +1662,14 @@
   2.693  		}
   2.694  
   2.695  		filter.closeBracket();
   2.696 -			}
   2.697 +	}
   2.698  
   2.699  
   2.700  	//GeoSPARQL
   2.701  	//XXX
   2.702  	protected void appendRelate(BinaryGeneralDBOperator expr, PostGISSqlExprBuilder filter, char[] intersectionPattern)
   2.703 -			throws UnsupportedRdbmsOperatorException
   2.704 -			{
   2.705 +	throws UnsupportedRdbmsOperatorException
   2.706 +	{
   2.707  		filter.openBracket();
   2.708  
   2.709  		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.GeneralDBSqlNull");
   2.710 @@ -1776,12 +1773,12 @@
   2.711  		}
   2.712  
   2.713  		filter.closeBracket();
   2.714 -			}
   2.715 +	}
   2.716  
   2.717  
   2.718  	protected void appendgeoSPARQLSpatialRelation(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
   2.719 -			throws UnsupportedRdbmsOperatorException
   2.720 -			{
   2.721 +	throws UnsupportedRdbmsOperatorException
   2.722 +	{
   2.723  		filter.openBracket();
   2.724  		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.GeneralDBSqlNull");
   2.725  		if(check1)
   2.726 @@ -2123,15 +2120,15 @@
   2.727  			}
   2.728  		}
   2.729  		filter.closeBracket();
   2.730 -			}
   2.731 +	}
   2.732  
   2.733  	@Override
   2.734  	//GeoSPARQL
   2.735  	//XXX
   2.736  
   2.737  	protected void appendRelate(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, char[] intersectionPattern)
   2.738 -			throws UnsupportedRdbmsOperatorException
   2.739 -			{
   2.740 +	throws UnsupportedRdbmsOperatorException
   2.741 +	{
   2.742  		filter.openBracket();
   2.743  
   2.744  		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.monetdb.algebra.GeneralDBSqlNull");
   2.745 @@ -2235,5 +2232,5 @@
   2.746  		}
   2.747  
   2.748  		filter.closeBracket();
   2.749 -			}
   2.750 +	}
   2.751  }