Strabon
changeset 1413:97064bbd8442
buffer in meters in SELECT clauses containing only constants is not supported yet (TODO), but we log a corresponding message and we do the computation in degrees :)
author | Babis Nikolaou <charnik@di.uoa.gr> |
---|---|
date | Mon Sep 22 13:34:35 2014 +0300 (2014-09-22) |
parents | 8dc244d8f18a |
children | eb28e195755a |
files | generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java |
line diff
1.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Mon Sep 22 13:12:18 2014 +0300 1.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBEvaluation.java Mon Sep 22 13:34:35 2014 +0300 1.3 @@ -56,6 +56,7 @@ 1.4 import org.openrdf.query.algebra.evaluation.function.spatial.geosparql.property.GeoSparqlGetSRIDFunc; 1.5 import org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.Centroid; 1.6 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BoundaryFunc; 1.7 +import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BufferFunc; 1.8 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.AreaFunc; 1.9 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.metric.DistanceFunc; 1.10 import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.property.AsGMLFunc; 1.11 @@ -136,6 +137,7 @@ 1.12 import com.vividsolutions.jts.io.ParseException; 1.13 1.14 import eu.earthobservatory.constants.GeoConstants; 1.15 +import eu.earthobservatory.constants.OGCConstants; 1.16 1.17 /** 1.18 * Extends the default strategy by accepting {@link GeneralDBSelectQuery} and evaluating 1.19 @@ -298,15 +300,23 @@ 1.20 // evaluated second argument of function (if any) 1.21 Value rightResult = null; 1.22 1.23 + // evaluated third argument of function (if any) 1.24 + Value thirdResult = null; 1.25 + 1.26 // evaluate first argument 1.27 leftResult = evaluate(left, bindings); 1.28 1.29 - // function call with 2 arguments, evaluate the second one now 1.30 + // function call with 2 or more arguments, evaluate the second one now 1.31 // see distance function as example 1.32 - if ( fc.getArgs().size() == 2 ) 1.33 + if ( fc.getArgs().size() > 2 ) 1.34 { 1.35 ValueExpr right = fc.getArgs().get(1); 1.36 rightResult = evaluate(right, bindings); 1.37 + 1.38 + if (fc.getArgs().size() == 3) { 1.39 + ValueExpr third = fc.getArgs().get(2); 1.40 + thirdResult = evaluate(third, bindings); 1.41 + } 1.42 } 1.43 1.44 // having evaluated the arguments of the function, evaluate the function 1.45 @@ -343,7 +353,7 @@ 1.46 // SPATIAL CONSTRUCT FUNCTIONS 1.47 // 1.48 else if (function instanceof SpatialConstructFunc) { 1.49 - return spatialConstructPicker(function, leftResult, rightResult); 1.50 + return spatialConstructPicker(function, leftResult, rightResult, thirdResult); 1.51 } 1.52 1.53 // 1.54 @@ -487,7 +497,7 @@ 1.55 } 1.56 } 1.57 1.58 - public StrabonPolyhedron spatialConstructPicker(Function function, Value left, Value right) throws Exception 1.59 + public StrabonPolyhedron spatialConstructPicker(Function function, Value left, Value right, Value thirdResult) throws Exception 1.60 { 1.61 StrabonPolyhedron leftArg = getValueAsStrabonPolyhedron(left); 1.62 if(function.getURI().equals(GeoConstants.stSPARQLunion)) 1.63 @@ -495,19 +505,24 @@ 1.64 StrabonPolyhedron rightArg = ((GeneralDBPolyhedron) right).getPolyhedron(); 1.65 return StrabonPolyhedron.union(leftArg, rightArg); 1.66 } 1.67 - else if(function.getURI().equals(GeoConstants.stSPARQLbuffer)) 1.68 - { 1.69 + else if (function instanceof BufferFunc) { 1.70 + // TODO implement computation of the buffer in meters 1.71 + // you'll get the type (degrees/meter) from the thirdResult, which 1.72 + // would be a URI. 1.73 + if (OGCConstants.OGCmetre.equals(thirdResult.stringValue())) { 1.74 + logger.info("[GeneraDBEvaluation] Computation of {} will be done in degrees.", function.getURI()); 1.75 + } 1.76 + 1.77 if(right instanceof LiteralImpl) 1.78 { 1.79 LiteralImpl radius = (LiteralImpl) right; 1.80 - return StrabonPolyhedron.buffer(leftArg,radius.doubleValue()); 1.81 + return StrabonPolyhedron.buffer(leftArg, radius.doubleValue()); 1.82 } 1.83 - else if(right instanceof RdbmsLiteral) 1.84 + else if (right instanceof RdbmsLiteral) 1.85 { 1.86 RdbmsLiteral radius = (RdbmsLiteral) right; 1.87 - return StrabonPolyhedron.buffer(leftArg,radius.doubleValue()); 1.88 + return StrabonPolyhedron.buffer(leftArg, radius.doubleValue()); 1.89 } 1.90 - 1.91 } 1.92 else if(function.getURI().equals(GeoConstants.stSPARQLtransform)) 1.93 { 1.94 @@ -537,6 +552,7 @@ 1.95 else if(function instanceof BoundaryFunc) 1.96 { 1.97 return StrabonPolyhedron.boundary(leftArg); 1.98 + 1.99 } 1.100 else if(function.getURI().equals(GeoConstants.stSPARQLintersection)) 1.101 { 1.102 @@ -556,7 +572,7 @@ 1.103 } else if (function instanceof Centroid) { 1.104 return leftArg.getCentroid(); 1.105 1.106 - } //else if (function instanceof MakeLine) { 1.107 + } //else if (function instanceof MakeLine) { // TODO add 1.108 // return null; 1.109 //} 1.110