Strabon
changeset 1122:ed2c581fe07b temporals
removed orig from repo
author | Konstantina Bereta <Konstantina.Bereta@di.uoa.gr> |
---|---|
date | Fri Apr 19 16:40:30 2013 +0300 (2013-04-19) |
parents | 3803532cc513 |
children | 35add8e2970f |
files | postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java.orig |
line diff
1.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java.orig Fri Apr 19 16:37:28 2013 +0300 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,2150 +0,0 @@ 1.4 -/* 1.5 - * Copyright Aduna (http://www.aduna-software.com/) (c) 2008. 1.6 - * 1.7 - * Licensed under the Aduna BSD-style license. 1.8 - */ 1.9 -package org.openrdf.sail.postgis.evaluation; 1.10 - 1.11 -import java.util.ArrayList; 1.12 -import java.util.List; 1.13 - 1.14 -import org.openrdf.query.algebra.evaluation.function.spatial.StrabonPolyhedron; 1.15 -import org.openrdf.sail.generaldb.algebra.GeneralDBColumnVar; 1.16 -import org.openrdf.sail.generaldb.algebra.GeneralDBDoubleValue; 1.17 -import org.openrdf.sail.generaldb.algebra.GeneralDBLabelColumn; 1.18 -import org.openrdf.sail.generaldb.algebra.GeneralDBNumericColumn; 1.19 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlAbove; 1.20 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlAnd; 1.21 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlAnyInteract; 1.22 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlBelow; 1.23 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlCase; 1.24 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlContains; 1.25 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlContainsMBB; 1.26 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlCoveredBy; 1.27 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlCovers; 1.28 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlDisjoint; 1.29 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlEqualsSpatial; 1.30 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoArea; 1.31 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoAsGML; 1.32 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoAsText; 1.33 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoBoundary; 1.34 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoBuffer; 1.35 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoConvexHull; 1.36 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoDifference; 1.37 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoDimension; 1.38 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoDistance; 1.39 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoEnvelope; 1.40 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoGeometryType; 1.41 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIntersection; 1.42 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIsEmpty; 1.43 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoIsSimple; 1.44 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSrid; 1.45 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoSymDifference; 1.46 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoTransform; 1.47 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlGeoUnion; 1.48 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlInside; 1.49 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlIntersects; 1.50 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlIsNull; 1.51 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlLeft; 1.52 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMathExpr; 1.53 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbEquals; 1.54 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbInside; 1.55 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbIntersects; 1.56 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlNot; 1.57 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull; 1.58 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlOverlap; 1.59 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 1.60 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 1.61 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructBinary; 1.62 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructUnary; 1.63 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialMetricBinary; 1.64 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialMetricUnary; 1.65 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialProperty; 1.66 -import org.openrdf.sail.generaldb.algebra.GeneralDBSqlTouch; 1.67 -import org.openrdf.sail.generaldb.algebra.GeneralDBStringValue; 1.68 -import org.openrdf.sail.generaldb.algebra.GeneralDBURIColumn; 1.69 -import org.openrdf.sail.generaldb.algebra.GeneralDBUnionItem; 1.70 -import org.openrdf.sail.generaldb.algebra.base.BinaryGeneralDBOperator; 1.71 -import org.openrdf.sail.generaldb.algebra.base.GeneralDBFromItem; 1.72 -import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr; 1.73 -import org.openrdf.sail.generaldb.algebra.base.TripleGeneralDBOperator; 1.74 -import org.openrdf.sail.generaldb.algebra.base.UnaryGeneralDBOperator; 1.75 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Contains; 1.76 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_CoveredBy; 1.77 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Covers; 1.78 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Disjoint; 1.79 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Equals; 1.80 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Inside; 1.81 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Meet; 1.82 -import org.openrdf.sail.generaldb.algebra.egenhofer.GeneralDBSqlEgenhofer_Overlap; 1.83 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Dc; 1.84 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Ec; 1.85 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Eq; 1.86 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Ntpp; 1.87 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Ntppi; 1.88 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Po; 1.89 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Tpp; 1.90 -import org.openrdf.sail.generaldb.algebra.rcc8.GeneralDBSqlRCC8_Tppi; 1.91 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Contains; 1.92 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Crosses; 1.93 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Disjoint; 1.94 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Equals; 1.95 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Intersects; 1.96 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Overlaps; 1.97 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Touches; 1.98 -import org.openrdf.sail.generaldb.algebra.sf.GeneralDBSqlSF_Within; 1.99 -import org.openrdf.sail.generaldb.evaluation.GeneralDBQueryBuilder; 1.100 -import org.openrdf.sail.generaldb.evaluation.GeneralDBSqlBracketBuilder; 1.101 -import org.openrdf.sail.generaldb.evaluation.GeneralDBSqlExprBuilder; 1.102 -import org.openrdf.sail.generaldb.evaluation.GeneralDBSqlJoinBuilder; 1.103 -import org.openrdf.sail.generaldb.evaluation.GeneralDBSqlQueryBuilder; 1.104 -import org.openrdf.sail.rdbms.exceptions.RdbmsException; 1.105 -import org.openrdf.sail.rdbms.exceptions.UnsupportedRdbmsOperatorException; 1.106 - 1.107 -/** 1.108 - * Constructs an SQL query from {@link GeneralDBSqlExpr}s and {@link GeneralDBFromItem}s. 1.109 - * 1.110 - * @author Manos Karpathiotakis <mk@di.uoa.gr> 1.111 - * 1.112 - */ 1.113 -public class PostGISQueryBuilder extends GeneralDBQueryBuilder { 1.114 - 1.115 - public static final String STRDFGEO_FIELD = "strdfgeo"; 1.116 - public static final String SRID_FIELD = "srid"; 1.117 - public static final String ST_TRANSFORM = "ST_Transform"; 1.118 - public static final String ST_ASBINARY = "ST_AsBinary"; 1.119 - /** 1.120 - * If (spatial) label column met is null, I must not try to retrieve its srid. 1.121 - * Opting to ask for 'null' instead 1.122 - */ 1.123 - boolean nullLabel = false; 1.124 - 1.125 - public enum SpatialOperandsPostGIS { anyInteract, equals, contains, left, right, above, inside, below; } 1.126 - public enum SpatialFunctionsPostGIS 1.127 - { //stSPARQL++ 1.128 - //Spatial Relationships 1.129 - ST_Disjoint, 1.130 - ST_Touches, 1.131 - ST_Covers, 1.132 - ST_CoveredBy, 1.133 - ST_Overlaps, 1.134 - ST_Intersects, 1.135 - ST_Equals, 1.136 - ST_Relate, 1.137 - ST_Within, 1.138 - ST_Contains, 1.139 - 1.140 - 1.141 - //Spatial Constructs - Binary 1.142 - ST_Union, 1.143 - ST_Intersection, 1.144 - ST_Difference, 1.145 - ST_Buffer, 1.146 - ST_Transform, 1.147 - ST_SymDifference, 1.148 - 1.149 - 1.150 - //Spatial Constructs - Unary 1.151 - ST_Envelope, 1.152 - ST_ConvexHull, 1.153 - ST_Boundary, 1.154 - 1.155 - //Spatial Metrics - Binary 1.156 - ST_Distance, 1.157 - 1.158 - //Spatial Metrics - Unary 1.159 - ST_Area, 1.160 - 1.161 - //Spatial Properties - All Unary 1.162 - ST_Dimension, 1.163 - ST_GeometryType, 1.164 - ST_AsGML, 1.165 - ST_AsText, 1.166 - ST_SRID, 1.167 - ST_IsEmpty, 1.168 - ST_IsSimple, 1.169 - 1.170 - //GeoSPARQL 1.171 - //Simple Features 1.172 - SF_Equals, 1.173 - SF_Disjoint, 1.174 - SF_Intersects, 1.175 - SF_Touches, 1.176 - SF_Within, 1.177 - SF_Contains, 1.178 - SF_Overlaps, 1.179 - SF_Crosses, 1.180 - 1.181 - //RCC8 1.182 - RCC8_Eq, 1.183 - RCC8_Dc, 1.184 - RCC8_Ec, 1.185 - RCC8_Po, 1.186 - RCC8_Tppi, 1.187 - RCC8_Tpp, 1.188 - RCC8_Ntppi, 1.189 - RCC8_Ntpp, 1.190 - 1.191 - //Egenhofer 1.192 - EH_Equals, 1.193 - EH_Disjoint, 1.194 - EH_Meet, 1.195 - EH_Overlap, 1.196 - EH_Covers, 1.197 - EH_CoveredBy, 1.198 - EH_Inside, 1.199 - EH_Contains, 1.200 - ; 1.201 - } 1.202 - 1.203 - public enum DateTimeFunctionsPostGIS { 1.204 - Difference; 1.205 - } 1.206 - 1.207 - public PostGISQueryBuilder() { 1.208 - super(); 1.209 - } 1.210 - 1.211 - public PostGISQueryBuilder(GeneralDBSqlQueryBuilder builder) { 1.212 - super(builder); 1.213 - this.query = builder; 1.214 - } 1.215 - 1.216 - @Override 1.217 - protected void append(GeneralDBSqlNull expr, GeneralDBSqlExprBuilder filter) { 1.218 - filter.appendNull(); 1.219 - } 1.220 - 1.221 - @Override 1.222 - protected void append(GeneralDBSqlIsNull expr, GeneralDBSqlExprBuilder filter) 1.223 - throws UnsupportedRdbmsOperatorException 1.224 - { 1.225 - dispatch(expr.getArg(), filter); 1.226 - filter.isNull(); 1.227 - } 1.228 - 1.229 - @Override 1.230 - protected void append(GeneralDBSqlNot expr, GeneralDBSqlExprBuilder filter) 1.231 - throws UnsupportedRdbmsOperatorException 1.232 - { 1.233 - if (expr.getArg() instanceof GeneralDBSqlIsNull) { 1.234 - GeneralDBSqlIsNull arg = (GeneralDBSqlIsNull)expr.getArg(); 1.235 - dispatch(arg.getArg(), filter); 1.236 - filter.isNotNull(); 1.237 - } 1.238 - else { 1.239 - GeneralDBSqlBracketBuilder open = filter.not(); 1.240 - dispatch(expr.getArg(), (GeneralDBSqlExprBuilder) open); 1.241 - open.close(); 1.242 - } 1.243 - } 1.244 - 1.245 - @Override 1.246 - protected void append(GeneralDBLabelColumn var, GeneralDBSqlExprBuilder filter) { 1.247 - if (var.getRdbmsVar().isResource()) { 1.248 - filter.appendNull(); 1.249 - nullLabel = true; 1.250 - } 1.251 - else { 1.252 - if(var.isSpatial()) 1.253 - { 1.254 - filter.appendFunction(ST_ASBINARY); 1.255 - filter.openBracket(); 1.256 - //XXX SRID 1.257 - filter.appendFunction(ST_TRANSFORM); 1.258 - filter.openBracket(); 1.259 - // 1.260 - String alias = getLabelAlias(var.getRdbmsVar()); 1.261 - 1.262 - filter.column(alias, STRDFGEO_FIELD); 1.263 - //XXX SRID 1.264 - filter.appendComma(); 1.265 - filter.column(alias, SRID_FIELD); 1.266 - filter.closeBracket(); 1.267 - // 1.268 - filter.closeBracket(); 1.269 - 1.270 - //Adding srid field explicitly for my StrabonPolyhedron constructor later on! 1.271 - filter.appendComma(); 1.272 - filter.column(alias, SRID_FIELD); 1.273 - } 1.274 - else 1.275 - { 1.276 - //XXX original/default case 1.277 - String alias = getLabelAlias(var.getRdbmsVar()); 1.278 - filter.column(alias, "value"); 1.279 - } 1.280 - } 1.281 - } 1.282 - 1.283 - @Override 1.284 - protected void append(GeneralDBSqlAnd expr, GeneralDBSqlExprBuilder filter) 1.285 - throws UnsupportedRdbmsOperatorException 1.286 - { 1.287 - dispatch(expr.getLeftArg(), filter); 1.288 - filter.and(); 1.289 - dispatch(expr.getRightArg(), filter); 1.290 - } 1.291 - 1.292 - protected GeneralDBSqlJoinBuilder subJoinAndFilter(GeneralDBSqlJoinBuilder query, GeneralDBFromItem from) 1.293 - throws RdbmsException, UnsupportedRdbmsOperatorException 1.294 - { 1.295 - if (from instanceof GeneralDBUnionItem) { 1.296 - GeneralDBUnionItem union = (GeneralDBUnionItem)from; 1.297 - List<String> names = union.getSelectVarNames(); 1.298 - List<GeneralDBColumnVar> vars = union.appendVars(new ArrayList<GeneralDBColumnVar>()); 1.299 - GeneralDBSqlQueryBuilder subquery = query.subquery(); 1.300 - for (GeneralDBFromItem item : union.getUnion()) { 1.301 - for (int i = 0, n = names.size(); i < n; i++) { 1.302 - GeneralDBColumnVar var = item.getVar(names.get(i)); 1.303 - GeneralDBSqlExprBuilder select = subquery.select(); 1.304 - if (var == null) { 1.305 - select.appendNull(); 1.306 - } 1.307 - else if (var.isImplied()) { 1.308 - select.appendNumeric(vf.getInternalId(var.getValue())); 1.309 - } 1.310 - else { 1.311 - select.column(var.getAlias(), var.getColumn()); 1.312 - } 1.313 - select.as(vars.get(i).getColumn()); 1.314 - } 1.315 - from(subquery, item); 1.316 - subquery = subquery.union(); 1.317 - } 1.318 - } 1.319 - for (GeneralDBFromItem join : from.getJoins()) { 1.320 - join(query, join); 1.321 - } 1.322 - for (GeneralDBSqlExpr expr : from.getFilters()) { 1.323 - dispatch(expr, query.on().and()); 1.324 - } 1.325 - return query; 1.326 - } 1.327 - 1.328 - //FIXME my addition from here on 1.329 - 1.330 - //Issue with this function: crashes when MathExpr is present in Select but does not 1.331 - //involve spatial variables! must escape this somehow 1.332 - @Override 1.333 - public GeneralDBQueryBuilder construct(GeneralDBSqlExpr expr) throws UnsupportedRdbmsOperatorException 1.334 - { 1.335 - if(!(expr instanceof GeneralDBSqlSpatialMetricBinary) 1.336 - &&!(expr instanceof GeneralDBSqlSpatialMetricUnary) 1.337 - &&!(expr instanceof GeneralDBSqlMathExpr) 1.338 - &&!(expr instanceof GeneralDBSqlSpatialProperty)) 1.339 - { 1.340 - query.select().appendFunction(ST_ASBINARY); 1.341 - } 1.342 - else 1.343 - { 1.344 - query.select(); 1.345 - } 1.346 - if(expr instanceof BinaryGeneralDBOperator) 1.347 - { 1.348 - dispatchBinarySqlOperator((BinaryGeneralDBOperator) expr, query.select); 1.349 - } 1.350 - else if(expr instanceof UnaryGeneralDBOperator) 1.351 - { 1.352 - dispatchUnarySqlOperator((UnaryGeneralDBOperator) expr, query.select); 1.353 - } 1.354 - //SRID support must be explicitly added! 1.355 - 1.356 - return this; 1.357 - } 1.358 - 1.359 - //Spatial Relationship Functions 1.360 - @Override 1.361 - protected void append(GeneralDBSqlAnyInteract expr, GeneralDBSqlExprBuilder filter) 1.362 - throws UnsupportedRdbmsOperatorException 1.363 - { 1.364 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Intersects); 1.365 - } 1.366 - 1.367 - 1.368 - @Override 1.369 - protected void append(GeneralDBSqlIntersects expr, GeneralDBSqlExprBuilder filter) 1.370 - throws UnsupportedRdbmsOperatorException { 1.371 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Intersects); 1.372 - } 1.373 - 1.374 - @Override 1.375 - protected void append(GeneralDBSqlContains expr, GeneralDBSqlExprBuilder filter) 1.376 - throws UnsupportedRdbmsOperatorException { 1.377 - 1.378 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Contains); 1.379 - } 1.380 - 1.381 - 1.382 - 1.383 - 1.384 - @Override 1.385 - protected void append(GeneralDBSqlEqualsSpatial expr, GeneralDBSqlExprBuilder filter) 1.386 - throws UnsupportedRdbmsOperatorException { 1.387 - 1.388 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Equals); 1.389 - } 1.390 - 1.391 - @Override 1.392 - protected void append(GeneralDBSqlInside expr, GeneralDBSqlExprBuilder filter) 1.393 - throws UnsupportedRdbmsOperatorException { 1.394 - 1.395 - //appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.inside); 1.396 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Within); 1.397 - 1.398 - } 1.399 - 1.400 - @Override 1.401 - protected void append(GeneralDBSqlCovers expr, GeneralDBSqlExprBuilder filter) 1.402 - throws UnsupportedRdbmsOperatorException { 1.403 - 1.404 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Covers); 1.405 - } 1.406 - 1.407 - @Override 1.408 - protected void append(GeneralDBSqlCoveredBy expr, GeneralDBSqlExprBuilder filter) 1.409 - throws UnsupportedRdbmsOperatorException { 1.410 - 1.411 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_CoveredBy); 1.412 - } 1.413 - 1.414 - @Override 1.415 - protected void append(GeneralDBSqlTouch expr, GeneralDBSqlExprBuilder filter) 1.416 - throws UnsupportedRdbmsOperatorException { 1.417 - 1.418 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Touches); 1.419 - } 1.420 - 1.421 - @Override 1.422 - protected void append(GeneralDBSqlOverlap expr, GeneralDBSqlExprBuilder filter) 1.423 - throws UnsupportedRdbmsOperatorException { 1.424 - 1.425 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Overlaps); 1.426 - } 1.427 - 1.428 - protected void append(GeneralDBSqlDisjoint expr, GeneralDBSqlExprBuilder filter) 1.429 - throws UnsupportedRdbmsOperatorException { 1.430 - 1.431 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Disjoint); 1.432 - } 1.433 - 1.434 - @Override 1.435 - protected void append(GeneralDBSqlRelate expr, GeneralDBSqlExprBuilder filter) 1.436 - throws UnsupportedRdbmsOperatorException 1.437 - { 1.438 - appendGeneralDBSpatialFunctionTriple(expr, filter, SpatialFunctionsPostGIS.ST_Relate); 1.439 - } 1.440 - 1.441 - @Override 1.442 - protected void append(GeneralDBSqlLeft expr, GeneralDBSqlExprBuilder filter) 1.443 - throws UnsupportedRdbmsOperatorException 1.444 - { 1.445 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.left); 1.446 - } 1.447 - 1.448 - @Override 1.449 - protected void append(GeneralDBSqlRight expr, GeneralDBSqlExprBuilder filter) 1.450 - throws UnsupportedRdbmsOperatorException 1.451 - { 1.452 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.right); 1.453 - } 1.454 - 1.455 - @Override 1.456 - protected void append(GeneralDBSqlAbove expr, GeneralDBSqlExprBuilder filter) 1.457 - throws UnsupportedRdbmsOperatorException 1.458 - { 1.459 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.above); 1.460 - } 1.461 - 1.462 - @Override 1.463 - protected void append(GeneralDBSqlBelow expr, GeneralDBSqlExprBuilder filter) 1.464 - throws UnsupportedRdbmsOperatorException 1.465 - { 1.466 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.below); 1.467 - } 1.468 - 1.469 - @Override 1.470 - protected void append(GeneralDBSqlMbbIntersects expr, GeneralDBSqlExprBuilder filter) 1.471 - throws UnsupportedRdbmsOperatorException { 1.472 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.anyInteract); 1.473 - } 1.474 - 1.475 - @Override 1.476 - protected void append(GeneralDBSqlMbbInside expr, GeneralDBSqlExprBuilder filter) 1.477 - throws UnsupportedRdbmsOperatorException { 1.478 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.inside); 1.479 - } 1.480 - 1.481 - 1.482 - @Override 1.483 - protected void append(GeneralDBSqlContainsMBB expr, GeneralDBSqlExprBuilder filter) 1.484 - throws UnsupportedRdbmsOperatorException { 1.485 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.contains); 1.486 - } 1.487 - 1.488 - 1.489 - @Override 1.490 - protected void append(GeneralDBSqlMbbEquals expr, GeneralDBSqlExprBuilder filter) 1.491 - throws UnsupportedRdbmsOperatorException { 1.492 - appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.equals); 1.493 - } 1.494 - 1.495 - //GeoSPARQL - Spatial Relationship Functions 1.496 - //Simple Features 1.497 - @Override 1.498 - protected void append(GeneralDBSqlSF_Contains expr, GeneralDBSqlExprBuilder filter) 1.499 - throws UnsupportedRdbmsOperatorException 1.500 - { 1.501 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Contains); 1.502 - } 1.503 - 1.504 - @Override 1.505 - protected void append(GeneralDBSqlSF_Crosses expr, GeneralDBSqlExprBuilder filter) 1.506 - throws UnsupportedRdbmsOperatorException 1.507 - { 1.508 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Crosses); 1.509 - } 1.510 - 1.511 - @Override 1.512 - protected void append(GeneralDBSqlSF_Disjoint expr, GeneralDBSqlExprBuilder filter) 1.513 - throws UnsupportedRdbmsOperatorException 1.514 - { 1.515 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Disjoint); 1.516 - } 1.517 - 1.518 - @Override 1.519 - protected void append(GeneralDBSqlSF_Equals expr, GeneralDBSqlExprBuilder filter) 1.520 - throws UnsupportedRdbmsOperatorException 1.521 - { 1.522 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Equals); 1.523 - } 1.524 - 1.525 - @Override 1.526 - protected void append(GeneralDBSqlSF_Intersects expr, GeneralDBSqlExprBuilder filter) 1.527 - throws UnsupportedRdbmsOperatorException 1.528 - { 1.529 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Intersects); 1.530 - } 1.531 - 1.532 - @Override 1.533 - protected void append(GeneralDBSqlSF_Overlaps expr, GeneralDBSqlExprBuilder filter) 1.534 - throws UnsupportedRdbmsOperatorException 1.535 - { 1.536 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Overlaps); 1.537 - } 1.538 - 1.539 - @Override 1.540 - protected void append(GeneralDBSqlSF_Touches expr, GeneralDBSqlExprBuilder filter) 1.541 - throws UnsupportedRdbmsOperatorException 1.542 - { 1.543 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Touches); 1.544 - } 1.545 - 1.546 - @Override 1.547 - protected void append(GeneralDBSqlSF_Within expr, GeneralDBSqlExprBuilder filter) 1.548 - throws UnsupportedRdbmsOperatorException 1.549 - { 1.550 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.SF_Within); 1.551 - } 1.552 - 1.553 - //Egenhofer 1.554 - @Override 1.555 - protected void append(GeneralDBSqlEgenhofer_CoveredBy expr, GeneralDBSqlExprBuilder filter) 1.556 - throws UnsupportedRdbmsOperatorException 1.557 - { 1.558 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_CoveredBy); 1.559 - } 1.560 - 1.561 - @Override 1.562 - protected void append(GeneralDBSqlEgenhofer_Covers expr, GeneralDBSqlExprBuilder filter) 1.563 - throws UnsupportedRdbmsOperatorException 1.564 - { 1.565 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Covers); 1.566 - } 1.567 - 1.568 - @Override 1.569 - protected void append(GeneralDBSqlEgenhofer_Contains expr, GeneralDBSqlExprBuilder filter) 1.570 - throws UnsupportedRdbmsOperatorException 1.571 - { 1.572 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Contains); 1.573 - } 1.574 - 1.575 - @Override 1.576 - protected void append(GeneralDBSqlEgenhofer_Disjoint expr, GeneralDBSqlExprBuilder filter) 1.577 - throws UnsupportedRdbmsOperatorException 1.578 - { 1.579 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Disjoint); 1.580 - } 1.581 - 1.582 - @Override 1.583 - protected void append(GeneralDBSqlEgenhofer_Equals expr, GeneralDBSqlExprBuilder filter) 1.584 - throws UnsupportedRdbmsOperatorException 1.585 - { 1.586 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Equals); 1.587 - } 1.588 - 1.589 - @Override 1.590 - protected void append(GeneralDBSqlEgenhofer_Inside expr, GeneralDBSqlExprBuilder filter) 1.591 - throws UnsupportedRdbmsOperatorException 1.592 - { 1.593 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Inside); 1.594 - } 1.595 - 1.596 - @Override 1.597 - protected void append(GeneralDBSqlEgenhofer_Meet expr, GeneralDBSqlExprBuilder filter) 1.598 - throws UnsupportedRdbmsOperatorException 1.599 - { 1.600 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Meet); 1.601 - } 1.602 - 1.603 - @Override 1.604 - protected void append(GeneralDBSqlEgenhofer_Overlap expr, GeneralDBSqlExprBuilder filter) 1.605 - throws UnsupportedRdbmsOperatorException 1.606 - { 1.607 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.EH_Overlap); 1.608 - } 1.609 - 1.610 - //RCC8 1.611 - @Override 1.612 - protected void append(GeneralDBSqlRCC8_Dc expr, GeneralDBSqlExprBuilder filter) 1.613 - throws UnsupportedRdbmsOperatorException 1.614 - { 1.615 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Dc); 1.616 - } 1.617 - 1.618 - @Override 1.619 - protected void append(GeneralDBSqlRCC8_Eq expr, GeneralDBSqlExprBuilder filter) 1.620 - throws UnsupportedRdbmsOperatorException 1.621 - { 1.622 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Eq); 1.623 - } 1.624 - 1.625 - @Override 1.626 - protected void append(GeneralDBSqlRCC8_Ec expr, GeneralDBSqlExprBuilder filter) 1.627 - throws UnsupportedRdbmsOperatorException 1.628 - { 1.629 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Ec); 1.630 - } 1.631 - 1.632 - @Override 1.633 - protected void append(GeneralDBSqlRCC8_Po expr, GeneralDBSqlExprBuilder filter) 1.634 - throws UnsupportedRdbmsOperatorException 1.635 - { 1.636 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Po); 1.637 - } 1.638 - 1.639 - @Override 1.640 - protected void append(GeneralDBSqlRCC8_Tppi expr, GeneralDBSqlExprBuilder filter) 1.641 - throws UnsupportedRdbmsOperatorException 1.642 - { 1.643 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Tppi); 1.644 - } 1.645 - 1.646 - @Override 1.647 - protected void append(GeneralDBSqlRCC8_Tpp expr, GeneralDBSqlExprBuilder filter) 1.648 - throws UnsupportedRdbmsOperatorException 1.649 - { 1.650 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Tpp); 1.651 - } 1.652 - 1.653 - @Override 1.654 - protected void append(GeneralDBSqlRCC8_Ntpp expr, GeneralDBSqlExprBuilder filter) 1.655 - throws UnsupportedRdbmsOperatorException 1.656 - { 1.657 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Ntpp); 1.658 - } 1.659 - 1.660 - @Override 1.661 - protected void append(GeneralDBSqlRCC8_Ntppi expr, GeneralDBSqlExprBuilder filter) 1.662 - throws UnsupportedRdbmsOperatorException 1.663 - { 1.664 - appendgeoSPARQLSpatialRelation(expr, filter,SpatialFunctionsPostGIS.RCC8_Ntppi); 1.665 - } 1.666 - 1.667 - //Spatial Construct Functions 1.668 - @Override 1.669 - protected void append(GeneralDBSqlGeoUnion expr, GeneralDBSqlExprBuilder filter) 1.670 - throws UnsupportedRdbmsOperatorException 1.671 - { 1.672 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Union); 1.673 - } 1.674 - 1.675 - @Override 1.676 - protected void append(GeneralDBSqlGeoBuffer expr, GeneralDBSqlExprBuilder filter) 1.677 - throws UnsupportedRdbmsOperatorException 1.678 - { 1.679 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Buffer); 1.680 - } 1.681 - 1.682 - //XXX Different Behavior 1.683 - @Override 1.684 - protected void append(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter) 1.685 - throws UnsupportedRdbmsOperatorException 1.686 - { 1.687 - appendTransformFunc(expr, filter); 1.688 - } 1.689 - 1.690 - @Override 1.691 - protected void append(GeneralDBSqlGeoEnvelope expr, GeneralDBSqlExprBuilder filter) 1.692 - throws UnsupportedRdbmsOperatorException 1.693 - { 1.694 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Envelope); 1.695 - } 1.696 - 1.697 - @Override 1.698 - protected void append(GeneralDBSqlGeoConvexHull expr, GeneralDBSqlExprBuilder filter) 1.699 - throws UnsupportedRdbmsOperatorException 1.700 - { 1.701 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_ConvexHull); 1.702 - } 1.703 - 1.704 - @Override 1.705 - protected void append(GeneralDBSqlGeoBoundary expr, GeneralDBSqlExprBuilder filter) 1.706 - throws UnsupportedRdbmsOperatorException 1.707 - { 1.708 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Boundary); 1.709 - } 1.710 - 1.711 - @Override 1.712 - protected void append(GeneralDBSqlGeoIntersection expr, GeneralDBSqlExprBuilder filter) 1.713 - throws UnsupportedRdbmsOperatorException 1.714 - { 1.715 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Intersection); 1.716 - } 1.717 - 1.718 - @Override 1.719 - protected void append(GeneralDBSqlGeoDifference expr, GeneralDBSqlExprBuilder filter) 1.720 - throws UnsupportedRdbmsOperatorException 1.721 - { 1.722 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Difference); 1.723 - } 1.724 - 1.725 - @Override 1.726 - protected void append(GeneralDBSqlGeoSymDifference expr, GeneralDBSqlExprBuilder filter) 1.727 - throws UnsupportedRdbmsOperatorException 1.728 - { 1.729 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_SymDifference); 1.730 - } 1.731 - 1.732 - //Spatial Metric Functions 1.733 - @Override 1.734 - protected void append(GeneralDBSqlGeoDistance expr, GeneralDBSqlExprBuilder filter) 1.735 - throws UnsupportedRdbmsOperatorException 1.736 - { 1.737 - appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_Distance); 1.738 - } 1.739 - 1.740 - @Override 1.741 - protected void append(GeneralDBSqlGeoArea expr, GeneralDBSqlExprBuilder filter) 1.742 - throws UnsupportedRdbmsOperatorException 1.743 - { 1.744 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Area); 1.745 - } 1.746 - 1.747 - //Spatial Property Functions 1.748 - @Override 1.749 - protected void append(GeneralDBSqlGeoDimension expr, GeneralDBSqlExprBuilder filter) 1.750 - throws UnsupportedRdbmsOperatorException 1.751 - { 1.752 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Dimension); 1.753 - } 1.754 - 1.755 - @Override 1.756 - protected void append(GeneralDBSqlGeoGeometryType expr, GeneralDBSqlExprBuilder filter) 1.757 - throws UnsupportedRdbmsOperatorException 1.758 - { 1.759 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_GeometryType); 1.760 - } 1.761 - 1.762 - @Override 1.763 - protected void append(GeneralDBSqlGeoAsText expr, GeneralDBSqlExprBuilder filter) 1.764 - throws UnsupportedRdbmsOperatorException 1.765 - { 1.766 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_AsText); 1.767 - } 1.768 - 1.769 - @Override 1.770 - protected void append(GeneralDBSqlGeoAsGML expr, GeneralDBSqlExprBuilder filter) 1.771 - throws UnsupportedRdbmsOperatorException 1.772 - { 1.773 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_AsGML); 1.774 - } 1.775 - 1.776 - // @Override 1.777 - // protected void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter) 1.778 - // throws UnsupportedRdbmsOperatorException 1.779 - // { 1.780 - // appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_SRID); 1.781 - // } 1.782 - 1.783 - /** 1.784 - * Special Case because I need to retrieve a single different column from geo_values when this function occurs 1.785 - * in the select clause 1.786 - */ 1.787 - @Override 1.788 - protected void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter) 1.789 - throws UnsupportedRdbmsOperatorException 1.790 - { 1.791 - boolean sridNeeded = true; 1.792 - filter.openBracket(); 1.793 - 1.794 - boolean check1 = expr.getArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.795 - boolean check2 = false; 1.796 - if(expr.getArg() instanceof GeneralDBLabelColumn) 1.797 - { 1.798 - if(((GeneralDBLabelColumn) expr.getArg()).getRdbmsVar().isResource()) 1.799 - { 1.800 - check2 = true; 1.801 - } 1.802 - } 1.803 - if(check1) 1.804 - { 1.805 - this.append((GeneralDBSqlNull)expr.getArg(), filter); 1.806 - 1.807 - } 1.808 - else if (check2) 1.809 - { 1.810 - appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter); 1.811 - } 1.812 - else 1.813 - { 1.814 - //XXX Incorporating SRID 1.815 - GeneralDBSqlExpr tmp = expr; 1.816 - if(tmp.getParentNode() == null) 1.817 - { 1.818 - String sridExpr; 1.819 - while(true) 1.820 - { 1.821 - GeneralDBSqlExpr child = null; 1.822 - 1.823 - if(tmp instanceof BinaryGeneralDBOperator) 1.824 - { 1.825 - child = ((BinaryGeneralDBOperator) tmp).getLeftArg(); 1.826 - } 1.827 - else if(tmp instanceof UnaryGeneralDBOperator) 1.828 - { 1.829 - child = ((UnaryGeneralDBOperator) tmp).getArg(); 1.830 - } 1.831 - else if(tmp instanceof GeneralDBStringValue) 1.832 - { 1.833 - //Constant!! 1.834 - sridNeeded = false; 1.835 - break; 1.836 - } 1.837 - 1.838 - tmp = child; 1.839 - if(tmp instanceof GeneralDBLabelColumn) 1.840 - { 1.841 - //Reached the innermost left var -> need to capture its SRID 1.842 - String alias; 1.843 - if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) { 1.844 - //Predicates used in triple patterns non-existent in db 1.845 - alias="NULL"; 1.846 - } 1.847 - else 1.848 - { 1.849 - //Reached the innermost left var -> need to capture its SRID 1.850 - alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar()); 1.851 - alias=alias+".srid"; 1.852 - } 1.853 - sridExpr = alias; 1.854 - filter.append(sridExpr); 1.855 - filter.closeBracket(); 1.856 - return; 1.857 - //break; 1.858 - } 1.859 - else if(tmp instanceof GeneralDBStringValue) 1.860 - { 1.861 - //Constant!! 1.862 - sridNeeded = false; 1.863 - break; 1.864 - } 1.865 - 1.866 - } 1.867 - } 1.868 - 1.869 - if(sridNeeded) 1.870 - { 1.871 - filter.appendFunction("ST_SRID"); 1.872 - filter.openBracket(); 1.873 - if(expr.getArg() instanceof GeneralDBStringValue) 1.874 - { 1.875 - appendWKT(expr.getArg(),filter); 1.876 - } 1.877 - else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.878 - { 1.879 - appendConstructFunction(expr.getArg(), filter); 1.880 - } 1.881 - else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.882 - { 1.883 - appendConstructFunction(expr.getArg(), filter); 1.884 - } 1.885 - else if(expr.getArg() instanceof GeneralDBSqlCase) 1.886 - { 1.887 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getArg()).getEntries().get(0).getResult(); 1.888 - appendMBB(onlyLabel,filter); 1.889 - } 1.890 - else 1.891 - { 1.892 - appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter); 1.893 - } 1.894 - 1.895 - filter.closeBracket(); 1.896 - } 1.897 - else 1.898 - { 1.899 - //4326 by default - Software House additions 1.900 - filter.append("4326"); 1.901 - } 1.902 - } 1.903 - 1.904 - filter.closeBracket(); 1.905 - } 1.906 - 1.907 - @Override 1.908 - protected void append(GeneralDBSqlGeoIsSimple expr, GeneralDBSqlExprBuilder filter) 1.909 - throws UnsupportedRdbmsOperatorException 1.910 - { 1.911 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_IsSimple); 1.912 - } 1.913 - 1.914 - @Override 1.915 - protected void append(GeneralDBSqlGeoIsEmpty expr, GeneralDBSqlExprBuilder filter) 1.916 - throws UnsupportedRdbmsOperatorException 1.917 - { 1.918 - appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_IsEmpty); 1.919 - } 1.920 - 1.921 - 1.922 - /** 1.923 - * 'helper' functions 1.924 - */ 1.925 - 1.926 - @Override 1.927 - protected String appendWKT(GeneralDBSqlExpr expr, GeneralDBSqlExprBuilder filter) 1.928 - { 1.929 - GeneralDBStringValue arg = (GeneralDBStringValue) expr; 1.930 - String raw = arg.getValue(); 1.931 - 1.932 - StrabonPolyhedron poly = null; 1.933 - try{ 1.934 - poly = new StrabonPolyhedron(raw); 1.935 - } catch (Exception e) { 1.936 - e.printStackTrace(); 1.937 - } 1.938 - 1.939 - filter.append(" ST_GeomFromText('"+poly.toWKT() +"',4326)"); 1.940 - 1.941 - return raw; 1.942 - } 1.943 - 1.944 - //Used in all the generaldb boolean spatial functions of the form ?GEO1 ~ ?GEO2 1.945 - // protected void appendStSPARQLSpatialOperand(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialOperandsPostGIS operand) throws UnsupportedRdbmsOperatorException 1.946 - // { 1.947 - // filter.openBracket(); 1.948 - // 1.949 - // boolean check1a = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.950 - // //boolean check2a = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.951 - // 1.952 - // if(check1a) 1.953 - // { 1.954 - // this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.955 - // 1.956 - // } 1.957 - //// else if(check2a) 1.958 - //// { 1.959 - //// this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.960 - //// } 1.961 - // else 1.962 - // { 1.963 - // if(expr.getLeftArg() instanceof GeneralDBSqlCase) 1.964 - // { 1.965 - // this.append((GeneralDBSqlCase)expr.getLeftArg(), filter); 1.966 - // } 1.967 - // else if(expr.getLeftArg() instanceof GeneralDBStringValue) 1.968 - // { 1.969 - // appendWKT(expr.getLeftArg(),filter); 1.970 - // } 1.971 - // else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.972 - // { 1.973 - // appendConstructFunction(expr.getLeftArg(), filter); 1.974 - // } 1.975 - // else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.976 - // { 1.977 - // appendConstructFunction(expr.getLeftArg(), filter); 1.978 - // } 1.979 - // else 1.980 - // { 1.981 - // appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 1.982 - // } 1.983 - // 1.984 - // switch(operand) 1.985 - // { 1.986 - // case anyInteract: filter.anyInteract(); break; 1.987 - // case equals: filter.equals(); break; 1.988 - // case contains: filter.contains(); break; 1.989 - // case inside: filter.inside(); break; 1.990 - // case left: filter.left(); break; 1.991 - // case right: filter.right(); break; 1.992 - // case above: filter.above(); break; 1.993 - // case below: filter.below(); break; 1.994 - // } 1.995 - // 1.996 - // boolean check2a = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.997 - // 1.998 - // if(check2a) 1.999 - // { 1.1000 - // this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1001 - // } 1.1002 - // else 1.1003 - // { 1.1004 - // 1.1005 - // if(expr.getRightArg() instanceof GeneralDBSqlCase) 1.1006 - // { 1.1007 - // this.append((GeneralDBSqlCase)expr.getRightArg(), filter); 1.1008 - // } 1.1009 - // else if(expr.getRightArg() instanceof GeneralDBStringValue) 1.1010 - // { 1.1011 - // appendWKT(expr.getRightArg(),filter); 1.1012 - // } 1.1013 - // else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1014 - // { 1.1015 - // appendConstructFunction(expr.getRightArg(), filter); 1.1016 - // } 1.1017 - // else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1018 - // { 1.1019 - // appendConstructFunction(expr.getRightArg(), filter); 1.1020 - // } 1.1021 - // else 1.1022 - // { 1.1023 - // appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter); 1.1024 - // } 1.1025 - // 1.1026 - // } 1.1027 - // } 1.1028 - // filter.closeBracket(); 1.1029 - // } 1.1030 - 1.1031 - 1.1032 - protected void appendStSPARQLSpatialOperand(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialOperandsPostGIS operand) throws UnsupportedRdbmsOperatorException 1.1033 - { 1.1034 - filter.openBracket(); 1.1035 - 1.1036 - boolean check1a = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1037 - boolean check2a = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1038 - 1.1039 - if(check1a) 1.1040 - { 1.1041 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.1042 - 1.1043 - } 1.1044 - else if(check2a) 1.1045 - { 1.1046 - this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1047 - } 1.1048 - else 1.1049 - { 1.1050 - if(expr.getLeftArg() instanceof GeneralDBSqlCase) 1.1051 - { 1.1052 - this.append((GeneralDBSqlCase)expr.getLeftArg(), filter); 1.1053 - } 1.1054 - else if(expr.getLeftArg() instanceof GeneralDBStringValue) 1.1055 - { 1.1056 - appendWKT(expr.getLeftArg(),filter); 1.1057 - } 1.1058 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1059 - { 1.1060 - appendConstructFunction(expr.getLeftArg(), filter); 1.1061 - } 1.1062 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1063 - { 1.1064 - appendConstructFunction(expr.getLeftArg(), filter); 1.1065 - } 1.1066 - else 1.1067 - { 1.1068 - appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 1.1069 - } 1.1070 - 1.1071 - switch(operand) 1.1072 - { 1.1073 - case anyInteract: filter.intersectsMBB(); break; 1.1074 - case equals: filter.equalsMBB(); break; 1.1075 - case contains: filter.containsMBB(); break; 1.1076 - case inside: filter.insideMBB(); break; 1.1077 - case left: filter.leftMBB(); break; 1.1078 - case right: filter.rightMBB(); break; 1.1079 - case above: filter.aboveMBB(); break; 1.1080 - case below: filter.belowMBB(); break; 1.1081 - } 1.1082 - 1.1083 - // boolean check2a = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1084 - // 1.1085 - // if(check2a) 1.1086 - // { 1.1087 - // this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1088 - // } 1.1089 - // else 1.1090 - // { 1.1091 - 1.1092 - if(expr.getRightArg() instanceof GeneralDBSqlCase) 1.1093 - { 1.1094 - this.append((GeneralDBSqlCase)expr.getRightArg(), filter); 1.1095 - } 1.1096 - else if(expr.getRightArg() instanceof GeneralDBStringValue) 1.1097 - { 1.1098 - appendWKT(expr.getRightArg(),filter); 1.1099 - } 1.1100 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1101 - { 1.1102 - appendConstructFunction(expr.getRightArg(), filter); 1.1103 - } 1.1104 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1105 - { 1.1106 - appendConstructFunction(expr.getRightArg(), filter); 1.1107 - } 1.1108 - else 1.1109 - { 1.1110 - appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter); 1.1111 - } 1.1112 - 1.1113 - //} 1.1114 - } 1.1115 - filter.closeBracket(); 1.1116 - } 1.1117 - 1.1118 - //Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 1.1119 - protected void appendTransformFunc(GeneralDBSqlGeoTransform expr, GeneralDBSqlExprBuilder filter) 1.1120 - throws UnsupportedRdbmsOperatorException 1.1121 - { 1.1122 - //In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))") 1.1123 - boolean sridNeeded = true; 1.1124 - //XXX Incorporating SRID 1.1125 - String sridExpr = null; 1.1126 - 1.1127 - filter.openBracket(); 1.1128 - filter.appendFunction(ST_TRANSFORM); 1.1129 - filter.openBracket(); 1.1130 - 1.1131 - boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1132 - boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1133 - 1.1134 - if(check1) 1.1135 - { 1.1136 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.1137 - 1.1138 - } 1.1139 - else if(check2) 1.1140 - { 1.1141 - this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1142 - } 1.1143 - else 1.1144 - { 1.1145 - GeneralDBSqlExpr tmp = expr; 1.1146 - if(tmp instanceof GeneralDBSqlSpatialConstructBinary && tmp.getParentNode() == null) 1.1147 - { 1.1148 - while(true) 1.1149 - { 1.1150 - GeneralDBSqlExpr child; 1.1151 - 1.1152 - if(tmp instanceof BinaryGeneralDBOperator) 1.1153 - { 1.1154 - child = ((BinaryGeneralDBOperator) tmp).getLeftArg(); 1.1155 - } 1.1156 - else //(tmp instanceof UnaryGeneralDBOperator) 1.1157 - { 1.1158 - child = ((UnaryGeneralDBOperator) tmp).getArg(); 1.1159 - } 1.1160 - 1.1161 - tmp = child; 1.1162 - if(tmp instanceof GeneralDBLabelColumn) 1.1163 - { 1.1164 - String alias; 1.1165 - if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) { 1.1166 - //Predicates used in triple patterns non-existent in db 1.1167 - alias="NULL"; 1.1168 - } 1.1169 - else 1.1170 - { 1.1171 - //Reached the innermost left var -> need to capture its SRID 1.1172 - alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar()); 1.1173 - alias=alias+".srid"; 1.1174 - } 1.1175 - sridExpr = alias; 1.1176 - break; 1.1177 - } 1.1178 - else if (tmp instanceof GeneralDBStringValue) //Constant!! 1.1179 - { 1.1180 - sridNeeded = false; 1.1181 - break; 1.1182 - } 1.1183 - 1.1184 - } 1.1185 - if(sridNeeded) 1.1186 - { 1.1187 - filter.appendFunction(ST_TRANSFORM); 1.1188 - filter.openBracket(); 1.1189 - } 1.1190 - } 1.1191 - 1.1192 - if(expr.getLeftArg() instanceof GeneralDBStringValue) 1.1193 - { 1.1194 - appendWKT(expr.getLeftArg(),filter); 1.1195 - } 1.1196 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1197 - { 1.1198 - appendConstructFunction(expr.getLeftArg(), filter); 1.1199 - } 1.1200 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1201 - { 1.1202 - appendConstructFunction(expr.getLeftArg(), filter); 1.1203 - } 1.1204 - else if(expr.getLeftArg() instanceof GeneralDBSqlCase) 1.1205 - { 1.1206 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getLeftArg()).getEntries().get(0).getResult(); 1.1207 - appendMBB(onlyLabel,filter); 1.1208 - } 1.1209 - else 1.1210 - { 1.1211 - appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 1.1212 - } 1.1213 - 1.1214 - //SRID Support 1.1215 - if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null) 1.1216 - { 1.1217 - filter.appendComma(); 1.1218 - //filter.append(((GeneralDBSqlSpatialConstructBinary)expr).getSrid()); 1.1219 - filter.append(sridExpr); 1.1220 - filter.closeBracket(); 1.1221 - } 1.1222 - 1.1223 - filter.appendComma(); 1.1224 - 1.1225 - if(expr.getRightArg() instanceof GeneralDBSqlCase) //case met in transform! 1.1226 - { 1.1227 - GeneralDBURIColumn plainURI = (GeneralDBURIColumn)((GeneralDBSqlCase)expr.getRightArg()).getEntries().get(0).getResult(); 1.1228 - 1.1229 - //XXX This case would be met if we recovered the SRID URI from the db!!! 1.1230 - //Need to set sridExpr to the value of this new URI, otherwise the appended uri 1.1231 - //to the spatial object will be the wrong one!!!! (Seee following case) 1.1232 - filter.keepSRID_part1(); 1.1233 - append(plainURI, filter); 1.1234 - filter.keepSRID_part2(); 1.1235 - append(plainURI, filter); 1.1236 - filter.keepSRID_part3(); 1.1237 - } 1.1238 - else if(expr.getRightArg() instanceof GeneralDBStringValue) 1.1239 - { 1.1240 - String unparsedSRID = ((GeneralDBStringValue)expr.getRightArg()).getValue(); 1.1241 - // int srid = Integer.parseInt(unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1)); 1.1242 - sridExpr = unparsedSRID.substring(unparsedSRID.lastIndexOf('/')+1); 1.1243 - filter.append(sridExpr); 1.1244 - filter.closeBracket(); 1.1245 - } 1.1246 - 1.1247 - 1.1248 - } 1.1249 - filter.closeBracket(); 1.1250 - //In this case, SRID is the one that has been provided by the user!! 1.1251 - //I am including this extra binding to be used in subsequent (Aggregate) steps 1.1252 - if(expr instanceof GeneralDBSqlSpatialConstructBinary && expr.getParentNode() == null) 1.1253 - { 1.1254 - filter.appendComma(); 1.1255 - filter.append(sridExpr); 1.1256 - } 1.1257 - 1.1258 - } 1.1259 - 1.1260 - /** Addition for datetime metric functions 1.1261 - * 1.1262 - * @author George Garbis <ggarbis@di.uoa.gr> 1.1263 - * 1.1264 - */ 1.1265 - 1.1266 - protected void appendGeneralDBDateTimeFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, DateTimeFunctionsPostGIS func) 1.1267 - throws UnsupportedRdbmsOperatorException 1.1268 - { 1.1269 - 1.1270 - filter.openBracket(); 1.1271 - 1.1272 - boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1273 - boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1274 - 1.1275 - if(check1) 1.1276 - { 1.1277 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.1278 - 1.1279 - } 1.1280 - else if(check2) 1.1281 - { 1.1282 - this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1283 - } 1.1284 - else 1.1285 - { 1.1286 - switch (func){ 1.1287 - case Difference: 1.1288 - append(((GeneralDBLabelColumn)expr.getRightArg()),filter); 1.1289 - filter.append(" - "); 1.1290 - append(((GeneralDBLabelColumn)expr.getRightArg()),filter); 1.1291 - break; 1.1292 - } 1.1293 - 1.1294 - } 1.1295 - } 1.1296 - 1.1297 - // Used in all the generaldb stsparql boolean spatial functions of the form ST_Function(?GEO1, ?GEO2) 1.1298 - // EXCEPT ST_Transform!!! 1.1299 - protected void appendGeneralDBSpatialFunctionBinary(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func) 1.1300 - throws UnsupportedRdbmsOperatorException 1.1301 - { 1.1302 - //In the case where no variable is present in the expression! e.g ConvexHull("POLYGON((.....))") 1.1303 - boolean sridNeeded = true; 1.1304 - String sridExpr = null; 1.1305 - 1.1306 - filter.openBracket(); 1.1307 - 1.1308 - boolean check1 = expr.getArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1309 - boolean check2 = false; 1.1310 - if(expr.getArg() instanceof GeneralDBLabelColumn) 1.1311 - { 1.1312 - if(((GeneralDBLabelColumn) expr.getArg()).getRdbmsVar().isResource()) 1.1313 - { 1.1314 - check2 = true; 1.1315 - } 1.1316 - } 1.1317 - if(check1) 1.1318 - { 1.1319 - this.append((GeneralDBSqlNull)expr.getArg(), filter); 1.1320 - 1.1321 - } 1.1322 - else if (check2) 1.1323 - { 1.1324 - appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter); 1.1325 - } 1.1326 - else 1.1327 - { 1.1328 - 1.1329 - GeneralDBSqlExpr tmp = expr; 1.1330 - 1.1331 - 1.1332 - if(tmp instanceof GeneralDBSqlSpatialConstructUnary && tmp.getParentNode() == null) 1.1333 - { 1.1334 - while(true) 1.1335 - { 1.1336 - GeneralDBSqlExpr child = null; 1.1337 - 1.1338 - if(tmp instanceof BinaryGeneralDBOperator) 1.1339 - { 1.1340 - child = ((BinaryGeneralDBOperator) tmp).getLeftArg(); 1.1341 - } 1.1342 - else if(tmp instanceof UnaryGeneralDBOperator) 1.1343 - { 1.1344 - child = ((UnaryGeneralDBOperator) tmp).getArg(); 1.1345 - } 1.1346 - else if(tmp instanceof GeneralDBStringValue) 1.1347 - { 1.1348 - sridNeeded = false; 1.1349 - break; 1.1350 - } 1.1351 - 1.1352 - tmp = child; 1.1353 - if(tmp instanceof GeneralDBLabelColumn) 1.1354 - { 1.1355 - //Reached the innermost left var -> need to capture its SRID 1.1356 - String alias; 1.1357 - if (((GeneralDBLabelColumn) tmp).getRdbmsVar().isResource()) { 1.1358 - //Predicates used in triple patterns non-existent in db 1.1359 - alias="NULL"; 1.1360 - } 1.1361 - else 1.1362 - { 1.1363 - //Reached the innermost left var -> need to capture its SRID 1.1364 - alias = getLabelAlias(((GeneralDBLabelColumn) tmp).getRdbmsVar()); 1.1365 - alias=alias+".srid"; 1.1366 - } 1.1367 - sridExpr = alias; 1.1368 - break; 1.1369 - } 1.1370 - else if (tmp instanceof GeneralDBStringValue) //Constant!! 1.1371 - { 1.1372 - sridNeeded = false; 1.1373 - break; 1.1374 - } 1.1375 - 1.1376 - } 1.1377 - if(sridNeeded) 1.1378 - { 1.1379 - filter.appendFunction(ST_TRANSFORM); 1.1380 - filter.openBracket(); 1.1381 - } 1.1382 - } 1.1383 - ///// 1.1384 - 1.1385 - switch(func) 1.1386 - { 1.1387 - case ST_Envelope: filter.appendFunction("ST_Envelope"); break; 1.1388 - case ST_ConvexHull: filter.appendFunction("ST_ConvexHull"); break; 1.1389 - case ST_Boundary: filter.appendFunction("ST_Boundary"); break; 1.1390 - case ST_Area: filter.appendFunction("ST_Area"); break; 1.1391 - case ST_Dimension: filter.appendFunction("ST_Dimension"); break; 1.1392 - case ST_GeometryType: filter.appendFunction("ST_GeometryType"); break; 1.1393 - case ST_AsText: filter.appendFunction("ST_AsText"); break; 1.1394 - case ST_AsGML: filter.appendFunction("ST_AsGML"); break; 1.1395 - case ST_SRID: filter.appendFunction("ST_SRID"); break; 1.1396 - case ST_IsEmpty: filter.appendFunction("ST_IsEmpty"); break; 1.1397 - case ST_IsSimple: filter.appendFunction("ST_IsSimple"); break; 1.1398 - } 1.1399 - filter.openBracket(); 1.1400 - if(expr.getArg() instanceof GeneralDBStringValue) 1.1401 - { 1.1402 - appendWKT(expr.getArg(),filter); 1.1403 - } 1.1404 - else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1405 - { 1.1406 - appendConstructFunction(expr.getArg(), filter); 1.1407 - } 1.1408 - else if(expr.getArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1409 - { 1.1410 - appendConstructFunction(expr.getArg(), filter); 1.1411 - } 1.1412 - else if(expr.getArg() instanceof GeneralDBSqlCase) 1.1413 - { 1.1414 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getArg()).getEntries().get(0).getResult(); 1.1415 - appendMBB(onlyLabel,filter); 1.1416 - } 1.1417 - else 1.1418 - { 1.1419 - appendMBB((GeneralDBLabelColumn)(expr.getArg()),filter); 1.1420 - } 1.1421 - 1.1422 - filter.closeBracket(); 1.1423 - // //SRID Support 1.1424 - if(sridNeeded) 1.1425 - { 1.1426 - if(expr instanceof GeneralDBSqlSpatialConstructUnary && expr.getParentNode() == null) 1.1427 - { 1.1428 - filter.appendComma(); 1.1429 - // filter.append(((GeneralDBSqlSpatialConstructUnary)expr).getSrid()); 1.1430 - filter.append(sridExpr); 1.1431 - filter.closeBracket(); 1.1432 - } 1.1433 - } 1.1434 - /// 1.1435 - } 1.1436 - 1.1437 - filter.closeBracket(); 1.1438 - //Used to explicitly include SRID 1.1439 - if(expr instanceof GeneralDBSqlSpatialConstructUnary && expr.getParentNode() == null) 1.1440 - { 1.1441 - filter.appendComma(); 1.1442 - filter.append(sridExpr); 1.1443 - } 1.1444 - } 1.1445 - 1.1446 - //Used in all the generaldb boolean spatial functions of the form ST_Function(?GEO1,?GEO2) 1.1447 - protected void appendGeneralDBSpatialFunctionTriple(TripleGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func) 1.1448 - throws UnsupportedRdbmsOperatorException 1.1449 - { 1.1450 - filter.openBracket(); 1.1451 - 1.1452 - boolean check1a = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1453 - boolean check2a = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1454 - boolean check3 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1455 - 1.1456 - if(check1a) 1.1457 - { 1.1458 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.1459 - 1.1460 - } 1.1461 - else if(check2a) 1.1462 - { 1.1463 - this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1464 - } 1.1465 - else if(check3) 1.1466 - { 1.1467 - this.append((GeneralDBSqlNull)expr.getThirdArg(), filter); 1.1468 - } 1.1469 - else 1.1470 - { 1.1471 - switch(func) 1.1472 - { 1.1473 - case ST_Relate: filter.appendFunction("ST_Relate"); break; 1.1474 - } 1.1475 - filter.openBracket(); 1.1476 - if(expr.getLeftArg() instanceof GeneralDBStringValue) 1.1477 - { 1.1478 - appendWKT(expr.getLeftArg(),filter); 1.1479 - } 1.1480 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1481 - { 1.1482 - appendConstructFunction(expr.getLeftArg(), filter); 1.1483 - } 1.1484 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1485 - { 1.1486 - appendConstructFunction(expr.getLeftArg(), filter); 1.1487 - } 1.1488 - else if(expr.getLeftArg() instanceof GeneralDBSqlCase) 1.1489 - { 1.1490 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getLeftArg()).getEntries().get(0).getResult(); 1.1491 - appendMBB(onlyLabel,filter); 1.1492 - } 1.1493 - else 1.1494 - { 1.1495 - appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 1.1496 - } 1.1497 - filter.appendComma(); 1.1498 - // boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1499 - // if(check2) 1.1500 - // { 1.1501 - // this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1502 - // } 1.1503 - // else 1.1504 - // { 1.1505 - if(expr.getRightArg() instanceof GeneralDBStringValue) 1.1506 - { 1.1507 - appendWKT(expr.getRightArg(),filter); 1.1508 - } 1.1509 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1510 - { 1.1511 - appendConstructFunction(expr.getRightArg(), filter); 1.1512 - } 1.1513 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1514 - { 1.1515 - appendConstructFunction(expr.getRightArg(), filter); 1.1516 - } 1.1517 - else if(expr.getRightArg() instanceof GeneralDBSqlCase) 1.1518 - { 1.1519 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getRightArg()).getEntries().get(0).getResult(); 1.1520 - appendMBB(onlyLabel,filter); 1.1521 - } 1.1522 - else if(expr.getRightArg() instanceof GeneralDBDoubleValue) //case met in buffer! 1.1523 - { 1.1524 - append(((GeneralDBDoubleValue)expr.getRightArg()), filter); 1.1525 - } 1.1526 - else if(expr.getRightArg() instanceof GeneralDBNumericColumn) //case met in buffer! 1.1527 - { 1.1528 - append(((GeneralDBNumericColumn)expr.getRightArg()), filter); 1.1529 - } 1.1530 - //case met in buffer when in select -> buffer(?spatial,?thematic) 1.1531 - else if(expr.getRightArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getRightArg()).isSpatial()) 1.1532 - { 1.1533 - append(((GeneralDBLabelColumn)expr.getRightArg()),filter); 1.1534 - appendCastToDouble(filter); 1.1535 - } 1.1536 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialMetricBinary) 1.1537 - { 1.1538 - appendMetricFunction(expr.getRightArg(), filter); 1.1539 - } 1.1540 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialMetricUnary) 1.1541 - { 1.1542 - appendMetricFunction(expr.getRightArg(), filter); 1.1543 - } 1.1544 - else 1.1545 - { 1.1546 - appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter); 1.1547 - } 1.1548 - 1.1549 - // } 1.1550 - //3rd arg 1.1551 - filter.appendComma(); 1.1552 - // boolean check3 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1553 - // if(check3) 1.1554 - // { 1.1555 - // this.append((GeneralDBSqlNull)expr.getThirdArg(), filter); 1.1556 - // } 1.1557 - // else 1.1558 - // { 1.1559 - 1.1560 - if(expr.getThirdArg() instanceof GeneralDBStringValue) 1.1561 - { 1.1562 - append(((GeneralDBStringValue)expr.getThirdArg()),filter); 1.1563 - } 1.1564 - else if(expr.getThirdArg() instanceof GeneralDBSqlCase) 1.1565 - { 1.1566 - append(((GeneralDBSqlCase)expr.getThirdArg()),filter); 1.1567 - } 1.1568 - //case met in buffer when in select -> buffer(?spatial,?thematic) 1.1569 - else if(expr.getThirdArg() instanceof GeneralDBLabelColumn )//&& !((GeneralDBLabelColumn)expr.getThirdArg()).isSpatial()) 1.1570 - { 1.1571 - 1.1572 - append(((GeneralDBLabelColumn)expr.getThirdArg()),filter); 1.1573 - } 1.1574 - 1.1575 - 1.1576 - // } 1.1577 - filter.closeBracket(); 1.1578 - } 1.1579 - 1.1580 - filter.closeBracket(); 1.1581 - } 1.1582 - 1.1583 - 1.1584 - //GeoSPARQL 1.1585 - //XXX 1.1586 - protected void appendRelate(BinaryGeneralDBOperator expr, PostGISSqlExprBuilder filter, char[] intersectionPattern) 1.1587 - throws UnsupportedRdbmsOperatorException 1.1588 - { 1.1589 - filter.openBracket(); 1.1590 - 1.1591 - boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1592 - boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1593 - 1.1594 - if(check1) 1.1595 - { 1.1596 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.1597 - 1.1598 - } 1.1599 - else if(check2) 1.1600 - { 1.1601 - this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.1602 - } 1.1603 - else 1.1604 - { 1.1605 - filter.appendFunction("ST_Relate"); 1.1606 - 1.1607 - 1.1608 - filter.openBracket(); 1.1609 - if(expr.getLeftArg() instanceof GeneralDBStringValue) 1.1610 - { 1.1611 - appendWKT(expr.getLeftArg(),filter); 1.1612 - } 1.1613 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1614 - { 1.1615 - appendConstructFunction(expr.getLeftArg(), filter); 1.1616 - } 1.1617 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1618 - { 1.1619 - appendConstructFunction(expr.getLeftArg(), filter); 1.1620 - } 1.1621 - else if(expr.getLeftArg() instanceof GeneralDBSqlCase) 1.1622 - { 1.1623 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getLeftArg()).getEntries().get(0).getResult(); 1.1624 - appendMBB(onlyLabel,filter); 1.1625 - } 1.1626 - else 1.1627 - { 1.1628 - appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 1.1629 - } 1.1630 - filter.appendComma(); 1.1631 - 1.1632 - if(expr.getRightArg() instanceof GeneralDBStringValue) 1.1633 - { 1.1634 - appendWKT(expr.getRightArg(),filter); 1.1635 - } 1.1636 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.1637 - { 1.1638 - appendConstructFunction(expr.getRightArg(), filter); 1.1639 - } 1.1640 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.1641 - { 1.1642 - appendConstructFunction(expr.getRightArg(), filter); 1.1643 - } 1.1644 - else if(expr.getRightArg() instanceof GeneralDBSqlCase) 1.1645 - { 1.1646 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getRightArg()).getEntries().get(0).getResult(); 1.1647 - appendMBB(onlyLabel,filter); 1.1648 - } 1.1649 - else if(expr.getRightArg() instanceof GeneralDBDoubleValue) //case met in buffer! 1.1650 - { 1.1651 - append(((GeneralDBDoubleValue)expr.getRightArg()), filter); 1.1652 - } 1.1653 - else if(expr.getRightArg() instanceof GeneralDBNumericColumn) //case met in buffer! 1.1654 - { 1.1655 - append(((GeneralDBNumericColumn)expr.getRightArg()), filter); 1.1656 - } 1.1657 - //case met in buffer when in select -> buffer(?spatial,?thematic) 1.1658 - else if(expr.getRightArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getRightArg()).isSpatial()) 1.1659 - { 1.1660 - append(((GeneralDBLabelColumn)expr.getRightArg()),filter); 1.1661 - appendCastToDouble(filter); 1.1662 - } 1.1663 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialMetricBinary) 1.1664 - { 1.1665 - appendMetricFunction(expr.getRightArg(), filter); 1.1666 - } 1.1667 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialMetricUnary) 1.1668 - { 1.1669 - appendMetricFunction(expr.getRightArg(), filter); 1.1670 - } 1.1671 - else 1.1672 - { 1.1673 - appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter); 1.1674 - } 1.1675 - 1.1676 - //3rd arg 1.1677 - filter.appendComma(); 1.1678 - 1.1679 - //must turn the table of characters I have to a valid sql value! 1.1680 - filter.append("'"); 1.1681 - for(int i = 0; i< intersectionPattern.length; i++) 1.1682 - { 1.1683 - filter.append(intersectionPattern[i]+""); 1.1684 - } 1.1685 - filter.append("'"); 1.1686 - 1.1687 - filter.closeBracket(); 1.1688 - 1.1689 - } 1.1690 - 1.1691 - filter.closeBracket(); 1.1692 - } 1.1693 - 1.1694 - 1.1695 - protected void appendgeoSPARQLSpatialRelation(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, SpatialFunctionsPostGIS func) 1.1696 - throws UnsupportedRdbmsOperatorException 1.1697 - { 1.1698 - filter.openBracket(); 1.1699 - boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.1700 - if(check1) 1.1701 - { 1.1702 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.1703 - 1.1704 - } 1.1705 - else 1.1706 - { 1.1707 - char[][] intersectionPattern = null; 1.1708 - switch(func) 1.1709 - { 1.1710 - case ST_Covers: 1.1711 - intersectionPattern = new char[1][9]; 1.1712 - intersectionPattern[0][0] = 'T'; 1.1713 - intersectionPattern[0][1] = '*'; 1.1714 - intersectionPattern[0][2] = 'T'; 1.1715 - intersectionPattern[0][3] = 'F'; 1.1716 - intersectionPattern[0][4] = 'T'; 1.1717 - intersectionPattern[0][5] = '*'; 1.1718 - intersectionPattern[0][6] = 'F'; 1.1719 - intersectionPattern[0][7] = 'F'; 1.1720 - intersectionPattern[0][8] = '*'; 1.1721 - break; 1.1722 - case ST_CoveredBy: 1.1723 - intersectionPattern = new char[1][9]; 1.1724 - intersectionPattern[0][0] = 'T'; 1.1725 - intersectionPattern[0][1] = 'F'; 1.1726 - intersectionPattern[0][2] = 'F'; 1.1727 - intersectionPattern[0][3] = '*'; 1.1728 - intersectionPattern[0][4] = 'T'; 1.1729 - intersectionPattern[0][5] = 'F'; 1.1730 - intersectionPattern[0][6] = 'T'; 1.1731 - intersectionPattern[0][7] = '*'; 1.1732 - intersectionPattern[0][8] = '*'; 1.1733 - break; 1.1734 - case SF_Contains: 1.1735 - intersectionPattern = new char[1][9]; 1.1736 - intersectionPattern[0][0] = 'T'; 1.1737 - intersectionPattern[0][1] = '*'; 1.1738 - intersectionPattern[0][2] = '*'; 1.1739 - intersectionPattern[0][3] = '*'; 1.1740 - intersectionPattern[0][4] = '*'; 1.1741 - intersectionPattern[0][5] = '*'; 1.1742 - intersectionPattern[0][6] = 'F'; 1.1743 - intersectionPattern[0][7] = 'F'; 1.1744 - intersectionPattern[0][8] = '*'; 1.1745 - break; 1.1746 - case SF_Crosses: 1.1747 - intersectionPattern = new char[1][9]; 1.1748 - intersectionPattern[0][0] = 'T'; 1.1749 - intersectionPattern[0][1] = '*'; 1.1750 - intersectionPattern[0][2] = 'T'; 1.1751 - intersectionPattern[0][3] = '*'; 1.1752 - intersectionPattern[0][4] = '*'; 1.1753 - intersectionPattern[0][5] = '*'; 1.1754 - intersectionPattern[0][6] = '*'; 1.1755 - intersectionPattern[0][7] = '*'; 1.1756 - intersectionPattern[0][8] = '*'; 1.1757 - break; 1.1758 - case SF_Disjoint: 1.1759 - case EH_Disjoint: 1.1760 - intersectionPattern = new char[1][9]; 1.1761 - intersectionPattern[0][0] = 'F'; 1.1762 - intersectionPattern[0][1] = 'F'; 1.1763 - intersectionPattern[0][2] = '*'; 1.1764 - intersectionPattern[0][3] = 'F'; 1.1765 - intersectionPattern[0][4] = 'F'; 1.1766 - intersectionPattern[0][5] = '*'; 1.1767 - intersectionPattern[0][6] = '*'; 1.1768 - intersectionPattern[0][7] = '*'; 1.1769 - intersectionPattern[0][8] = '*'; 1.1770 - break; 1.1771 - case SF_Equals: 1.1772 - case EH_Equals: 1.1773 - case RCC8_Eq: 1.1774 - intersectionPattern = new char[1][9]; 1.1775 - intersectionPattern[0][0] = 'T'; 1.1776 - intersectionPattern[0][1] = 'F'; 1.1777 - intersectionPattern[0][2] = 'F'; 1.1778 - intersectionPattern[0][3] = 'F'; 1.1779 - intersectionPattern[0][4] = 'T'; 1.1780 - intersectionPattern[0][5] = 'F'; 1.1781 - intersectionPattern[0][6] = 'F'; 1.1782 - intersectionPattern[0][7] = 'F'; 1.1783 - intersectionPattern[0][8] = 'T'; 1.1784 - break; 1.1785 - case SF_Overlaps: 1.1786 - case EH_Overlap: 1.1787 - intersectionPattern = new char[1][9]; 1.1788 - intersectionPattern[0][0] = 'T'; 1.1789 - intersectionPattern[0][1] = '*'; 1.1790 - intersectionPattern[0][2] = 'T'; 1.1791 - intersectionPattern[0][3] = '*'; 1.1792 - intersectionPattern[0][4] = '*'; 1.1793 - intersectionPattern[0][5] = '*'; 1.1794 - intersectionPattern[0][6] = 'T'; 1.1795 - intersectionPattern[0][7] = '*'; 1.1796 - intersectionPattern[0][8] = '*'; 1.1797 - break; 1.1798 - case SF_Within: 1.1799 - intersectionPattern = new char[1][9]; 1.1800 - intersectionPattern[0][0] = 'T'; 1.1801 - intersectionPattern[0][1] = '*'; 1.1802 - intersectionPattern[0][2] = 'F'; 1.1803 - intersectionPattern[0][3] = '*'; 1.1804 - intersectionPattern[0][4] = '*'; 1.1805 - intersectionPattern[0][5] = 'F'; 1.1806 - intersectionPattern[0][6] = '*'; 1.1807 - intersectionPattern[0][7] = '*'; 1.1808 - intersectionPattern[0][8] = '*'; 1.1809 - break; 1.1810 - case EH_Covers: 1.1811 - intersectionPattern = new char[1][9]; 1.1812 - intersectionPattern[0][0] = 'T'; 1.1813 - intersectionPattern[0][1] = '*'; 1.1814 - intersectionPattern[0][2] = 'T'; 1.1815 - intersectionPattern[0][3] = 'F'; 1.1816 - intersectionPattern[0][4] = 'T'; 1.1817 - intersectionPattern[0][5] = '*'; 1.1818 - intersectionPattern[0][6] = 'F'; 1.1819 - intersectionPattern[0][7] = 'F'; 1.1820 - intersectionPattern[0][8] = '*'; 1.1821 - break; 1.1822 - case EH_CoveredBy: 1.1823 - intersectionPattern = new char[1][9]; 1.1824 - intersectionPattern[0][0] = 'T'; 1.1825 - intersectionPattern[0][1] = 'F'; 1.1826 - intersectionPattern[0][2] = 'F'; 1.1827 - intersectionPattern[0][3] = '*'; 1.1828 - intersectionPattern[0][4] = 'T'; 1.1829 - intersectionPattern[0][5] = 'F'; 1.1830 - intersectionPattern[0][6] = 'T'; 1.1831 - intersectionPattern[0][7] = '*'; 1.1832 - intersectionPattern[0][8] = '*'; 1.1833 - break; 1.1834 - case EH_Inside: 1.1835 - intersectionPattern = new char[1][9]; 1.1836 - intersectionPattern[0][0] = 'T'; 1.1837 - intersectionPattern[0][1] = 'F'; 1.1838 - intersectionPattern[0][2] = 'F'; 1.1839 - intersectionPattern[0][3] = '*'; 1.1840 - intersectionPattern[0][4] = 'F'; 1.1841 - intersectionPattern[0][5] = 'F'; 1.1842 - intersectionPattern[0][6] = 'T'; 1.1843 - intersectionPattern[0][7] = '*'; 1.1844 - intersectionPattern[0][8] = '*'; 1.1845 - break; 1.1846 - case EH_Contains: 1.1847 - intersectionPattern = new char[1][9]; 1.1848 - intersectionPattern[0][0] = 'T'; 1.1849 - intersectionPattern[0][1] = '*'; 1.1850 - intersectionPattern[0][2] = 'T'; 1.1851 - intersectionPattern[0][3] = 'F'; 1.1852 - intersectionPattern[0][4] = 'F'; 1.1853 - intersectionPattern[0][5] = '*'; 1.1854 - intersectionPattern[0][6] = 'F'; 1.1855 - intersectionPattern[0][7] = 'F'; 1.1856 - intersectionPattern[0][8] = '*'; 1.1857 - break; 1.1858 - case RCC8_Dc: 1.1859 - intersectionPattern = new char[1][9]; 1.1860 - intersectionPattern[0][0] = 'F'; 1.1861 - intersectionPattern[0][1] = 'F'; 1.1862 - intersectionPattern[0][2] = 'T'; 1.1863 - intersectionPattern[0][3] = 'F'; 1.1864 - intersectionPattern[0][4] = 'F'; 1.1865 - intersectionPattern[0][5] = 'T'; 1.1866 - intersectionPattern[0][6] = 'T'; 1.1867 - intersectionPattern[0][7] = 'T'; 1.1868 - intersectionPattern[0][8] = 'T'; 1.1869 - break; 1.1870 - case RCC8_Ec: 1.1871 - intersectionPattern = new char[1][9]; 1.1872 - intersectionPattern[0][0] = 'F'; 1.1873 - intersectionPattern[0][1] = 'F'; 1.1874 - intersectionPattern[0][2] = 'T'; 1.1875 - intersectionPattern[0][3] = 'F'; 1.1876 - intersectionPattern[0][4] = 'T'; 1.1877 - intersectionPattern[0][5] = 'T'; 1.1878 - intersectionPattern[0][6] = 'T'; 1.1879 - intersectionPattern[0][7] = 'T'; 1.1880 - intersectionPattern[0][8] = 'T'; 1.1881 - break; 1.1882 - case RCC8_Po: 1.1883 - intersectionPattern = new char[1][9]; 1.1884 - intersectionPattern[0][0] = 'T'; 1.1885 - intersectionPattern[0][1] = 'T'; 1.1886 - intersectionPattern[0][2] = 'T'; 1.1887 - intersectionPattern[0][3] = 'T'; 1.1888 - intersectionPattern[0][4] = 'T'; 1.1889 - intersectionPattern[0][5] = 'T'; 1.1890 - intersectionPattern[0][6] = 'T'; 1.1891 - intersectionPattern[0][7] = 'T'; 1.1892 - intersectionPattern[0][8] = 'T'; 1.1893 - break; 1.1894 - case RCC8_Tppi: 1.1895 - intersectionPattern = new char[1][9]; 1.1896 - intersectionPattern[0][0] = 'T'; 1.1897 - intersectionPattern[0][1] = 'T'; 1.1898 - intersectionPattern[0][2] = 'T'; 1.1899 - intersectionPattern[0][3] = 'F'; 1.1900 - intersectionPattern[0][4] = 'T'; 1.1901 - intersectionPattern[0][5] = 'T'; 1.1902 - intersectionPattern[0][6] = 'F'; 1.1903 - intersectionPattern[0][7] = 'F'; 1.1904 - intersectionPattern[0][8] = 'T'; 1.1905 - break; 1.1906 - case RCC8_Tpp: 1.1907 - intersectionPattern = new char[1][9]; 1.1908 - intersectionPattern[0][0] = 'T'; 1.1909 - intersectionPattern[0][1] = 'F'; 1.1910 - intersectionPattern[0][2] = 'F'; 1.1911 - intersectionPattern[0][3] = 'T'; 1.1912 - intersectionPattern[0][4] = 'T'; 1.1913 - intersectionPattern[0][5] = 'F'; 1.1914 - intersectionPattern[0][6] = 'T'; 1.1915 - intersectionPattern[0][7] = 'T'; 1.1916 - intersectionPattern[0][8] = 'T'; 1.1917 - break; 1.1918 - case RCC8_Ntpp: 1.1919 - intersectionPattern = new char[1][9]; 1.1920 - intersectionPattern[0][0] = 'T'; 1.1921 - intersectionPattern[0][1] = 'F'; 1.1922 - intersectionPattern[0][2] = 'F'; 1.1923 - intersectionPattern[0][3] = 'T'; 1.1924 - intersectionPattern[0][4] = 'F'; 1.1925 - intersectionPattern[0][5] = 'F'; 1.1926 - intersectionPattern[0][6] = 'T'; 1.1927 - intersectionPattern[0][7] = 'T'; 1.1928 - intersectionPattern[0][8] = 'T'; 1.1929 - break; 1.1930 - case RCC8_Ntppi: 1.1931 - intersectionPattern = new char[1][9]; 1.1932 - intersectionPattern[0][0] = 'T'; 1.1933 - intersectionPattern[0][1] = 'T'; 1.1934 - intersectionPattern[0][2] = 'T'; 1.1935 - intersectionPattern[0][3] = 'F'; 1.1936 - intersectionPattern[0][4] = 'F'; 1.1937 - intersectionPattern[0][5] = 'T'; 1.1938 - intersectionPattern[0][6] = 'F'; 1.1939 - intersectionPattern[0][7] = 'F'; 1.1940 - intersectionPattern[0][8] = 'T'; 1.1941 - break; 1.1942 - case SF_Intersects: 1.1943 - intersectionPattern = new char[4][9]; 1.1944 - intersectionPattern[0][0] = 'T'; 1.1945 - intersectionPattern[0][1] = '*'; 1.1946 - intersectionPattern[0][2] = '*'; 1.1947 - intersectionPattern[0][3] = '*'; 1.1948 - intersectionPattern[0][4] = '*'; 1.1949 - intersectionPattern[0][5] = '*'; 1.1950 - intersectionPattern[0][6] = '*'; 1.1951 - intersectionPattern[0][7] = '*'; 1.1952 - intersectionPattern[0][8] = '*'; 1.1953 - // 1.1954 - intersectionPattern[1][0] = '*'; 1.1955 - intersectionPattern[1][1] = 'T'; 1.1956 - intersectionPattern[1][2] = '*'; 1.1957 - intersectionPattern[1][3] = '*'; 1.1958 - intersectionPattern[1][4] = '*'; 1.1959 - intersectionPattern[1][5] = '*'; 1.1960 - intersectionPattern[1][6] = '*'; 1.1961 - intersectionPattern[1][7] = '*'; 1.1962 - intersectionPattern[1][8] = '*'; 1.1963 - // 1.1964 - intersectionPattern[2][0] = '*'; 1.1965 - intersectionPattern[2][1] = '*'; 1.1966 - intersectionPattern[2][2] = '*'; 1.1967 - intersectionPattern[2][3] = 'T'; 1.1968 - intersectionPattern[2][4] = '*'; 1.1969 - intersectionPattern[2][5] = '*'; 1.1970 - intersectionPattern[2][6] = '*'; 1.1971 - intersectionPattern[2][7] = '*'; 1.1972 - intersectionPattern[2][8] = '*'; 1.1973 - // 1.1974 - intersectionPattern[3][0] = '*'; 1.1975 - intersectionPattern[3][1] = '*'; 1.1976 - intersectionPattern[3][2] = '*'; 1.1977 - intersectionPattern[3][3] = '*'; 1.1978 - intersectionPattern[3][4] = 'T'; 1.1979 - intersectionPattern[3][5] = '*'; 1.1980 - intersectionPattern[3][6] = '*'; 1.1981 - intersectionPattern[3][7] = '*'; 1.1982 - intersectionPattern[3][8] = '*'; 1.1983 - break; 1.1984 - 1.1985 - case SF_Touches: 1.1986 - case EH_Meet: 1.1987 - intersectionPattern = new char[3][9]; 1.1988 - intersectionPattern[0][0] = 'F'; 1.1989 - intersectionPattern[0][1] = 'T'; 1.1990 - intersectionPattern[0][2] = '*'; 1.1991 - intersectionPattern[0][3] = '*'; 1.1992 - intersectionPattern[0][4] = '*'; 1.1993 - intersectionPattern[0][5] = '*'; 1.1994 - intersectionPattern[0][6] = '*'; 1.1995 - intersectionPattern[0][7] = '*'; 1.1996 - intersectionPattern[0][8] = '*'; 1.1997 - // 1.1998 - intersectionPattern[1][0] = 'F'; 1.1999 - intersectionPattern[1][1] = '*'; 1.2000 - intersectionPattern[1][2] = '*'; 1.2001 - intersectionPattern[1][3] = 'T'; 1.2002 - intersectionPattern[1][4] = '*'; 1.2003 - intersectionPattern[1][5] = '*'; 1.2004 - intersectionPattern[1][6] = '*'; 1.2005 - intersectionPattern[1][7] = '*'; 1.2006 - intersectionPattern[1][8] = '*'; 1.2007 - // 1.2008 - intersectionPattern[2][0] = 'F'; 1.2009 - intersectionPattern[2][1] = '*'; 1.2010 - intersectionPattern[2][2] = '*'; 1.2011 - intersectionPattern[2][3] = '*'; 1.2012 - intersectionPattern[2][4] = 'T'; 1.2013 - intersectionPattern[2][5] = '*'; 1.2014 - intersectionPattern[2][6] = '*'; 1.2015 - intersectionPattern[2][7] = '*'; 1.2016 - intersectionPattern[2][8] = '*'; 1.2017 - // 1.2018 - 1.2019 - } 1.2020 - 1.2021 - for(int i = 0; i < intersectionPattern.length ; i++) 1.2022 - { 1.2023 - appendRelate(expr, filter, intersectionPattern[i]); 1.2024 - if(i < intersectionPattern.length - 1) 1.2025 - { 1.2026 - //append OR and continue 1.2027 - filter.or(); 1.2028 - } 1.2029 - } 1.2030 - 1.2031 - //Also need bounding box intersection query to enable the usage of the Gist R-tree index 1.2032 - if(func != SpatialFunctionsPostGIS.SF_Disjoint && func != SpatialFunctionsPostGIS.EH_Disjoint && func != SpatialFunctionsPostGIS.RCC8_Dc) 1.2033 - { 1.2034 - filter.and(); 1.2035 - appendGeneralDBSpatialFunctionBinary(expr, filter,SpatialFunctionsPostGIS.ST_Intersects); 1.2036 - } 1.2037 - } 1.2038 - filter.closeBracket(); 1.2039 - } 1.2040 - 1.2041 - @Override 1.2042 - //GeoSPARQL 1.2043 - //XXX 1.2044 - 1.2045 - protected void appendRelate(BinaryGeneralDBOperator expr, GeneralDBSqlExprBuilder filter, char[] intersectionPattern) 1.2046 - throws UnsupportedRdbmsOperatorException 1.2047 - { 1.2048 - filter.openBracket(); 1.2049 - System.out.println(expr.getLeftArg().getClass().getCanonicalName()); 1.2050 - boolean check1 = expr.getLeftArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.2051 - if(check1) 1.2052 - { 1.2053 - this.append((GeneralDBSqlNull)expr.getLeftArg(), filter); 1.2054 - 1.2055 - } 1.2056 - else 1.2057 - { 1.2058 - filter.appendFunction("ST_Relate"); 1.2059 - 1.2060 - 1.2061 - filter.openBracket(); 1.2062 - if(expr.getLeftArg() instanceof GeneralDBStringValue) 1.2063 - { 1.2064 - appendWKT(expr.getLeftArg(),filter); 1.2065 - } 1.2066 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.2067 - { 1.2068 - appendConstructFunction(expr.getLeftArg(), filter); 1.2069 - } 1.2070 - else if(expr.getLeftArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.2071 - { 1.2072 - appendConstructFunction(expr.getLeftArg(), filter); 1.2073 - } 1.2074 - else if(expr.getLeftArg() instanceof GeneralDBSqlCase) 1.2075 - { 1.2076 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getLeftArg()).getEntries().get(0).getResult(); 1.2077 - appendMBB(onlyLabel,filter); 1.2078 - } 1.2079 - else 1.2080 - { 1.2081 - appendMBB((GeneralDBLabelColumn)(expr.getLeftArg()),filter); 1.2082 - } 1.2083 - filter.appendComma(); 1.2084 - boolean check2 = expr.getRightArg().getClass().getCanonicalName().equals("org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull"); 1.2085 - if(check2) 1.2086 - { 1.2087 - this.append((GeneralDBSqlNull)expr.getRightArg(), filter); 1.2088 - } 1.2089 - else 1.2090 - { 1.2091 - if(expr.getRightArg() instanceof GeneralDBStringValue) 1.2092 - { 1.2093 - appendWKT(expr.getRightArg(),filter); 1.2094 - } 1.2095 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructUnary) 1.2096 - { 1.2097 - appendConstructFunction(expr.getRightArg(), filter); 1.2098 - } 1.2099 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialConstructBinary) 1.2100 - { 1.2101 - appendConstructFunction(expr.getRightArg(), filter); 1.2102 - } 1.2103 - else if(expr.getRightArg() instanceof GeneralDBSqlCase) 1.2104 - { 1.2105 - GeneralDBLabelColumn onlyLabel = (GeneralDBLabelColumn)((GeneralDBSqlCase)expr.getRightArg()).getEntries().get(0).getResult(); 1.2106 - appendMBB(onlyLabel,filter); 1.2107 - } 1.2108 - else if(expr.getRightArg() instanceof GeneralDBDoubleValue) //case met in buffer! 1.2109 - { 1.2110 - append(((GeneralDBDoubleValue)expr.getRightArg()), filter); 1.2111 - } 1.2112 - else if(expr.getRightArg() instanceof GeneralDBNumericColumn) //case met in buffer! 1.2113 - { 1.2114 - append(((GeneralDBNumericColumn)expr.getRightArg()), filter); 1.2115 - } 1.2116 - //case met in buffer when in select -> buffer(?spatial,?thematic) 1.2117 - else if(expr.getRightArg() instanceof GeneralDBLabelColumn && !((GeneralDBLabelColumn)expr.getRightArg()).isSpatial()) 1.2118 - { 1.2119 - append(((GeneralDBLabelColumn)expr.getRightArg()),filter); 1.2120 - appendCastToDouble(filter); 1.2121 - } 1.2122 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialMetricBinary) 1.2123 - { 1.2124 - appendMetricFunction(expr.getRightArg(), filter); 1.2125 - } 1.2126 - else if(expr.getRightArg() instanceof GeneralDBSqlSpatialMetricUnary) 1.2127 - { 1.2128 - appendMetricFunction(expr.getRightArg(), filter); 1.2129 - } 1.2130 - else 1.2131 - { 1.2132 - appendMBB((GeneralDBLabelColumn)(expr.getRightArg()),filter); 1.2133 - } 1.2134 - 1.2135 - } 1.2136 - //3rd arg 1.2137 - filter.appendComma(); 1.2138 - 1.2139 - //must turn the table of characters I have to a valid sql value! 1.2140 - filter.append("'"); 1.2141 - for(int i = 0; i< intersectionPattern.length; i++) 1.2142 - { 1.2143 - filter.append(intersectionPattern[i]+""); 1.2144 - } 1.2145 - filter.append("'"); 1.2146 - 1.2147 - filter.closeBracket(); 1.2148 - } 1.2149 - 1.2150 - filter.closeBracket(); 1.2151 - } 1.2152 - 1.2153 -}