Strabon
changeset 1112:d6d815e1dbb6
added <http://postgis.net/ST_MakeLine> extension function which is mapped to ST_MakeLine(geometry, geometry) function of PostGIS (http://postgis.org/docs/ST_MakeLine.html). It does not work yet, but it is almost complete (it needs some debugging)
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/evaluation/src/main/java/org/openrdf/query/algebra/evaluation/function/spatial/postgis/construct/MakeLine.java Sat Apr 27 03:53:29 2013 +0300 1.3 @@ -0,0 +1,29 @@ 1.4 +/** 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + * 1.9 + * Copyright (C) 2013, Pyravlos Team 1.10 + * 1.11 + * http://www.strabon.di.uoa.gr/ 1.12 + */ 1.13 +package org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct; 1.14 + 1.15 +import org.openrdf.query.algebra.evaluation.function.spatial.SpatialConstructFunc; 1.16 + 1.17 +import eu.earthobservatory.vocabulary.PostGIS; 1.18 + 1.19 +/** 1.20 + * This SPARQL extension function corresponds to the PostGIS 1.21 + * <code>ST_MakeLine(geometry geom1, geometry geom2)</code> function 1.22 + * as described in <a>http://postgis.org/docs/ST_MakeLine.html</a>. 1.23 + * 1.24 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 1.25 + */ 1.26 +public class MakeLine extends SpatialConstructFunc { 1.27 + 1.28 + @Override 1.29 + public String getURI() { 1.30 + return PostGIS.ST_MAKELINE; 1.31 + } 1.32 +}
2.1 --- a/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function Fri Apr 26 21:28:38 2013 +0300 2.2 +++ b/evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function Sat Apr 27 03:53:29 2013 +0300 2.3 @@ -80,4 +80,6 @@ 2.4 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeaturesWithinFunc 2.5 org.openrdf.query.algebra.evaluation.function.spatial.geosparql.sf.SimpleFeatureTouchesFunc 2.6 2.7 -org.openrdf.query.algebra.evaluation.function.datetime.stsparql.metric.DiffDateTime 2.8 \ No newline at end of file 2.9 +org.openrdf.query.algebra.evaluation.function.datetime.stsparql.metric.DiffDateTime 2.10 + 2.11 +org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.MakeLine 2.12 \ No newline at end of file
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/GeneralDBSqlST_MakeLine.java Sat Apr 27 03:53:29 2013 +0300 3.3 @@ -0,0 +1,30 @@ 3.4 +/** 3.5 + * This Source Code Form is subject to the terms of the Mozilla Public 3.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 3.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 3.8 + * 3.9 + * Copyright (C) 2013, Pyravlos Team 3.10 + * 3.11 + * http://www.strabon.di.uoa.gr/ 3.12 + */ 3.13 +package org.openrdf.sail.generaldb.algebra; 3.14 + 3.15 +import org.openrdf.sail.generaldb.algebra.base.GeneralDBQueryModelVisitorBase; 3.16 +import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr; 3.17 + 3.18 +/** 3.19 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 3.20 + */ 3.21 +public class GeneralDBSqlST_MakeLine extends GeneralDBSqlSpatialConstructBinary { 3.22 + 3.23 + public GeneralDBSqlST_MakeLine(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 3.24 + super(left, right); 3.25 + } 3.26 + 3.27 + @Override 3.28 + public <X extends Exception> void visit(GeneralDBQueryModelVisitorBase<X> visitor) 3.29 + throws X 3.30 + { 3.31 + visitor.meet(this); 3.32 + } 3.33 +}
4.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java Fri Apr 26 21:28:38 2013 +0300 4.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java Sat Apr 27 03:53:29 2013 +0300 4.3 @@ -63,6 +63,7 @@ 4.4 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRegex; 4.5 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 4.6 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 4.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 4.8 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlTouches; 4.9 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlWithin; 4.10 import org.openrdf.sail.generaldb.algebra.GeneralDBStringValue; 4.11 @@ -389,6 +390,14 @@ 4.12 return new GeneralDBSqlGeoSymDifference(left, right); 4.13 } 4.14 4.15 + /** PostGIS Construct functions **/ 4.16 + public static GeneralDBSqlExpr st_MakeLine(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 4.17 + 4.18 + return new GeneralDBSqlST_MakeLine(left, right); 4.19 + } 4.20 + /** PostGIS Construct functions **/ 4.21 + 4.22 + 4.23 /** Addition for datetime metric functions 4.24 * 4.25 * @author George Garbis <ggarbis@di.uoa.gr>
5.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java Fri Apr 26 21:28:38 2013 +0300 5.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java Sat Apr 27 03:53:29 2013 +0300 5.3 @@ -35,6 +35,7 @@ 5.4 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoBuffer; 5.5 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoConvexHull; 5.6 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoDifference; 5.7 +import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_MakeLine; 5.8 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoDistance; 5.9 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoEnvelope; 5.10 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoIntersection; 5.11 @@ -141,6 +142,7 @@ 5.12 import org.slf4j.LoggerFactory; 5.13 5.14 import eu.earthobservatory.constants.GeoConstants; 5.15 +import eu.earthobservatory.vocabulary.PostGIS; 5.16 5.17 /** 5.18 * Boolean SQL expression factory. This factory can convert a number of core 5.19 @@ -1251,6 +1253,10 @@ 5.20 { 5.21 return geoBuffer(leftArg, rightArg, thirdArg); 5.22 } 5.23 + else if (function.getURI().equals(PostGIS.ST_MAKELINE)) 5.24 + { 5.25 + return st_MakeLine(leftArg, rightArg); 5.26 + } 5.27 5.28 logger.error("[Strabon.spatialConstructPicker] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 5.29 return null;
6.1 --- a/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java Fri Apr 26 21:28:38 2013 +0300 6.2 +++ b/generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java Sat Apr 27 03:53:29 2013 +0300 6.3 @@ -75,6 +75,7 @@ 6.4 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRegex; 6.5 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 6.6 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 6.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 6.8 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlShift; 6.9 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlTouches; 6.10 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlWithin; 6.11 @@ -676,6 +677,11 @@ 6.12 else if (expr instanceof GeneralDBSqlDiffDateTime) { 6.13 append((GeneralDBSqlDiffDateTime)expr, filter); 6.14 } 6.15 + /* PostGIS Construct functions */ 6.16 + else if (expr instanceof GeneralDBSqlST_MakeLine) { 6.17 + append((GeneralDBSqlST_MakeLine)expr, filter); 6.18 + } 6.19 + /* PostGIS Construct functions */ 6.20 /** 6.21 * end of my addition 6.22 */ 6.23 @@ -1093,6 +1099,11 @@ 6.24 protected abstract void append(GeneralDBSqlGeoSymDifference expr, GeneralDBSqlExprBuilder filter) 6.25 throws UnsupportedRdbmsOperatorException; 6.26 6.27 + /* PostGIS Construct Functions */ 6.28 + protected abstract void append(GeneralDBSqlST_MakeLine expr, GeneralDBSqlExprBuilder filter) 6.29 + throws UnsupportedRdbmsOperatorException; 6.30 + /* PostGIS Construct Functions */ 6.31 + 6.32 /** Addition for datetime metric functions 6.33 * 6.34 * @author George Garbis <ggarbis@di.uoa.gr> 6.35 @@ -1192,6 +1203,16 @@ 6.36 { 6.37 append((GeneralDBSqlGeoSymDifference)constr, filter); 6.38 } 6.39 + else if(constr instanceof GeneralDBSqlGeoSymDifference) 6.40 + { 6.41 + append((GeneralDBSqlGeoSymDifference)constr, filter); 6.42 + } 6.43 + /* PostGIS functions */ 6.44 + else if(constr instanceof GeneralDBSqlST_MakeLine) 6.45 + { 6.46 + append((GeneralDBSqlST_MakeLine)constr, filter); 6.47 + } 6.48 + /* PostGIS functions */ 6.49 } 6.50 6.51 protected void appendMetricFunction(GeneralDBSqlExpr constr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException
7.1 --- a/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java Fri Apr 26 21:28:38 2013 +0300 7.2 +++ b/monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java Sat Apr 27 03:53:29 2013 +0300 7.3 @@ -55,6 +55,7 @@ 7.4 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlOverlaps; 7.5 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 7.6 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 7.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 7.8 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructBinary; 7.9 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructTriple; 7.10 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructUnary; 7.11 @@ -116,8 +117,8 @@ 7.12 public class MonetDBQueryBuilder extends GeneralDBQueryBuilder { 7.13 7.14 public static final String ST_TRANSFORM = "ST_Transform"; 7.15 - public static final String GEOGRAPHY = "Geography"; 7.16 - public static final String GEOMETRY = "Geometry"; 7.17 + public static final String GEOGRAPHY = "Geography"; 7.18 + public static final String GEOMETRY = "Geometry"; 7.19 7.20 /** 7.21 * If (spatial) label column met is null, I must not try to retrieve its srid. 7.22 @@ -2582,19 +2583,18 @@ 7.23 } 7.24 7.25 @Override 7.26 - protected void append(GeneralDBSqlMbbContains expr, 7.27 - GeneralDBSqlExprBuilder filter) 7.28 - throws UnsupportedRdbmsOperatorException { 7.29 - // TODO Auto-generated method stub 7.30 - 7.31 + protected void append(GeneralDBSqlMbbContains expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 7.32 + throw new UnsupportedRdbmsOperatorException("MbbContains is not available in MonetDB."); 7.33 } 7.34 7.35 @Override 7.36 - protected void append(GeneralDBSqlMbbWithin expr, 7.37 - GeneralDBSqlExprBuilder filter) 7.38 - throws UnsupportedRdbmsOperatorException { 7.39 - // TODO Auto-generated method stub 7.40 - 7.41 + protected void append(GeneralDBSqlMbbWithin expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 7.42 + throw new UnsupportedRdbmsOperatorException("MbbWithin is not available in MonetDB."); 7.43 + } 7.44 + 7.45 + @Override 7.46 + protected void append(GeneralDBSqlST_MakeLine expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 7.47 + throw new UnsupportedRdbmsOperatorException("ST_MakeLine is not available in MonetDB."); 7.48 } 7.49 7.50 }
8.1 --- a/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java Fri Apr 26 21:28:38 2013 +0300 8.2 +++ b/postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java Sat Apr 27 03:53:29 2013 +0300 8.3 @@ -56,6 +56,7 @@ 8.4 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlOverlaps; 8.5 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 8.6 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 8.7 +import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 8.8 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructBinary; 8.9 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructTriple; 8.10 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructUnary; 8.11 @@ -116,12 +117,12 @@ 8.12 */ 8.13 public class PostGISQueryBuilder extends GeneralDBQueryBuilder { 8.14 8.15 - public static final String STRDFGEO_FIELD = "strdfgeo"; 8.16 - public static final String SRID_FIELD = "srid"; 8.17 - public static final String ST_TRANSFORM = "ST_Transform"; 8.18 - public static final String ST_ASBINARY = "ST_AsBinary"; 8.19 - public static final String GEOGRAPHY = "Geography"; 8.20 - public static final String GEOMETRY = "Geometry"; 8.21 + public static final String STRDFGEO_FIELD = "strdfgeo"; 8.22 + public static final String SRID_FIELD = "srid"; 8.23 + public static final String ST_TRANSFORM = "ST_Transform"; 8.24 + public static final String ST_ASBINARY = "ST_AsBinary"; 8.25 + public static final String GEOGRAPHY = "Geography"; 8.26 + public static final String GEOMETRY = "Geometry"; 8.27 /** 8.28 * If (spatial) label column met is null, I must not try to retrieve its srid. 8.29 * Opting to ask for 'null' instead 8.30 @@ -149,6 +150,9 @@ 8.31 ST_Buffer, 8.32 ST_Transform, 8.33 ST_SymDifference, 8.34 + 8.35 + // Spatial Constructs - Binary (PostGIS namespace) 8.36 + ST_MakeLine, 8.37 8.38 8.39 //Spatial Constructs - Unary 8.40 @@ -752,10 +756,15 @@ 8.41 8.42 @Override 8.43 protected void append(GeneralDBSqlGeoSymDifference expr, GeneralDBSqlExprBuilder filter) 8.44 - throws UnsupportedRdbmsOperatorException 8.45 - { 8.46 + throws UnsupportedRdbmsOperatorException 8.47 + { 8.48 appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_SymDifference); 8.49 - } 8.50 + } 8.51 + 8.52 + @Override 8.53 + protected void append(GeneralDBSqlST_MakeLine expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 8.54 + appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_MakeLine); 8.55 + } 8.56 8.57 /** Addition for datetime metric functions 8.58 * 8.59 @@ -808,10 +817,10 @@ 8.60 8.61 @Override 8.62 protected void append(GeneralDBSqlGeoAsGML expr, GeneralDBSqlExprBuilder filter) 8.63 - throws UnsupportedRdbmsOperatorException 8.64 - { 8.65 + throws UnsupportedRdbmsOperatorException 8.66 + { 8.67 appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_AsGML); 8.68 - } 8.69 + } 8.70 8.71 // @Override 8.72 // protected void append(GeneralDBSqlGeoSrid expr, GeneralDBSqlExprBuilder filter) 8.73 @@ -1514,6 +1523,9 @@ 8.74 case ST_SymDifference: filter.appendFunction("ST_SymDifference"); break; 8.75 case ST_Buffer: filter.appendFunction("ST_Buffer"); break; 8.76 8.77 + // PostGIS 8.78 + case ST_MakeLine: filter.appendFunction("ST_MakeLine"); break; 8.79 + 8.80 case ST_Equals: filter.appendFunction("ST_Equals"); break; 8.81 case ST_Disjoint: filter.appendFunction("ST_Disjoint"); break; 8.82 case ST_Intersects: filter.appendFunction("ST_Intersects"); break; 8.83 @@ -2962,6 +2974,6 @@ 8.84 } 8.85 8.86 filter.closeBracket(); 8.87 - } 8.88 + } 8.89 8.90 }
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/vocab/src/main/java/eu/earthobservatory/vocabulary/PostGIS.java Sat Apr 27 03:53:29 2013 +0300 9.3 @@ -0,0 +1,21 @@ 9.4 +/** 9.5 + * This Source Code Form is subject to the terms of the Mozilla Public 9.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 9.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. 9.8 + * 9.9 + * Copyright (C) 2013, Pyravlos Team 9.10 + * 9.11 + * http://www.strabon.di.uoa.gr/ 9.12 + */ 9.13 +package eu.earthobservatory.vocabulary; 9.14 + 9.15 +/** 9.16 + * @author Charalampos Nikolaou <charnik@di.uoa.gr> 9.17 + */ 9.18 +public class PostGIS { 9.19 + 9.20 + public static final String NAMESPACE = "http://postgis.net/"; 9.21 + 9.22 + /** Construct functions **/ 9.23 + public static final String ST_MAKELINE = NAMESPACE + "ST_MakeLine"; 9.24 +}