Strabon

changeset 55:6ac1b8837a6a

Added strdf:transform. Currently supports user-input value as second argument. will extend in order to allow uri retrieved from db
author Manos Karpathiotakis <mk@di.uoa.gr>
date Thu Mar 15 18:33:05 2012 +0200 (2012-03-15)
parents b678ff809288
children bbd7bbc0921e
files evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBNumericExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBSqlExprFactory.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBSqlExprBuilder.java generaldb/src/main/java/org/openrdf/sail/generaldb/model/GeneralDBPolyhedron.java generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizerFactory.java 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/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java	Wed Mar 14 17:02:40 2012 +0200
     1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/StrabonPolyhedron.java	Thu Mar 15 18:33:05 2012 +0200
     1.3 @@ -28,6 +28,7 @@
     1.4  import org.opengis.referencing.crs.CoordinateReferenceSystem;
     1.5  import org.opengis.referencing.operation.MathTransform;
     1.6  import org.opengis.referencing.operation.TransformException;
     1.7 +import org.openrdf.model.URI;
     1.8  import org.openrdf.model.Value; 
     1.9  
    1.10  public class StrabonPolyhedron implements Value {
    1.11 @@ -68,6 +69,7 @@
    1.12  	public static final String intersection="http://strdf.di.uoa.gr/ontology#intersection";
    1.13  	public static final String difference="http://strdf.di.uoa.gr/ontology#difference";
    1.14  	public static final String symDifference="http://strdf.di.uoa.gr/ontology#symDifference";
    1.15 +	public static final String transform="http://strdf.di.uoa.gr/ontology#transform";
    1.16  	//Spatial Metric Functions
    1.17  	public static final String distance="http://strdf.di.uoa.gr/ontology#distance";
    1.18  	public static final String area="http://strdf.di.uoa.gr/ontology#area";
    1.19 @@ -799,6 +801,13 @@
    1.20  		poly.geometry = A.geometry;
    1.21  		return poly;
    1.22  	}
    1.23 +	
    1.24 +	public static StrabonPolyhedron transform(StrabonPolyhedron A, URI srid) throws Exception {
    1.25 +		
    1.26 +		int parsedSRID = Integer.parseInt(srid.toString().substring(srid.toString().lastIndexOf('/')+1));
    1.27 +		Geometry converted = StrabonPolyhedron.convertSRID(A.getGeometry(),A.getGeometry().getSRID(), parsedSRID);
    1.28 +		return new StrabonPolyhedron(converted);
    1.29 +	}
    1.30  
    1.31  	/**
    1.32  	 * Performs quick union between polygons or multipolygons.
     2.1 --- a/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java	Wed Mar 14 17:02:40 2012 +0200
     2.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/iterator/StSPARQLGroupIterator.java	Thu Mar 15 18:33:05 2012 +0200
     2.3 @@ -60,6 +60,7 @@
     2.4  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.EnvelopeFunc;
     2.5  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.IntersectionFunc;
     2.6  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.SymDifferenceFunc;
     2.7 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.TransformFunc;
     2.8  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc;
     2.9  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.AreaFunc;
    2.10  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.DistanceFunc;
    2.11 @@ -423,6 +424,13 @@
    2.12  					LiteralImpl lit = (LiteralImpl) radius;
    2.13  					return StrabonPolyhedron.buffer(leftArg,lit.doubleValue());
    2.14  				}
    2.15 +				else if(function instanceof TransformFunc)
    2.16 +				{
    2.17 +					leftArg = (StrabonPolyhedron) evaluateConstruct(((FunctionCall) expr).getArgs().get(0),prototype);
    2.18 +					Value sridCoarse = strategy.evaluate(((FunctionCall) expr).getArgs().get(1),prototype);
    2.19 +					URIImpl srid = (URIImpl) sridCoarse;
    2.20 +					return StrabonPolyhedron.transform(leftArg,srid);
    2.21 +				}
    2.22  				else if(function instanceof EnvelopeFunc)
    2.23  				{
    2.24  					leftArg = (StrabonPolyhedron) evaluateConstruct(((FunctionCall) expr).getArgs().get(0),prototype);
     3.1 --- a/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Wed Mar 14 17:02:40 2012 +0200
     3.2 +++ b/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function	Thu Mar 15 18:33:05 2012 +0200
     3.3 @@ -20,6 +20,7 @@
     3.4  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.AboveFunc
     3.5  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.BelowFunc
     3.6  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BufferFunc
     3.7 +org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.TransformFunc
     3.8  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc
     3.9  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.IntersectionFunc
    3.10  org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.DifferenceFunc
     4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java	Wed Mar 14 17:02:40 2012 +0200
     4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java	Thu Mar 15 18:33:05 2012 +0200
     4.3 @@ -42,6 +42,7 @@
     4.4  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIsSimple;
     4.5  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSrid;
     4.6  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSymDifference;
     4.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoTransform;
     4.8  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoUnion;
     4.9  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlInside;
    4.10  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlIsNull;
    4.11 @@ -337,6 +338,11 @@
    4.12  		return new GeneralDBSqlGeoBuffer(left, right);
    4.13  	}
    4.14  	
    4.15 +	public static GeneralDBSqlExpr geoTransform(GeneralDBSqlExpr left, GeneralDBSqlExpr right) {
    4.16 +
    4.17 +		return new GeneralDBSqlGeoTransform(left, right);
    4.18 +	}
    4.19 +	
    4.20  	public static GeneralDBSqlExpr geoEnvelope(GeneralDBSqlExpr expr) {
    4.21  
    4.22  		return new GeneralDBSqlGeoEnvelope(expr);
     5.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Wed Mar 14 17:02:40 2012 +0200
     5.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java	Thu Mar 15 18:33:05 2012 +0200
     5.3 @@ -65,6 +65,7 @@
     5.4  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BoundaryFunc;
     5.5  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.ConvexHullFunc;
     5.6  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.EnvelopeFunc;
     5.7 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.TransformFunc;
     5.8  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc;
     5.9  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.AreaFunc;
    5.10  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.RelateFunc;
    5.11 @@ -123,6 +124,7 @@
    5.12  
    5.13  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoUnion;
    5.14  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoBuffer;
    5.15 +import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoTransform;
    5.16  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoEnvelope;
    5.17  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoConvexHull;
    5.18  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoBoundary;
    5.19 @@ -641,10 +643,15 @@
    5.20  						//Be it a Var or a Value Constant, 'numeric' is the way to go
    5.21  						rightArg = numeric(right);
    5.22  					}
    5.23 -					//DEFAULT behavior for constructs! buffer's second argument is a ValueConstant or a Var,
    5.24 -					//thus the special treatment
    5.25 +					else if(function.getURI().equals(StrabonPolyhedron.transform))
    5.26 +					{
    5.27 +						//Another special case -> Second argument of this function is a URI
    5.28 +						rightArg = uri(right);
    5.29 +					}
    5.30  					else 
    5.31  					{
    5.32 +						//DEFAULT behavior for constructs! buffer's second argument is a ValueConstant or a Var,
    5.33 +						//thus the special treatment
    5.34  						rightArg = label(right);
    5.35  					}
    5.36  				}
    5.37 @@ -854,10 +861,15 @@
    5.38  					//Be it a Var or a Value Constant, 'numeric' is the way to go
    5.39  					rightArg = numeric(right);
    5.40  				}
    5.41 -				//DEFAULT behavior for constructs! buffer's second argument is a ValueConstant or a Var,
    5.42 -				//thus the special treatment
    5.43 +				else if(function.getURI().equals(StrabonPolyhedron.transform))
    5.44 +				{
    5.45 +					//Another special case -> Second argument of this function is a URI
    5.46 +					rightArg = uri(right);
    5.47 +				}
    5.48  				else 
    5.49  				{
    5.50 +					//DEFAULT behavior for constructs! buffer's second argument is a ValueConstant or a Var,
    5.51 +					//thus the special treatment
    5.52  					rightArg = label(right);
    5.53  				}
    5.54  			}
    5.55 @@ -1102,6 +1114,10 @@
    5.56  		{
    5.57  			return geoBuffer(leftArg,rightArg);
    5.58  		}
    5.59 +		else if(function.getURI().equals(StrabonPolyhedron.transform))
    5.60 +		{
    5.61 +			return geoTransform(leftArg,rightArg);
    5.62 +		}
    5.63  		else if(function.getURI().equals(StrabonPolyhedron.envelope))
    5.64  		{
    5.65  			return geoEnvelope(leftArg);
     6.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBNumericExprFactory.java	Wed Mar 14 17:02:40 2012 +0200
     6.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBNumericExprFactory.java	Thu Mar 15 18:33:05 2012 +0200
     6.3 @@ -16,6 +16,7 @@
     6.4  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoArea;
     6.5  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoBoundary;
     6.6  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoBuffer;
     6.7 +import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoTransform;
     6.8  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoConvexHull;
     6.9  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoDifference;
    6.10  import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoDistance;
    6.11 @@ -82,8 +83,10 @@
    6.12  
    6.13  	/**
    6.14  	 * Addition in order to be able to transform the metric expressions I need
    6.15 +	 * I also needed to create uri expressions
    6.16  	 */
    6.17  	private GeneralDBLabelExprFactory labelsPeek;
    6.18 +	private GeneralDBURIExprFactory urisPeek;
    6.19  
    6.20  	public GeneralDBLabelExprFactory getLabelsPeek() {
    6.21  		return labelsPeek;
    6.22 @@ -92,13 +95,21 @@
    6.23  	public void setLabelsPeek(GeneralDBLabelExprFactory labelsPeek) {
    6.24  		this.labelsPeek = labelsPeek;
    6.25  	}
    6.26 +
    6.27 +	public GeneralDBURIExprFactory getUrisPeek() {
    6.28 +		return urisPeek;
    6.29 +	}
    6.30 +
    6.31 +	public void setUrisPeek(GeneralDBURIExprFactory labelsPeek) {
    6.32 +		this.urisPeek = urisPeek;
    6.33 +	}
    6.34  	/**
    6.35  	 * 
    6.36  	 */
    6.37  
    6.38  	public GeneralDBSqlExpr createNumericExpr(ValueExpr expr)
    6.39 -	throws UnsupportedRdbmsOperatorException
    6.40 -	{
    6.41 +			throws UnsupportedRdbmsOperatorException
    6.42 +			{
    6.43  		result = null;
    6.44  		if (expr == null)
    6.45  			return new GeneralDBSqlNull();
    6.46 @@ -106,7 +117,7 @@
    6.47  		if (result == null)
    6.48  			return new GeneralDBSqlNull();
    6.49  		return result;
    6.50 -	}
    6.51 +			}
    6.52  
    6.53  	@Override
    6.54  	public void meet(Datatype node) {
    6.55 @@ -115,18 +126,18 @@
    6.56  
    6.57  	@Override
    6.58  	public void meet(Lang node)
    6.59 -	throws UnsupportedRdbmsOperatorException
    6.60 -	{
    6.61 +			throws UnsupportedRdbmsOperatorException
    6.62 +			{
    6.63  		result = sqlNull();
    6.64 -	}
    6.65 +			}
    6.66  
    6.67  	/**
    6.68  	 * XXX changes here to enable more complicated metric expressions
    6.69  	 */
    6.70  	@Override
    6.71  	public void meet(MathExpr node)
    6.72 -	throws UnsupportedRdbmsOperatorException
    6.73 -	{
    6.74 +			throws UnsupportedRdbmsOperatorException
    6.75 +			{
    6.76  		GeneralDBSqlExpr left;// = createNumericExpr(node.getLeftArg());
    6.77  		GeneralDBSqlExpr right;// = createNumericExpr(node.getRightArg());
    6.78  
    6.79 @@ -161,7 +172,7 @@
    6.80  
    6.81  		MathOp op = node.getOperator();
    6.82  		result = new GeneralDBSqlMathExpr(left, op, right);
    6.83 -	}
    6.84 +			}
    6.85  
    6.86  	@Override
    6.87  	public void meet(Str node) {
    6.88 @@ -185,10 +196,10 @@
    6.89  
    6.90  	@Override
    6.91  	protected void meetNode(QueryModelNode arg)
    6.92 -	throws UnsupportedRdbmsOperatorException
    6.93 -	{
    6.94 +			throws UnsupportedRdbmsOperatorException
    6.95 +			{
    6.96  		throw unsupported(arg);
    6.97 -	}
    6.98 +			}
    6.99  
   6.100  	private GeneralDBSqlExpr valueOf(Value value) {
   6.101  		if (value instanceof Literal) {
   6.102 @@ -306,12 +317,21 @@
   6.103  					//Be it a Var or a Value Constant, 'numeric' is the way to go
   6.104  					rightArg = this.createNumericExpr(right);
   6.105  				}
   6.106 -				//DEFAULT behavior for constructs! buffer's second argument is a ValueConstant or a Var,
   6.107 -				//thus the special treatment
   6.108 +				else if(function.getURI().equals(StrabonPolyhedron.transform))
   6.109 +				{
   6.110 +					//Another special case -> Second argument of this function is a URI
   6.111 +					rightArg = uri(right);
   6.112 +				}
   6.113  				else 
   6.114 -				{
   6.115 +				{	
   6.116 +					//DEFAULT behavior for constructs! buffer's second argument is a ValueConstant or a Var,
   6.117 +					//thus the special treatment
   6.118  					rightArg = label(right);
   6.119  				}
   6.120 +
   6.121 +
   6.122 +
   6.123 +
   6.124  			}
   6.125  		}
   6.126  
   6.127 @@ -386,6 +406,10 @@
   6.128  		{
   6.129  			return geoBuffer(leftArg,rightArg);
   6.130  		}
   6.131 +		else if(function.getURI().equals(StrabonPolyhedron.transform))
   6.132 +		{
   6.133 +			return geoTransform(leftArg,rightArg);
   6.134 +		}
   6.135  		else if(function.getURI().equals(StrabonPolyhedron.envelope))
   6.136  		{
   6.137  			return geoEnvelope(leftArg);
   6.138 @@ -493,10 +517,16 @@
   6.139  	}
   6.140  
   6.141  	protected GeneralDBSqlExpr label(ValueExpr arg)
   6.142 -	throws UnsupportedRdbmsOperatorException
   6.143 -	{
   6.144 +			throws UnsupportedRdbmsOperatorException
   6.145 +			{
   6.146  		return labelsPeek.createLabelExpr(arg);
   6.147 -	}
   6.148 +			}
   6.149 +
   6.150 +	protected GeneralDBSqlExpr uri(ValueExpr arg)
   6.151 +			throws UnsupportedRdbmsOperatorException
   6.152 +			{
   6.153 +		return urisPeek.createUriExpr(arg);
   6.154 +			}
   6.155  
   6.156  	//	protected GeneralDBSqlExpr numeric(ValueExpr arg)
   6.157  	//	throws UnsupportedRdbmsOperatorException
     7.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBSqlExprFactory.java	Wed Mar 14 17:02:40 2012 +0200
     7.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBSqlExprFactory.java	Thu Mar 15 18:33:05 2012 +0200
     7.3 @@ -78,9 +78,10 @@
     7.4  		this.numeric = numeric;
     7.5  		//XXX don't like the way I get access to what I need, but it seems it is the only choice
     7.6  		//Extra note: This setter must FOLLOW the one for the LabelExprFactory!!! 
     7.7 +		//* and the one of the URIExprFactory as well
     7.8  		//Otherwise an exception will be thrown 
     7.9  		numeric.setLabelsPeek(label);
    7.10 -		
    7.11 +		numeric.setUrisPeek(uri);
    7.12  	}
    7.13  
    7.14  	public void setTimeExprFactory(GeneralDBTimeExprFactory time) {
     8.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Wed Mar 14 17:02:40 2012 +0200
     8.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java	Thu Mar 15 18:33:05 2012 +0200
     8.3 @@ -36,6 +36,7 @@
     8.4  import org.openrdf.model.Value;
     8.5  import org.openrdf.model.impl.BooleanLiteralImpl;
     8.6  import org.openrdf.model.impl.LiteralImpl;
     8.7 +import org.openrdf.model.impl.URIImpl;
     8.8  import org.openrdf.query.BindingSet;
     8.9  import org.openrdf.query.Dataset;
    8.10  import org.openrdf.query.QueryEvaluationException;
    8.11 @@ -82,7 +83,6 @@
    8.12  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.RightFunc;
    8.13  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.relation.TouchFunc;
    8.14  import org.openrdf.query.algebra.evaluation.impl.EvaluationStrategyImpl;
    8.15 -import org.openrdf.query.algebra.evaluation.iterator.ExtensionIterator;
    8.16  import org.openrdf.query.algebra.evaluation.iterator.StSPARQLGroupIterator;
    8.17  import org.openrdf.query.algebra.evaluation.iterator.OrderIterator;
    8.18  import org.openrdf.query.algebra.evaluation.util.StSPARQLOrderComparator;
    8.19 @@ -114,12 +114,14 @@
    8.20  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialProperty;
    8.21  import org.openrdf.sail.generaldb.algebra.GeneralDBSelectQuery.OrderElem;
    8.22  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructBinary;
    8.23 +import org.openrdf.sail.generaldb.algebra.GeneralDBURIColumn;
    8.24  import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr;
    8.25  import org.openrdf.sail.generaldb.model.GeneralDBPolyhedron;
    8.26  import org.openrdf.sail.rdbms.exceptions.RdbmsException;
    8.27  import org.openrdf.sail.rdbms.exceptions.RdbmsQueryEvaluationException;
    8.28  import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException;
    8.29  import org.openrdf.sail.rdbms.model.RdbmsLiteral;
    8.30 +import org.openrdf.sail.rdbms.model.RdbmsURI;
    8.31  import org.openrdf.sail.generaldb.schema.IdSequence;
    8.32  
    8.33  import com.vividsolutions.jts.geom.Geometry;
    8.34 @@ -292,13 +294,13 @@
    8.35  		Value leftResult = null;
    8.36  		Value rightResult = null;
    8.37  
    8.38 -//		try {
    8.39 -			leftResult = evaluate(left,bindings);
    8.40 -//		} catch (ValueExprEvaluationException e) {
    8.41 -//			e.printStackTrace();
    8.42 -//		} catch (QueryEvaluationException e) {
    8.43 -//			e.printStackTrace();
    8.44 -//		}
    8.45 +		//		try {
    8.46 +		leftResult = evaluate(left,bindings);
    8.47 +		//		} catch (ValueExprEvaluationException e) {
    8.48 +		//			e.printStackTrace();
    8.49 +		//		} catch (QueryEvaluationException e) {
    8.50 +		//			e.printStackTrace();
    8.51 +		//		}
    8.52  
    8.53  
    8.54  		//		if(!(function instanceof EnvelopeFunc) 
    8.55 @@ -307,13 +309,13 @@
    8.56  		if ( fc.getArgs().size() == 2 )
    8.57  		{
    8.58  			ValueExpr right = fc.getArgs().get(1);
    8.59 -//			try {
    8.60 -				rightResult = evaluate(right,bindings);
    8.61 -//			} catch (ValueExprEvaluationException e) {
    8.62 -//				e.printStackTrace();
    8.63 -//			} catch (QueryEvaluationException e) {
    8.64 -//				e.printStackTrace();
    8.65 -//			}
    8.66 +			//			try {
    8.67 +			rightResult = evaluate(right,bindings);
    8.68 +			//			} catch (ValueExprEvaluationException e) {
    8.69 +			//				e.printStackTrace();
    8.70 +			//			} catch (QueryEvaluationException e) {
    8.71 +			//				e.printStackTrace();
    8.72 +			//			}
    8.73  		}
    8.74  
    8.75  		try {
    8.76 @@ -506,6 +508,22 @@
    8.77  			}
    8.78  
    8.79  		}
    8.80 +		else if(function.getURI().equals(StrabonPolyhedron.transform))
    8.81 +		{
    8.82 +			if(right instanceof URIImpl)
    8.83 +			{
    8.84 +				URIImpl srid = (URIImpl) right;
    8.85 +				return StrabonPolyhedron.transform(leftArg,srid);
    8.86 +			}
    8.87 +			else if(right instanceof RdbmsURI)
    8.88 +			{
    8.89 +				RdbmsURI srid = (RdbmsURI) right;
    8.90 +				int parsedSRID = Integer.parseInt(srid.toString().substring(srid.toString().lastIndexOf('/')+1));
    8.91 +				Geometry converted = StrabonPolyhedron.convertSRID(leftArg.getGeometry(),leftArg.getGeometry().getSRID(), parsedSRID);
    8.92 +				return new StrabonPolyhedron(converted);
    8.93 +			}
    8.94 +
    8.95 +		}
    8.96  		else if(function.getURI().equals(StrabonPolyhedron.envelope))
    8.97  		{
    8.98  			return StrabonPolyhedron.envelope(leftArg);
    8.99 @@ -886,6 +904,22 @@
   8.100  			}
   8.101  			//System.out.println("stopper");
   8.102  		}
   8.103 +		else if(expr instanceof GeneralDBURIColumn)//Used for 2nd argument of Transform
   8.104 +		{
   8.105 +			boolean found = false;
   8.106 +			String name = ((GeneralDBURIColumn) expr).getVarName();
   8.107 +
   8.108 +			for(GeneralDBColumnVar reference: allKnown)
   8.109 +			{
   8.110 +				if(name.equals(reference.getName()))
   8.111 +				{
   8.112 +					GeneralDBSqlExpr exprCopy = new GeneralDBURIColumn(reference);
   8.113 +					expr.replaceWith(exprCopy);
   8.114 +					found = true;
   8.115 +				}
   8.116 +			}
   8.117 +
   8.118 +		}
   8.119  		else if(expr instanceof GeneralDBSqlMathExpr)//Case when I have calculations in select
   8.120  		{
   8.121  			locateColumnVars(((GeneralDBSqlMathExpr)expr).getLeftArg(),allKnown);
     9.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Wed Mar 14 17:02:40 2012 +0200
     9.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java	Thu Mar 15 18:33:05 2012 +0200
     9.3 @@ -56,6 +56,7 @@
     9.4  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIsSimple;
     9.5  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSrid;
     9.6  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSymDifference;
     9.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoTransform;
     9.8  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoUnion;
     9.9  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlInside;
    9.10  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlIsNull;
    9.11 @@ -118,7 +119,7 @@
    9.12   */
    9.13  public abstract class GeneralDBQueryBuilder {
    9.14  
    9.15 -	
    9.16 +
    9.17  	protected GeneralDBSqlQueryBuilder query;
    9.18  
    9.19  	protected GeneralDBValueFactory vf;
    9.20 @@ -126,7 +127,7 @@
    9.21  	protected boolean usingHashTable;
    9.22  
    9.23  	public GeneralDBQueryBuilder() {}
    9.24 -	
    9.25 +
    9.26  	public GeneralDBQueryBuilder(GeneralDBSqlQueryBuilder builder) {
    9.27  		super();
    9.28  		this.query = builder;
    9.29 @@ -145,19 +146,19 @@
    9.30  	}
    9.31  
    9.32  	public GeneralDBQueryBuilder filter(GeneralDBColumnVar var, Value val)
    9.33 -	throws RdbmsException
    9.34 -	{
    9.35 +			throws RdbmsException
    9.36 +			{
    9.37  		String alias = var.getAlias();
    9.38  		String column = var.getColumn();
    9.39  		query.filter().and().columnEquals(alias, column, vf.getInternalId(val));
    9.40  		return this;
    9.41 -	}
    9.42 +			}
    9.43  
    9.44  	public void from(GeneralDBFromItem from)
    9.45 -	throws RdbmsException, UnsupportedRdbmsOperatorException
    9.46 -	{
    9.47 +			throws RdbmsException, UnsupportedRdbmsOperatorException
    9.48 +			{
    9.49  		from(query, from);
    9.50 -	}
    9.51 +			}
    9.52  
    9.53  	public List<?> getParameters() {
    9.54  		return query.findParameters(new ArrayList<Object>());
    9.55 @@ -172,22 +173,22 @@
    9.56  	}
    9.57  
    9.58  	public void orderBy(GeneralDBSqlExpr expr, boolean isAscending)
    9.59 -	throws UnsupportedRdbmsOperatorException
    9.60 -	{
    9.61 +			throws UnsupportedRdbmsOperatorException
    9.62 +			{
    9.63  		GeneralDBSqlExprBuilder orderBy = query.orderBy();
    9.64  		dispatch(expr, orderBy);
    9.65  		if (!isAscending) {
    9.66  			orderBy.append(" DESC");
    9.67  		}
    9.68 -	}
    9.69 +			}
    9.70  
    9.71  	public GeneralDBQueryBuilder select(GeneralDBSqlExpr expr)
    9.72 -	throws UnsupportedRdbmsOperatorException
    9.73 -	{
    9.74 +			throws UnsupportedRdbmsOperatorException
    9.75 +			{
    9.76  		dispatch(expr, query.select());
    9.77  
    9.78  		return this;
    9.79 -	}
    9.80 +			}
    9.81  
    9.82  	@Override
    9.83  	public String toString() {
    9.84 @@ -233,7 +234,7 @@
    9.85  		}
    9.86  		return sb.toString();
    9.87  	}	
    9.88 -	
    9.89 +
    9.90  	protected void append(GeneralDBBNodeColumn var, GeneralDBSqlExprBuilder filter) {
    9.91  		String alias = getBNodeAlias(var.getRdbmsVar());
    9.92  		filter.column(alias, "value");
    9.93 @@ -328,24 +329,24 @@
    9.94  	}
    9.95  
    9.96  	protected void append(GeneralDBSqlAbs expr, GeneralDBSqlExprBuilder filter)
    9.97 -	throws UnsupportedRdbmsOperatorException
    9.98 -	{
    9.99 +			throws UnsupportedRdbmsOperatorException
   9.100 +			{
   9.101  		GeneralDBSqlBracketBuilder abs = filter.abs();
   9.102  		dispatch(expr.getArg(), (GeneralDBSqlExprBuilder) abs);
   9.103  		abs.close();
   9.104 -	}
   9.105 +			}
   9.106  
   9.107  	protected void append(GeneralDBSqlAnd expr, GeneralDBSqlExprBuilder filter)
   9.108 -	throws UnsupportedRdbmsOperatorException
   9.109 -	{
   9.110 +			throws UnsupportedRdbmsOperatorException
   9.111 +			{
   9.112  		dispatch(expr.getLeftArg(), filter);
   9.113  		filter.and();
   9.114  		dispatch(expr.getRightArg(), filter);
   9.115 -	}	
   9.116 +			}	
   9.117  
   9.118  	protected void append(GeneralDBSqlCase expr, GeneralDBSqlExprBuilder filter)
   9.119 -	throws UnsupportedRdbmsOperatorException
   9.120 -	{
   9.121 +			throws UnsupportedRdbmsOperatorException
   9.122 +			{
   9.123  		GeneralDBSqlCaseBuilder caseExpr = filter.caseBegin();
   9.124  		for (GeneralDBSqlCase.Entry e : expr.getEntries()) {
   9.125  			caseExpr.when();
   9.126 @@ -354,87 +355,87 @@
   9.127  			dispatch(e.getResult(), filter);
   9.128  		}
   9.129  		caseExpr.end();
   9.130 -	}
   9.131 +			}
   9.132  
   9.133  	protected void append(GeneralDBSqlCast expr, GeneralDBSqlExprBuilder filter)
   9.134 -	throws UnsupportedRdbmsOperatorException
   9.135 -	{
   9.136 +			throws UnsupportedRdbmsOperatorException
   9.137 +			{
   9.138  		GeneralDBSqlCastBuilder cast = filter.cast(expr.getType());
   9.139  		dispatch(expr.getArg(), (GeneralDBSqlExprBuilder) cast);
   9.140  		cast.close();
   9.141 -	}
   9.142 +			}
   9.143  
   9.144  	protected void append(GeneralDBSqlCompare expr, GeneralDBSqlExprBuilder filter)
   9.145 -	throws UnsupportedRdbmsOperatorException
   9.146 -	{
   9.147 +			throws UnsupportedRdbmsOperatorException
   9.148 +			{
   9.149  		dispatch(expr.getLeftArg(), filter);
   9.150  		filter.appendOperator(expr.getOperator());
   9.151  		dispatch(expr.getRightArg(), filter);
   9.152 -	}
   9.153 +			}
   9.154  
   9.155  	protected void append(GeneralDBSqlConcat expr, GeneralDBSqlExprBuilder filter)
   9.156 -	throws UnsupportedRdbmsOperatorException
   9.157 -	{
   9.158 +			throws UnsupportedRdbmsOperatorException
   9.159 +			{
   9.160  		GeneralDBSqlBracketBuilder open = filter.open();
   9.161  		dispatch(expr.getLeftArg(), (GeneralDBSqlExprBuilder) open);
   9.162  		open.concat();
   9.163  		dispatch(expr.getRightArg(), (GeneralDBSqlExprBuilder) open);
   9.164  		open.close();
   9.165 -	}
   9.166 +			}
   9.167  
   9.168  	protected void append(GeneralDBSqlEq expr, GeneralDBSqlExprBuilder filter)
   9.169 -	throws UnsupportedRdbmsOperatorException
   9.170 -	{
   9.171 +			throws UnsupportedRdbmsOperatorException
   9.172 +			{
   9.173  		dispatch(expr.getLeftArg(), filter);
   9.174  		filter.eq();
   9.175  		dispatch(expr.getRightArg(), filter);
   9.176 -	}
   9.177 +			}
   9.178  
   9.179  	protected abstract void append(GeneralDBSqlIsNull expr, GeneralDBSqlExprBuilder filter)
   9.180 -		throws UnsupportedRdbmsOperatorException;
   9.181 +			throws UnsupportedRdbmsOperatorException;
   9.182  
   9.183  	protected void append(GeneralDBSqlLike expr, GeneralDBSqlExprBuilder filter)
   9.184 -	throws UnsupportedRdbmsOperatorException
   9.185 -	{
   9.186 +			throws UnsupportedRdbmsOperatorException
   9.187 +			{
   9.188  		dispatch(expr.getLeftArg(), filter);
   9.189  		filter.like();
   9.190  		dispatch(expr.getRightArg(), filter);
   9.191 -	}
   9.192 +			}
   9.193  
   9.194  	protected void append(GeneralDBSqlLowerCase expr, GeneralDBSqlExprBuilder filter)
   9.195 -	throws UnsupportedRdbmsOperatorException
   9.196 -	{
   9.197 +			throws UnsupportedRdbmsOperatorException
   9.198 +			{
   9.199  		GeneralDBSqlBracketBuilder lower = filter.lowerCase();
   9.200  		dispatch(expr.getArg(), (GeneralDBSqlExprBuilder) lower);
   9.201  		lower.close();
   9.202 -	}
   9.203 +			}
   9.204  
   9.205  	protected void append(GeneralDBSqlMathExpr expr, GeneralDBSqlExprBuilder filter)
   9.206 -	throws UnsupportedRdbmsOperatorException
   9.207 -	{
   9.208 +			throws UnsupportedRdbmsOperatorException
   9.209 +			{
   9.210  		dispatch(expr.getLeftArg(), filter);
   9.211  		filter.math(expr.getOperator());
   9.212  		dispatch(expr.getRightArg(), filter);
   9.213 -	}
   9.214 +			}
   9.215  
   9.216  	protected abstract void append(GeneralDBSqlNot expr, GeneralDBSqlExprBuilder filter)
   9.217 -		throws UnsupportedRdbmsOperatorException;
   9.218 +			throws UnsupportedRdbmsOperatorException;
   9.219  
   9.220  	protected abstract void append(GeneralDBSqlNull expr, GeneralDBSqlExprBuilder filter);
   9.221 -	
   9.222 +
   9.223  	protected void append(GeneralDBSqlOr expr, GeneralDBSqlExprBuilder filter)
   9.224 -	throws UnsupportedRdbmsOperatorException
   9.225 -	{
   9.226 +			throws UnsupportedRdbmsOperatorException
   9.227 +			{
   9.228  		GeneralDBSqlBracketBuilder open = filter.open();
   9.229  		dispatch(expr.getLeftArg(), (GeneralDBSqlExprBuilder) open);
   9.230  		open.or();
   9.231  		dispatch(expr.getRightArg(), (GeneralDBSqlExprBuilder) open);
   9.232  		open.close();
   9.233 -	}
   9.234 -	
   9.235 +			}
   9.236 +
   9.237  	protected void append(GeneralDBSqlRegex expr, GeneralDBSqlExprBuilder filter)
   9.238 -	throws UnsupportedRdbmsOperatorException
   9.239 -	{
   9.240 +			throws UnsupportedRdbmsOperatorException
   9.241 +			{
   9.242  		GeneralDBSqlRegexBuilder regex = filter.regex();
   9.243  		dispatch(expr.getArg(), regex.value());
   9.244  		dispatch(expr.getPatternArg(), regex.pattern());
   9.245 @@ -443,11 +444,11 @@
   9.246  			dispatch(flags, regex.flags());
   9.247  		}
   9.248  		regex.close();
   9.249 -	}
   9.250 +			}
   9.251  
   9.252  	protected void append(GeneralDBSqlShift expr, GeneralDBSqlExprBuilder filter)
   9.253 -	throws UnsupportedRdbmsOperatorException
   9.254 -	{
   9.255 +			throws UnsupportedRdbmsOperatorException
   9.256 +			{
   9.257  		GeneralDBSqlBracketBuilder mod = filter.mod(expr.getRange());
   9.258  		GeneralDBSqlBracketBuilder open = mod.open();
   9.259  		dispatch(expr.getArg(), (GeneralDBSqlExprBuilder) open);
   9.260 @@ -455,7 +456,7 @@
   9.261  		open.close();
   9.262  		mod.plus(expr.getRange());
   9.263  		mod.close();
   9.264 -	}
   9.265 +			}
   9.266  
   9.267  	protected void append(GeneralDBStringValue expr, GeneralDBSqlExprBuilder filter) {
   9.268  		filter.varchar(expr.getValue());
   9.269 @@ -472,8 +473,8 @@
   9.270  	}
   9.271  
   9.272  	protected void dispatch(GeneralDBSqlExpr expr, GeneralDBSqlExprBuilder filter)
   9.273 -	throws UnsupportedRdbmsOperatorException
   9.274 -	{
   9.275 +			throws UnsupportedRdbmsOperatorException
   9.276 +			{
   9.277  		if (expr instanceof GeneralDBValueColumnBase) {
   9.278  			dispatchValueColumnBase((GeneralDBValueColumnBase)expr, filter);
   9.279  		}
   9.280 @@ -496,11 +497,11 @@
   9.281  		else {
   9.282  			dispatchOther(expr, filter);
   9.283  		}
   9.284 -	}
   9.285 +			}
   9.286  
   9.287  	protected void dispatchBinarySqlOperator(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter)
   9.288 -	throws UnsupportedRdbmsOperatorException
   9.289 -	{
   9.290 +			throws UnsupportedRdbmsOperatorException
   9.291 +			{
   9.292  		if (expr instanceof GeneralDBSqlAnd) {
   9.293  			append((GeneralDBSqlAnd)expr, filter);
   9.294  		}
   9.295 @@ -652,6 +653,9 @@
   9.296  		else if (expr instanceof GeneralDBSqlGeoBuffer) {
   9.297  			append((GeneralDBSqlGeoBuffer)expr, filter);
   9.298  		}
   9.299 +		else if (expr instanceof GeneralDBSqlGeoTransform) {
   9.300 +			append((GeneralDBSqlGeoTransform)expr, filter);
   9.301 +		}
   9.302  		else if (expr instanceof GeneralDBSqlGeoIntersection) {
   9.303  			append((GeneralDBSqlGeoIntersection)expr, filter);
   9.304  		}
   9.305 @@ -672,11 +676,11 @@
   9.306  		else {
   9.307  			throw unsupported(expr);
   9.308  		}
   9.309 -	}
   9.310 +			}
   9.311  
   9.312  	protected void dispatchTripleSqlOperator(TripleGeneralDBOperator expr, GeneralDBSqlExprBuilder filter)
   9.313 -	throws UnsupportedRdbmsOperatorException
   9.314 -	{
   9.315 +			throws UnsupportedRdbmsOperatorException
   9.316 +			{
   9.317  		if (expr instanceof GeneralDBSqlRelate) {
   9.318  			append((GeneralDBSqlRelate)expr, filter);
   9.319  		}
   9.320 @@ -684,24 +688,24 @@
   9.321  		{
   9.322  			throw unsupported(expr);
   9.323  		}
   9.324 -	}
   9.325 +			}
   9.326  
   9.327  
   9.328  
   9.329  	protected void dispatchOther(GeneralDBSqlExpr expr, GeneralDBSqlExprBuilder filter)
   9.330 -	throws UnsupportedRdbmsOperatorException
   9.331 -	{
   9.332 +			throws UnsupportedRdbmsOperatorException
   9.333 +			{
   9.334  		if (expr instanceof GeneralDBSqlCase) {
   9.335  			append((GeneralDBSqlCase)expr, filter);
   9.336  		}
   9.337  		else {
   9.338  			throw unsupported(expr);
   9.339  		}
   9.340 -	}
   9.341 +			}
   9.342  
   9.343  	protected void dispatchSqlConstant(GeneralDBSqlConstant<?> expr, GeneralDBSqlExprBuilder filter)
   9.344 -	throws UnsupportedRdbmsOperatorException
   9.345 -	{
   9.346 +			throws UnsupportedRdbmsOperatorException
   9.347 +			{
   9.348  		if (expr instanceof GeneralDBDoubleValue) {
   9.349  			append((GeneralDBDoubleValue)expr, filter);
   9.350  		}
   9.351 @@ -723,11 +727,11 @@
   9.352  		else {
   9.353  			throw unsupported(expr);
   9.354  		}
   9.355 -	}
   9.356 +			}
   9.357  
   9.358  	protected void dispatchUnarySqlOperator(UnaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter)
   9.359 -	throws UnsupportedRdbmsOperatorException
   9.360 -	{
   9.361 +			throws UnsupportedRdbmsOperatorException
   9.362 +			{
   9.363  		if (expr instanceof GeneralDBSqlAbs) {
   9.364  			append((GeneralDBSqlAbs)expr, filter);
   9.365  		}
   9.366 @@ -783,11 +787,11 @@
   9.367  		else {
   9.368  			throw unsupported(expr);
   9.369  		}
   9.370 -	}
   9.371 +			}
   9.372  
   9.373  	protected void dispatchValueColumnBase(GeneralDBValueColumnBase expr, GeneralDBSqlExprBuilder filter)
   9.374 -	throws UnsupportedRdbmsOperatorException
   9.375 -	{
   9.376 +			throws UnsupportedRdbmsOperatorException
   9.377 +			{
   9.378  		if (expr instanceof GeneralDBBNodeColumn) {
   9.379  			append((GeneralDBBNodeColumn)expr, filter);
   9.380  		}
   9.381 @@ -824,11 +828,11 @@
   9.382  		else {
   9.383  			throw unsupported(expr);
   9.384  		}
   9.385 -	}
   9.386 +			}
   9.387  
   9.388  	protected void from(GeneralDBSqlQueryBuilder subquery, GeneralDBFromItem item)
   9.389 -	throws RdbmsException, UnsupportedRdbmsOperatorException
   9.390 -	{
   9.391 +			throws RdbmsException, UnsupportedRdbmsOperatorException
   9.392 +			{
   9.393  		assert !item.isLeft() : item;
   9.394  		String alias = item.getAlias();
   9.395  		if (item instanceof GeneralDBJoinItem) {
   9.396 @@ -838,7 +842,7 @@
   9.397  		else {
   9.398  			subJoinAndFilter(subquery.from(alias), item);
   9.399  		}
   9.400 -	}
   9.401 +			}
   9.402  
   9.403  	protected String getBNodeAlias(GeneralDBColumnVar var) {
   9.404  		return "b" + getDBName(var);
   9.405 @@ -888,8 +892,8 @@
   9.406  	}
   9.407  
   9.408  	protected void join(GeneralDBSqlJoinBuilder query, GeneralDBFromItem join)
   9.409 -	throws RdbmsException, UnsupportedRdbmsOperatorException
   9.410 -	{
   9.411 +			throws RdbmsException, UnsupportedRdbmsOperatorException
   9.412 +			{
   9.413  		String alias = join.getAlias();
   9.414  		if (join instanceof GeneralDBJoinItem) {
   9.415  			String tableName = ((GeneralDBJoinItem)join).getTableName();
   9.416 @@ -908,190 +912,193 @@
   9.417  				subJoinAndFilter(query.join(alias), join);
   9.418  			}
   9.419  		}
   9.420 -	}
   9.421 +			}
   9.422  
   9.423  	protected abstract GeneralDBSqlJoinBuilder subJoinAndFilter(GeneralDBSqlJoinBuilder query, GeneralDBFromItem from)
   9.424 -	throws RdbmsException, UnsupportedRdbmsOperatorException;
   9.425 -	
   9.426 +			throws RdbmsException, UnsupportedRdbmsOperatorException;
   9.427 +
   9.428  	protected UnsupportedRdbmsOperatorException unsupported(Object object)
   9.429 -	throws UnsupportedRdbmsOperatorException
   9.430 -	{
   9.431 +			throws UnsupportedRdbmsOperatorException
   9.432 +			{
   9.433  		return new UnsupportedRdbmsOperatorException(object.toString());
   9.434 -	}
   9.435 +			}
   9.436  
   9.437  	//FIXME my addition from here on
   9.438  	public abstract GeneralDBQueryBuilder construct(GeneralDBSqlExpr expr)
   9.439 -	throws UnsupportedRdbmsOperatorException;
   9.440 +			throws UnsupportedRdbmsOperatorException;
   9.441  
   9.442  	//Spatial Relationship Functions
   9.443  	protected abstract void append(GeneralDBSqlAnyInteract expr, GeneralDBSqlExprBuilder filter)
   9.444 -	throws UnsupportedRdbmsOperatorException;
   9.445 +			throws UnsupportedRdbmsOperatorException;
   9.446  
   9.447  	protected abstract void append(GeneralDBSqlContains expr, GeneralDBSqlExprBuilder filter)
   9.448 -	throws UnsupportedRdbmsOperatorException;
   9.449 +			throws UnsupportedRdbmsOperatorException;
   9.450  
   9.451  	protected abstract void append(GeneralDBSqlEqualsSpatial expr, GeneralDBSqlExprBuilder filter)
   9.452 -	throws UnsupportedRdbmsOperatorException;
   9.453 +			throws UnsupportedRdbmsOperatorException;
   9.454  
   9.455  	protected abstract void append(GeneralDBSqlInside expr, GeneralDBSqlExprBuilder filter)
   9.456 -	throws UnsupportedRdbmsOperatorException;
   9.457 +			throws UnsupportedRdbmsOperatorException;
   9.458  
   9.459  	protected abstract void append(GeneralDBSqlCovers expr, GeneralDBSqlExprBuilder filter)
   9.460 -	throws UnsupportedRdbmsOperatorException;
   9.461 +			throws UnsupportedRdbmsOperatorException;
   9.462  
   9.463  	protected abstract void append(GeneralDBSqlCoveredBy expr, GeneralDBSqlExprBuilder filter)
   9.464 -	throws UnsupportedRdbmsOperatorException;
   9.465 +			throws UnsupportedRdbmsOperatorException;
   9.466  
   9.467  	protected abstract void append(GeneralDBSqlTouch expr, GeneralDBSqlExprBuilder filter)
   9.468 -	throws UnsupportedRdbmsOperatorException;
   9.469 +			throws UnsupportedRdbmsOperatorException;
   9.470  
   9.471  	protected abstract void append(GeneralDBSqlOverlap expr, GeneralDBSqlExprBuilder filter)
   9.472 -	throws UnsupportedRdbmsOperatorException;
   9.473 +			throws UnsupportedRdbmsOperatorException;
   9.474  
   9.475  	protected abstract void append(GeneralDBSqlDisjoint expr, GeneralDBSqlExprBuilder filter)
   9.476 -	throws UnsupportedRdbmsOperatorException;
   9.477 +			throws UnsupportedRdbmsOperatorException;
   9.478  
   9.479  	protected abstract void append(GeneralDBSqlRelate expr, GeneralDBSqlExprBuilder filter)
   9.480 -	throws UnsupportedRdbmsOperatorException;
   9.481 -	
   9.482 +			throws UnsupportedRdbmsOperatorException;
   9.483 +
   9.484  	protected abstract void append(GeneralDBSqlLeft expr, GeneralDBSqlExprBuilder filter)
   9.485 -	throws UnsupportedRdbmsOperatorException;
   9.486 -	
   9.487 +			throws UnsupportedRdbmsOperatorException;
   9.488 +
   9.489  	protected abstract void append(GeneralDBSqlRight expr, GeneralDBSqlExprBuilder filter)
   9.490 -	throws UnsupportedRdbmsOperatorException;
   9.491 -	
   9.492 +			throws UnsupportedRdbmsOperatorException;
   9.493 +
   9.494  	protected abstract void append(GeneralDBSqlAbove expr, GeneralDBSqlExprBuilder filter)
   9.495 -	throws UnsupportedRdbmsOperatorException;
   9.496 -	
   9.497 +			throws UnsupportedRdbmsOperatorException;
   9.498 +
   9.499  	protected abstract void append(GeneralDBSqlBelow expr, GeneralDBSqlExprBuilder filter)
   9.500 -	throws UnsupportedRdbmsOperatorException;
   9.501 +			throws UnsupportedRdbmsOperatorException;
   9.502  
   9.503  	//GeoSPARQL - Spatial Relationship Functions 
   9.504  	//Simple Features
   9.505  	protected abstract void append(GeneralDBSqlSF_Contains expr, GeneralDBSqlExprBuilder filter)
   9.506 -	throws UnsupportedRdbmsOperatorException;
   9.507 +			throws UnsupportedRdbmsOperatorException;
   9.508  
   9.509  	protected abstract void append(GeneralDBSqlSF_Crosses expr, GeneralDBSqlExprBuilder filter)
   9.510 -	throws UnsupportedRdbmsOperatorException;
   9.511 +			throws UnsupportedRdbmsOperatorException;
   9.512  
   9.513  	protected abstract void append(GeneralDBSqlSF_Disjoint expr, GeneralDBSqlExprBuilder filter)
   9.514 -	throws UnsupportedRdbmsOperatorException;
   9.515 +			throws UnsupportedRdbmsOperatorException;
   9.516  
   9.517  	protected abstract void append(GeneralDBSqlSF_Equals expr, GeneralDBSqlExprBuilder filter)
   9.518 -	throws UnsupportedRdbmsOperatorException;
   9.519 +			throws UnsupportedRdbmsOperatorException;
   9.520  
   9.521  	protected abstract void append(GeneralDBSqlSF_Intersects expr, GeneralDBSqlExprBuilder filter)
   9.522 -	throws UnsupportedRdbmsOperatorException;
   9.523 +			throws UnsupportedRdbmsOperatorException;
   9.524  
   9.525  	protected abstract void append(GeneralDBSqlSF_Overlaps expr, GeneralDBSqlExprBuilder filter)
   9.526 -	throws UnsupportedRdbmsOperatorException;
   9.527 +			throws UnsupportedRdbmsOperatorException;
   9.528  
   9.529  	protected abstract void append(GeneralDBSqlSF_Touches expr, GeneralDBSqlExprBuilder filter)
   9.530 -	throws UnsupportedRdbmsOperatorException;
   9.531 +			throws UnsupportedRdbmsOperatorException;
   9.532  
   9.533  	protected abstract void append(GeneralDBSqlSF_Within expr, GeneralDBSqlExprBuilder filter)
   9.534 -	throws UnsupportedRdbmsOperatorException;
   9.535 +			throws UnsupportedRdbmsOperatorException;
   9.536  
   9.537  	//Egenhofer
   9.538  	protected abstract void append(GeneralDBSqlEgenhofer_CoveredBy expr, GeneralDBSqlExprBuilder filter)
   9.539 -	throws UnsupportedRdbmsOperatorException;
   9.540 -	
   9.541 +			throws UnsupportedRdbmsOperatorException;
   9.542 +
   9.543  	protected abstract void append(GeneralDBSqlEgenhofer_Covers expr, GeneralDBSqlExprBuilder filter)
   9.544 -	throws UnsupportedRdbmsOperatorException;
   9.545 -	
   9.546 +			throws UnsupportedRdbmsOperatorException;
   9.547 +
   9.548  	protected abstract void append(GeneralDBSqlEgenhofer_Contains expr, GeneralDBSqlExprBuilder filter)
   9.549 -	throws UnsupportedRdbmsOperatorException;
   9.550 -	
   9.551 +			throws UnsupportedRdbmsOperatorException;
   9.552 +
   9.553  	protected abstract void append(GeneralDBSqlEgenhofer_Disjoint expr, GeneralDBSqlExprBuilder filter)
   9.554 -	throws UnsupportedRdbmsOperatorException;
   9.555 -	
   9.556 +			throws UnsupportedRdbmsOperatorException;
   9.557 +
   9.558  	protected abstract void append(GeneralDBSqlEgenhofer_Equals expr, GeneralDBSqlExprBuilder filter)
   9.559 -	throws UnsupportedRdbmsOperatorException;
   9.560 -	
   9.561 +			throws UnsupportedRdbmsOperatorException;
   9.562 +
   9.563  	protected abstract void append(GeneralDBSqlEgenhofer_Inside expr, GeneralDBSqlExprBuilder filter)
   9.564 -	throws UnsupportedRdbmsOperatorException;
   9.565 -	
   9.566 +			throws UnsupportedRdbmsOperatorException;
   9.567 +
   9.568  	protected abstract void append(GeneralDBSqlEgenhofer_Meet expr, GeneralDBSqlExprBuilder filter)
   9.569 -	throws UnsupportedRdbmsOperatorException;
   9.570 -	
   9.571 +			throws UnsupportedRdbmsOperatorException;
   9.572 +
   9.573  	protected abstract void append(GeneralDBSqlEgenhofer_Overlap expr, GeneralDBSqlExprBuilder filter)
   9.574 -	throws UnsupportedRdbmsOperatorException;
   9.575 -	
   9.576 +			throws UnsupportedRdbmsOperatorException;
   9.577 +
   9.578  	//RCC8
   9.579  	protected abstract void append(GeneralDBSqlRCC8_Dc expr, GeneralDBSqlExprBuilder filter)
   9.580 -	throws UnsupportedRdbmsOperatorException;
   9.581 -	
   9.582 +			throws UnsupportedRdbmsOperatorException;
   9.583 +
   9.584  	protected abstract void append(GeneralDBSqlRCC8_Eq expr, GeneralDBSqlExprBuilder filter)
   9.585 -	throws UnsupportedRdbmsOperatorException;
   9.586 -	
   9.587 +			throws UnsupportedRdbmsOperatorException;
   9.588 +
   9.589  	protected abstract void append(GeneralDBSqlRCC8_Ec expr, GeneralDBSqlExprBuilder filter)
   9.590 -	throws UnsupportedRdbmsOperatorException;
   9.591 -	
   9.592 +			throws UnsupportedRdbmsOperatorException;
   9.593 +
   9.594  	protected abstract void append(GeneralDBSqlRCC8_Po expr, GeneralDBSqlExprBuilder filter)
   9.595 -	throws UnsupportedRdbmsOperatorException;
   9.596 -	
   9.597 +			throws UnsupportedRdbmsOperatorException;
   9.598 +
   9.599  	protected abstract void append(GeneralDBSqlRCC8_Tppi expr, GeneralDBSqlExprBuilder filter)
   9.600 -	throws UnsupportedRdbmsOperatorException;
   9.601 -	
   9.602 +			throws UnsupportedRdbmsOperatorException;
   9.603 +
   9.604  	protected abstract void append(GeneralDBSqlRCC8_Tpp expr, GeneralDBSqlExprBuilder filter)
   9.605 -	throws UnsupportedRdbmsOperatorException;
   9.606 -	
   9.607 +			throws UnsupportedRdbmsOperatorException;
   9.608 +
   9.609  	protected abstract void append(GeneralDBSqlRCC8_Ntpp expr, GeneralDBSqlExprBuilder filter)
   9.610 -	throws UnsupportedRdbmsOperatorException;
   9.611 -	
   9.612 +			throws UnsupportedRdbmsOperatorException;
   9.613 +
   9.614  	protected abstract void append(GeneralDBSqlRCC8_Ntppi expr, GeneralDBSqlExprBuilder filter)
   9.615 -	throws UnsupportedRdbmsOperatorException;
   9.616 +			throws UnsupportedRdbmsOperatorException;
   9.617  
   9.618  	//Spatial Construct Functions
   9.619  	protected abstract void append(GeneralDBSqlGeoUnion expr, GeneralDBSqlExprBuilder filter)
   9.620 -	throws UnsupportedRdbmsOperatorException;
   9.621 +			throws UnsupportedRdbmsOperatorException;
   9.622  
   9.623  	protected abstract void append(GeneralDBSqlGeoBuffer expr, GeneralDBSqlExprBuilder filter)
   9.624 -	throws UnsupportedRdbmsOperatorException;
   9.625 +			throws UnsupportedRdbmsOperatorException;
   9.626 +
   9.627 +	protected abstract void append(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   9.628 +			throws UnsupportedRdbmsOperatorException;
   9.629  
   9.630  	protected abstract void append(GeneralDBSqlGeoEnvelope expr, GeneralDBSqlExprBuilder filter)
   9.631 -	throws UnsupportedRdbmsOperatorException;
   9.632 +			throws UnsupportedRdbmsOperatorException;
   9.633  
   9.634  	protected abstract void append(GeneralDBSqlGeoConvexHull expr, GeneralDBSqlExprBuilder filter)
   9.635 -	throws UnsupportedRdbmsOperatorException;
   9.636 +			throws UnsupportedRdbmsOperatorException;
   9.637  
   9.638  	protected abstract void append(GeneralDBSqlGeoBoundary expr, GeneralDBSqlExprBuilder filter)
   9.639 -	throws UnsupportedRdbmsOperatorException;
   9.640 +			throws UnsupportedRdbmsOperatorException;
   9.641  
   9.642  	protected abstract void append(GeneralDBSqlGeoIntersection expr, GeneralDBSqlExprBuilder filter)
   9.643 -	throws UnsupportedRdbmsOperatorException;
   9.644 +			throws UnsupportedRdbmsOperatorException;
   9.645  
   9.646  	protected abstract void append(GeneralDBSqlGeoDifference expr, GeneralDBSqlExprBuilder filter)
   9.647 -	throws UnsupportedRdbmsOperatorException;
   9.648 +			throws UnsupportedRdbmsOperatorException;
   9.649  
   9.650  	protected abstract void append(GeneralDBSqlGeoSymDifference expr, GeneralDBSqlExprBuilder filter)
   9.651 -	throws UnsupportedRdbmsOperatorException;
   9.652 +			throws UnsupportedRdbmsOperatorException;
   9.653  
   9.654  	//Spatial Metric Functions
   9.655  	protected abstract void append(GeneralDBSqlGeoDistance expr, GeneralDBSqlExprBuilder filter)
   9.656 -	throws UnsupportedRdbmsOperatorException;
   9.657 +			throws UnsupportedRdbmsOperatorException;
   9.658  
   9.659  	protected abstract void append(GeneralDBSqlGeoArea expr, GeneralDBSqlExprBuilder filter)
   9.660 -	throws UnsupportedRdbmsOperatorException;
   9.661 +			throws UnsupportedRdbmsOperatorException;
   9.662  
   9.663  	//Spatial Property Functions
   9.664  	protected abstract void append(GeneralDBSqlGeoDimension expr, GeneralDBSqlExprBuilder filter)
   9.665 -	throws UnsupportedRdbmsOperatorException;
   9.666 +			throws UnsupportedRdbmsOperatorException;
   9.667  
   9.668  	protected abstract void append(GeneralDBSqlGeoGeometryType expr, GeneralDBSqlExprBuilder filter)
   9.669 -	throws UnsupportedRdbmsOperatorException;
   9.670 +			throws UnsupportedRdbmsOperatorException;
   9.671  
   9.672  	protected abstract void append(GeneralDBSqlGeoAsText expr, GeneralDBSqlExprBuilder filter)
   9.673 -	throws UnsupportedRdbmsOperatorException;
   9.674 +			throws UnsupportedRdbmsOperatorException;
   9.675  
   9.676  	protected abstract void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter)
   9.677 -	throws UnsupportedRdbmsOperatorException;
   9.678 +			throws UnsupportedRdbmsOperatorException;
   9.679  
   9.680  	protected abstract void append(GeneralDBSqlGeoIsSimple expr, GeneralDBSqlExprBuilder filter)
   9.681 -	throws UnsupportedRdbmsOperatorException;
   9.682 +			throws UnsupportedRdbmsOperatorException;
   9.683  
   9.684  	protected abstract void append(GeneralDBSqlGeoIsEmpty expr, GeneralDBSqlExprBuilder filter)
   9.685 -	throws UnsupportedRdbmsOperatorException;
   9.686 +			throws UnsupportedRdbmsOperatorException;
   9.687  
   9.688  
   9.689  	/**
   9.690 @@ -1117,8 +1124,8 @@
   9.691  	protected abstract String appendWKT(GeneralDBSqlExpr expr, GeneralDBSqlExprBuilder filter);
   9.692  
   9.693  	protected void appendConstructFunction(GeneralDBSqlExpr constr, GeneralDBSqlExprBuilder filter) 
   9.694 -	throws UnsupportedRdbmsOperatorException
   9.695 -	{
   9.696 +			throws UnsupportedRdbmsOperatorException
   9.697 +			{
   9.698  		if(constr instanceof GeneralDBSqlGeoUnion)
   9.699  		{
   9.700  			append((GeneralDBSqlGeoUnion)constr, filter);
   9.701 @@ -1127,6 +1134,10 @@
   9.702  		{
   9.703  			append((GeneralDBSqlGeoBuffer)constr, filter);
   9.704  		}
   9.705 +		else if(constr instanceof GeneralDBSqlGeoTransform)
   9.706 +		{
   9.707 +			append((GeneralDBSqlGeoTransform)constr, filter);
   9.708 +		}
   9.709  		else if(constr instanceof GeneralDBSqlGeoEnvelope)
   9.710  		{
   9.711  			append((GeneralDBSqlGeoEnvelope)constr, filter);
   9.712 @@ -1152,11 +1163,11 @@
   9.713  			append((GeneralDBSqlGeoSymDifference)constr, filter);
   9.714  		}
   9.715  
   9.716 -	}
   9.717 +			}
   9.718  
   9.719  	protected void appendMetricFunction(GeneralDBSqlExpr constr, GeneralDBSqlExprBuilder filter) 
   9.720 -	throws UnsupportedRdbmsOperatorException
   9.721 -	{
   9.722 +			throws UnsupportedRdbmsOperatorException
   9.723 +			{
   9.724  		if(constr instanceof GeneralDBSqlGeoDistance)
   9.725  		{
   9.726  			append((GeneralDBSqlGeoDistance)constr, filter);
   9.727 @@ -1167,19 +1178,19 @@
   9.728  		}
   9.729  
   9.730  
   9.731 -	}
   9.732 +			}
   9.733  
   9.734  	protected void appendCastToDouble(GeneralDBSqlExprBuilder filter)
   9.735  	{
   9.736  		filter.doubleCast();
   9.737  	}
   9.738 -
   9.739 -
   9.740 +	
   9.741 +	
   9.742  
   9.743  	//GeoSPARQL
   9.744  	//XXX
   9.745 -	
   9.746 +
   9.747  	protected abstract void appendRelate(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, char[] intersectionPattern)
   9.748 -	throws UnsupportedRdbmsOperatorException;
   9.749 -	
   9.750 +			throws UnsupportedRdbmsOperatorException;
   9.751 +
   9.752  }
    10.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBSqlExprBuilder.java	Wed Mar 14 17:02:40 2012 +0200
    10.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBSqlExprBuilder.java	Thu Mar 15 18:33:05 2012 +0200
    10.3 @@ -310,6 +310,18 @@
    10.4  	public void doubleCast() {
    10.5  		where.append(" :: DOUBLE PRECISION ");
    10.6  	}
    10.7 +	
    10.8 +	public void keepSRID_part1() {
    10.9 +		where.append(" SUBSTRING(");
   10.10 +	}
   10.11 +	
   10.12 +	public void keepSRID_part2() {
   10.13 +		where.append(" , position('0' in ");
   10.14 +	}
   10.15 +	
   10.16 +	public void keepSRID_part3() {
   10.17 +		where.append(" ) + 2) ");
   10.18 +	}
   10.19  
   10.20  	//	public void overlap() {
   10.21  	//
    11.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/model/GeneralDBPolyhedron.java	Wed Mar 14 17:02:40 2012 +0200
    11.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/model/GeneralDBPolyhedron.java	Thu Mar 15 18:33:05 2012 +0200
    11.3 @@ -33,21 +33,21 @@
    11.4  		this.datatype = datatype;
    11.5  	}
    11.6  
    11.7 -//	public GeneralDBPolyhedron(Number id, Integer version, URI datatype, String polyhedron) throws IOException, ClassNotFoundException {
    11.8 -//		super(id, version);
    11.9 -//
   11.10 -//		try {
   11.11 -//			this.polyhedron = new StrabonPolyhedron(polyhedron);
   11.12 -//		} catch (ParseException e) {
   11.13 -//
   11.14 -//			e.printStackTrace();
   11.15 -//		} catch (Exception e) {
   11.16 -//
   11.17 -//			e.printStackTrace();
   11.18 -//		}
   11.19 -//		setPolyhedronStringRep(this.polyhedron);
   11.20 -//		this.datatype = datatype;
   11.21 -//	}
   11.22 +	//	public GeneralDBPolyhedron(Number id, Integer version, URI datatype, String polyhedron) throws IOException, ClassNotFoundException {
   11.23 +	//		super(id, version);
   11.24 +	//
   11.25 +	//		try {
   11.26 +	//			this.polyhedron = new StrabonPolyhedron(polyhedron);
   11.27 +	//		} catch (ParseException e) {
   11.28 +	//
   11.29 +	//			e.printStackTrace();
   11.30 +	//		} catch (Exception e) {
   11.31 +	//
   11.32 +	//			e.printStackTrace();
   11.33 +	//		}
   11.34 +	//		setPolyhedronStringRep(this.polyhedron);
   11.35 +	//		this.datatype = datatype;
   11.36 +	//	}
   11.37  	/**
   11.38  	 * METHODS
   11.39  	 */
   11.40 @@ -90,17 +90,18 @@
   11.41  
   11.42  	@Override
   11.43  	public String toString() {
   11.44 -		return new String("\""+this.polyhedronStringRep+"\"" + "^^<" + 
   11.45 +		return new String("\""+this.polyhedronStringRep+";http://www.opengis.net/def/crs/EPSG/0/"
   11.46 +				+this.getPolyhedron().getGeometry().getSRID()+"\"" + "^^<" + 
   11.47  				((StrabonPolyhedron.EnableConstraintRepresentation)  ? 
   11.48  						StrabonPolyhedron.stRDFSemiLinearPointset : StrabonPolyhedron.ogcGeometry)
   11.49  						+">");
   11.50  	}
   11.51 -	
   11.52 +
   11.53  	@Override
   11.54  	public int hashCode() {
   11.55  		return polyhedronStringRep.hashCode();
   11.56  	}
   11.57 -	
   11.58 +
   11.59  	@Override
   11.60  	public boolean equals(Object other) {
   11.61  
   11.62 @@ -110,7 +111,7 @@
   11.63  			{
   11.64  				return true;
   11.65  			}
   11.66 -			
   11.67 +
   11.68  		}
   11.69  		return false;
   11.70  	}
    12.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Wed Mar 14 17:02:40 2012 +0200
    12.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizer.java	Thu Mar 15 18:33:05 2012 +0200
    12.3 @@ -71,6 +71,7 @@
    12.4  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.aggregate.ExtentFunc;
    12.5  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BufferFunc;
    12.6  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.EnvelopeFunc;
    12.7 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.TransformFunc;
    12.8  import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.UnionFunc;
    12.9  import org.openrdf.query.algebra.evaluation.iterator.SPARQLMinusIteration;
   12.10  import org.openrdf.sail.generaldb.GeneralDBValueFactory;
   12.11 @@ -891,7 +892,7 @@
   12.12  				argNo++;
   12.13  				if(arg instanceof Var)
   12.14  				{
   12.15 -					if(!(function instanceof BufferFunc) || argNo!=2 )
   12.16 +					if((!(function instanceof BufferFunc)&&!(function instanceof TransformFunc)) || argNo!=2 )
   12.17  					{
   12.18  						//The variable's name is not in the list yet
   12.19  						if(!geoNames.contains(((Var) arg).getName()))
    13.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizerFactory.java	Wed Mar 14 17:02:40 2012 +0200
    13.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/optimizers/GeneralDBSelectQueryOptimizerFactory.java	Thu Mar 15 18:33:05 2012 +0200
    13.3 @@ -59,11 +59,13 @@
    13.4  		sql.setDatatypeExprFactory(datatype);
    13.5  		sql.setLabelExprFactory(label);
    13.6  		sql.setLanguageExprFactory(language);
    13.7 +		sql.setURIExprFactory(uri);
    13.8 +		
    13.9  		sql.setNumericExprFactory(new GeneralDBNumericExprFactory());
   13.10  		sql.setTimeExprFactory(new GeneralDBTimeExprFactory());
   13.11  		sql.setZonedExprFactory(new GeneralDBZonedExprFactory(ids));
   13.12  		sql.setHashExprFactory(new GeneralDBHashExprFactory(vf));
   13.13 -		sql.setURIExprFactory(uri);
   13.14 +		
   13.15  		label.setSqlExprFactory(sql);
   13.16  		uri.setSqlExprFactory(sql);
   13.17  		bool.setSqlExprFactory(sql);
    14.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Wed Mar 14 17:02:40 2012 +0200
    14.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java	Thu Mar 15 18:33:05 2012 +0200
    14.3 @@ -39,6 +39,7 @@
    14.4  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIsSimple;
    14.5  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSrid;
    14.6  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSymDifference;
    14.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoTransform;
    14.8  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoUnion;
    14.9  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlInside;
   14.10  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlIsNull;
   14.11 @@ -122,6 +123,7 @@
   14.12  		ST_Intersection,
   14.13  		ST_Difference,
   14.14  		ST_Buffer,
   14.15 +		ST_Transform,
   14.16  		ST_SymDifference,
   14.17  		//Spatial Constructs - Unary
   14.18  		ST_Envelope,
   14.19 @@ -639,6 +641,13 @@
   14.20  	{
   14.21  		appendMonetDBSpatialFunctionBinary(expr, filter, SpatialFunctionsMonetDB.ST_Buffer);
   14.22  	}
   14.23 +	
   14.24 +	@Override
   14.25 +	protected void append(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   14.26 +	throws UnsupportedRdbmsOperatorException
   14.27 +	{
   14.28 +		appendMonetDBSpatialFunctionBinary(expr, filter, SpatialFunctionsMonetDB.ST_Transform);
   14.29 +	}
   14.30  
   14.31  	@Override
   14.32  	protected void append(GeneralDBSqlGeoEnvelope expr, GeneralDBSqlExprBuilder filter)
   14.33 @@ -764,6 +773,7 @@
   14.34  	}
   14.35  
   14.36  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   14.37 +	
   14.38  	protected void appendMonetDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsMonetDB func)
   14.39  	throws UnsupportedRdbmsOperatorException
   14.40  	{
   14.41 @@ -779,6 +789,7 @@
   14.42  		{
   14.43  			switch(func)
   14.44  			{
   14.45 +			//XXX Careful: ST_Transform support MISSING!!!
   14.46  			case ST_Difference: filter.appendFunction("Difference"); break;
   14.47  			case ST_Intersection: filter.appendFunction("Intersection"); break;
   14.48  			case ST_Union: filter.appendFunction("\"Union\""); break;
    15.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Wed Mar 14 17:02:40 2012 +0200
    15.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java	Thu Mar 15 18:33:05 2012 +0200
    15.3 @@ -38,6 +38,7 @@
    15.4  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIsSimple;
    15.5  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSrid;
    15.6  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSymDifference;
    15.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoTransform;
    15.8  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoUnion;
    15.9  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlInside;
   15.10  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlIsNull;
   15.11 @@ -55,6 +56,7 @@
   15.12  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialProperty;
   15.13  import org.openrdf.sail.generaldb.algebra.GeneralDBSqlTouch;
   15.14  import org.openrdf.sail.generaldb.algebra.GeneralDBStringValue;
   15.15 +import org.openrdf.sail.generaldb.algebra.GeneralDBURIColumn;
   15.16  import org.openrdf.sail.generaldb.algebra.GeneralDBUnionItem;
   15.17  import org.openrdf.sail.generaldb.algebra.base.BinaryGeneralDBOperator;
   15.18  import org.openrdf.sail.generaldb.algebra.base.GeneralDBFromItem;
   15.19 @@ -119,6 +121,7 @@
   15.20  		ST_Intersection, 
   15.21  		ST_Difference,
   15.22  		ST_Buffer,
   15.23 +		ST_Transform,
   15.24  		ST_SymDifference,
   15.25  		//Spatial Constructs - Unary
   15.26  		ST_Envelope,
   15.27 @@ -603,6 +606,14 @@
   15.28  		appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Buffer);
   15.29  			}
   15.30  
   15.31 +	//XXX Different Behavior
   15.32 +	@Override
   15.33 +	protected void append(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   15.34 +			throws UnsupportedRdbmsOperatorException
   15.35 +			{
   15.36 +		appendTransformFunc(expr, filter);
   15.37 +			}
   15.38 +
   15.39  	@Override
   15.40  	protected void append(GeneralDBSqlGeoEnvelope expr, GeneralDBSqlExprBuilder filter)
   15.41  			throws UnsupportedRdbmsOperatorException
   15.42 @@ -1015,15 +1026,18 @@
   15.43  		filter.closeBracket();
   15.44  	}
   15.45  	//	
   15.46 +
   15.47  	//Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
   15.48 -	protected void appendGeneralDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
   15.49 +	protected void appendTransformFunc(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter)
   15.50  			throws UnsupportedRdbmsOperatorException
   15.51 -	{
   15.52 +			{
   15.53  		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
   15.54  		boolean sridNeeded = true;
   15.55  		//XXX Incorporating SRID
   15.56  		String sridExpr = null;
   15.57 -		
   15.58 +
   15.59 +		filter.openBracket();
   15.60 +		filter.appendFunction("ST_Transform");
   15.61  		filter.openBracket();
   15.62  
   15.63  		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
   15.64 @@ -1040,7 +1054,140 @@
   15.65  		}
   15.66  		else
   15.67  		{
   15.68 +			GeneralDBSqlExpr tmp = expr;
   15.69 +			if(tmp instanceof GeneralDBSqlSpatialConstructBinary && tmp.getParentNode() == null)
   15.70 +			{
   15.71 +				while(true)
   15.72 +				{
   15.73 +					GeneralDBSqlExpr child;
   15.74 +
   15.75 +					if(tmp instanceof BinaryGeneralDBOperator)
   15.76 +					{
   15.77 +						child = ((BinaryGeneralDBOperator) tmp).getLeftArg();
   15.78 +					}
   15.79 +					else //(tmp instanceof UnaryGeneralDBOperator)
   15.80 +					{
   15.81 +						child = ((UnaryGeneralDBOperator) tmp).getArg();
   15.82 +					}
   15.83 +
   15.84 +					tmp = child;
   15.85 +					if(tmp instanceof GeneralDBLabelColumn)
   15.86 +					{
   15.87 +						//Reached the innermost left var -> need to capture its SRID
   15.88 +						String alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar());
   15.89 +						alias=alias+".srid";
   15.90 +						sridExpr = alias;
   15.91 +						//						((GeneralDBSqlSpatialConstructBinary)expr).setSrid(alias);
   15.92 +						break;
   15.93 +					}
   15.94 +					else if (tmp instanceof GeneralDBStringValue) //Constant!!
   15.95 +					{
   15.96 +						sridNeeded  = false;
   15.97 +						break;
   15.98 +					}
   15.99 +
  15.100 +				}
  15.101 +				if(sridNeeded)
  15.102 +				{
  15.103 +					filter.appendFunction("ST_Transform");
  15.104 +					filter.openBracket();
  15.105 +				}
  15.106 +			}
  15.107 +
  15.108 +			if(expr.getLeftArg() instanceof GeneralDBStringValue)
  15.109 +			{
  15.110 +				appendWKT(expr.getLeftArg(),filter);
  15.111 +			}
  15.112 +			else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary)
  15.113 +			{
  15.114 +				appendConstructFunction(expr.getLeftArg(), filter);
  15.115 +			}
  15.116 +			else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary)
  15.117 +			{
  15.118 +				appendConstructFunction(expr.getLeftArg(), filter);
  15.119 +			}
  15.120 +			else if(expr.getLeftArg() instanceof GeneralDBSqlCase)
  15.121 +			{
  15.122 +				GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getLeftArg()).getEntries().get(0).getResult();
  15.123 +				appendMBB(onlyLabel,filter); 
  15.124 +			}
  15.125 +			else
  15.126 +			{
  15.127 +				appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter);
  15.128 +			}
  15.129  			
  15.130 +			//SRID Support
  15.131 +			if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
  15.132 +			{
  15.133 +				filter.appendComma();
  15.134 +				//filter.append(((GeneralDBSqlSpatialConstructBinary)expr).getSrid());
  15.135 +				filter.append(sridExpr);
  15.136 +				filter.closeBracket();
  15.137 +			}
  15.138 +			
  15.139 +			filter.appendComma();
  15.140 +
  15.141 +			if(expr.getRightArg() instanceof GeneralDBURIColumn) //case met in transform!
  15.142 +			{
  15.143 +				//XXX This case would be met if we recovered the SRID URI from the db!!!
  15.144 +				//Need to set sridExpr to the value of this new URI, otherwise the appended uri
  15.145 +				//to the spatial object will be the wrong one!!!! (Seee following case)
  15.146 +				filter.keepSRID_part1();
  15.147 +				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
  15.148 +				filter.keepSRID_part2();
  15.149 +				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
  15.150 +				filter.keepSRID_part3();
  15.151 +			}
  15.152 +			else if(expr.getRightArg() instanceof GeneralDBStringValue)
  15.153 +			{
  15.154 +				String unparsedSRID = ((GeneralDBStringValue)expr.getRightArg()).getValue();
  15.155 +//				int srid = Integer.parseInt(unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1));
  15.156 +				sridExpr = unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1);
  15.157 +				filter.append(sridExpr);
  15.158 +				filter.closeBracket();
  15.159 +			}
  15.160 +
  15.161 +			
  15.162 +		}
  15.163 +		filter.closeBracket();
  15.164 +		//In this case, SRID is the one that has been provided by the user!!
  15.165 +		if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null)
  15.166 +		{
  15.167 +			filter.appendComma();
  15.168 +			filter.append(sridExpr);
  15.169 +		}
  15.170 +
  15.171 +			}
  15.172 +
  15.173 +
  15.174 +
  15.175 +	//Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 
  15.176 +	//EXCEPT ST_Transform!!!
  15.177 +	protected void appendGeneralDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func)
  15.178 +			throws UnsupportedRdbmsOperatorException
  15.179 +			{
  15.180 +		//In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))")
  15.181 +		boolean sridNeeded = true;
  15.182 +		//XXX Incorporating SRID
  15.183 +		String sridExpr = null;
  15.184 +
  15.185 +		filter.openBracket();
  15.186 +
  15.187 +		boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
  15.188 +		boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull");
  15.189 +
  15.190 +		if(check1)
  15.191 +		{
  15.192 +			this.append((GeneralDBSqlNull)expr.getLeftArg(), filter);
  15.193 +
  15.194 +		}
  15.195 +		else if(check2)
  15.196 +		{
  15.197 +			this.append((GeneralDBSqlNull)expr.getRightArg(), filter);
  15.198 +		}
  15.199 +		else
  15.200 +		{
  15.201 +
  15.202  			GeneralDBSqlExpr tmp = expr;
  15.203  			if(tmp instanceof GeneralDBSqlSpatialConstructBinary && tmp.getParentNode() == null)
  15.204  			{
  15.205 @@ -1150,6 +1297,14 @@
  15.206  			{
  15.207  				append(((GeneralDBNumericColumn)expr.getRightArg()), filter);
  15.208  			}
  15.209 +			else if(expr.getRightArg() instanceof GeneralDBURIColumn) //case met in transform!
  15.210 +			{
  15.211 +				filter.keepSRID_part1();
  15.212 +				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
  15.213 +				filter.keepSRID_part2();
  15.214 +				append(((GeneralDBURIColumn)expr.getRightArg()), filter);
  15.215 +				filter.keepSRID_part3();
  15.216 +			}
  15.217  			//case met in buffer when in select -> buffer(?spatial,?thematic)
  15.218  			else if(expr.getRightArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getRightArg()).isSpatial())
  15.219  			{
  15.220 @@ -1188,7 +1343,7 @@
  15.221  			filter.appendComma();
  15.222  			filter.append(sridExpr);
  15.223  		}
  15.224 -		
  15.225 +
  15.226  			}
  15.227  
  15.228  	//Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1) 
  15.229 @@ -1307,7 +1462,7 @@
  15.230  			}
  15.231  
  15.232  			filter.closeBracket();
  15.233 -//			//SRID Support
  15.234 +			//			//SRID Support
  15.235  			if(sridNeeded)
  15.236  			{
  15.237  				if(expr instanceof GeneralDBSqlSpatialConstructUnary && expr.getParentNode() == null)
  15.238 @@ -1328,7 +1483,7 @@
  15.239  			filter.appendComma();
  15.240  			filter.append(sridExpr);
  15.241  		}
  15.242 -		
  15.243 +
  15.244  			}
  15.245  
  15.246