Changeset 1116:db18575a8e6f


Ignore:
Timestamp:
04/27/13 14:36:45 (6 years ago)
Author:
Babis Nikolaou <charnik@…>
Branch:
default
Message:

added <http://postgis.net/ST_Centroid> extension function which is mapped to ST_Centroid(geometry) function of PostGIS (http://postgis.org/docs/ST_Centroid.html)

Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • evaluation/src/main/resources/META-INF/services/org.openrdf.query.algebra.evaluation.function.Function

    r1112 r1116  
    8484 
    8585org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.MakeLine 
     86org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.Centroid 
  • generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/GeneralDBSqlAbove.java

    r577 r1116  
    1 /* 
    2  * Copyright Aduna (http://www.aduna-software.com/) (c) 2008. 
    3  * 
    4  * Licensed under the Aduna BSD-style license. 
     1/** 
     2 * This Source Code Form is subject to the terms of the Mozilla Public 
     3 * License, v. 2.0. If a copy of the MPL was not distributed with this 
     4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
     5 *  
     6 * Copyright (C) 2010, 2011, 2012, 2013 Pyravlos Team 
     7 *  
     8 * http://www.strabon.di.uoa.gr/ 
    59 */ 
    610package org.openrdf.sail.generaldb.algebra; 
    711 
    812  
    9 import org.openrdf.sail.generaldb.algebra.base.BinaryGeneralDBOperator;  
    10 import org.openrdf.sail.generaldb.algebra.base.GeneralDBQueryModelVisitorBase; 
    1113import org.openrdf.sail.generaldb.algebra.base.GeneralDBSqlExpr; 
    1214 
    13 public class GeneralDBSqlAbove extends GeneralDBSqlGeoSpatial{ 
     15public class GeneralDBSqlAbove extends GeneralDBSqlGeoSpatial { 
    1416 
    1517        public GeneralDBSqlAbove(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 
  • generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/base/GeneralDBExprSupport.java

    r1114 r1116  
    6464import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 
    6565import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 
     66import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_Centroid; 
    6667import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 
    6768import org.openrdf.sail.generaldb.algebra.GeneralDBSqlTouches; 
     
    392393         
    393394        /** PostGIS Construct functions **/ 
     395        // Binary 
    394396        public static GeneralDBSqlExpr st_MakeLine(GeneralDBSqlExpr left, GeneralDBSqlExpr right) { 
    395397 
    396398                return new GeneralDBSqlST_MakeLine(left, right); 
     399        } 
     400        // Unary 
     401        public static GeneralDBSqlExpr st_Centroid(GeneralDBSqlExpr expr) { 
     402 
     403                return new GeneralDBSqlST_Centroid(expr); 
    397404        } 
    398405        /** PostGIS Construct functions **/ 
  • generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBBooleanExprFactory.java

    r1112 r1116  
    3636import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoConvexHull; 
    3737import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoDifference; 
    38 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_MakeLine; 
    3938import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoDistance; 
    4039import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.geoEnvelope; 
     
    8483import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.sqlNull; 
    8584import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.srid; 
     85import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_Centroid; 
     86import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_MakeLine; 
    8687import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.str; 
    8788import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.sub; 
     
    124125import org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlConvexHullFunc; 
    125126import org.openrdf.query.algebra.evaluation.function.spatial.geosparql.nontopological.GeoSparqlEnvelopeFunc; 
     127import org.openrdf.query.algebra.evaluation.function.spatial.postgis.construct.Centroid; 
    126128import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BoundaryFunc; 
    127129import org.openrdf.query.algebra.evaluation.function.spatial.stsparql.construct.BufferFunc; 
     
    872874                                && !(function instanceof GeoSparqlConvexHullFunc) 
    873875                                && !(function instanceof GeoSparqlEnvelopeFunc) 
     876                                && !(function instanceof Centroid) 
    874877                                && !(function instanceof UnionFunc && functionCall.getArgs().size()==1)) 
    875878                { 
     
    12541257                        return geoBuffer(leftArg, rightArg, thirdArg); 
    12551258                } 
     1259                /* PostGIS Construct functions */ 
    12561260                else if (function.getURI().equals(PostGIS.ST_MAKELINE)) 
    12571261                { 
    12581262                        return st_MakeLine(leftArg, rightArg); 
    12591263                } 
     1264                else if (function.getURI().equals(PostGIS.ST_CENTROID)) 
     1265                { 
     1266                        return st_Centroid(leftArg); 
     1267                } 
     1268                /* PostGIS Construct functions */ 
    12601269 
    12611270                logger.error("[Strabon.spatialConstructPicker] No appropriate SQL expression was generated for extension function {}. This is probably a bug.", function.getURI()); 
  • generaldb/src/main/java/org/openrdf/sail/generaldb/algebra/factories/GeneralDBNumericExprFactory.java

    r1114 r1116  
    2525import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.sqlNull; 
    2626import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.srid; 
     27import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_Centroid; 
     28import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_MakeLine; 
    2729import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.unsupported; 
    28  
    29 import static org.openrdf.sail.generaldb.algebra.base.GeneralDBExprSupport.st_MakeLine; 
    3030 
    3131import org.openrdf.model.Literal; 
     
    504504                        return st_MakeLine(leftArg, rightArg); 
    505505                } 
     506                else if(function.getURI().equals(PostGIS.ST_CENTROID)) 
     507                { 
     508                        return st_Centroid(leftArg); 
     509                } 
    506510                /** PostGIS construct functions */ 
    507511                //Should never reach this place 
  • generaldb/src/main/java/org/openrdf/sail/generaldb/evaluation/GeneralDBQueryBuilder.java

    r1112 r1116  
    7676import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 
    7777import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 
     78import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_Centroid; 
    7879import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 
    7980import org.openrdf.sail.generaldb.algebra.GeneralDBSqlShift; 
     
    11031104        protected abstract void append(GeneralDBSqlST_MakeLine expr, GeneralDBSqlExprBuilder filter) 
    11041105                        throws UnsupportedRdbmsOperatorException; 
     1106        protected abstract void append(GeneralDBSqlST_Centroid expr, GeneralDBSqlExprBuilder filter) 
     1107                        throws UnsupportedRdbmsOperatorException; 
    11051108        /* PostGIS Construct Functions */ 
    11061109         
     
    12131216                        append((GeneralDBSqlST_MakeLine)constr, filter); 
    12141217                } 
     1218                else if(constr instanceof GeneralDBSqlST_Centroid) 
     1219                { 
     1220                        append((GeneralDBSqlST_Centroid)constr, filter); 
     1221                } 
    12151222                /* PostGIS functions */ 
    12161223        } 
  • monetdb/src/main/java/org/openrdf/sail/monetdb/evaluation/MonetDBQueryBuilder.java

    r1112 r1116  
    2020import org.openrdf.sail.generaldb.algebra.GeneralDBSqlCase; 
    2121import org.openrdf.sail.generaldb.algebra.GeneralDBSqlContains; 
    22 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbContains; 
    2322import org.openrdf.sail.generaldb.algebra.GeneralDBSqlCrosses; 
    2423import org.openrdf.sail.generaldb.algebra.GeneralDBSqlDiffDateTime; 
     
    4746import org.openrdf.sail.generaldb.algebra.GeneralDBSqlLeft; 
    4847import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMathExpr; 
     48import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbContains; 
    4949import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbEquals; 
     50import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbIntersects; 
    5051import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbWithin; 
    51 import org.openrdf.sail.generaldb.algebra.GeneralDBSqlMbbIntersects; 
    5252import org.openrdf.sail.generaldb.algebra.GeneralDBSqlNot; 
    5353import org.openrdf.sail.generaldb.algebra.GeneralDBSqlNull; 
     
    5656import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 
    5757import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 
     58import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_Centroid; 
    5859import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 
    5960import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructBinary; 
     
    25982599        } 
    25992600 
     2601        @Override 
     2602        protected void append(GeneralDBSqlST_Centroid expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 
     2603                throw new UnsupportedRdbmsOperatorException("ST_Centroid is not available in MonetDB."); 
     2604        } 
     2605 
    26002606} 
  • postgis/src/main/java/org/openrdf/sail/postgis/evaluation/PostGISQueryBuilder.java

    r1114 r1116  
    6161import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRelate; 
    6262import org.openrdf.sail.generaldb.algebra.GeneralDBSqlRight; 
     63import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_Centroid; 
    6364import org.openrdf.sail.generaldb.algebra.GeneralDBSqlST_MakeLine; 
    6465import org.openrdf.sail.generaldb.algebra.GeneralDBSqlSpatialConstructBinary; 
     
    164165                ST_Boundary, 
    165166 
     167                // Spatial Constructs - Unary (PostGIS namespace) 
     168                ST_Centroid, 
     169                 
    166170                //Spatial Metrics - Binary 
    167171                ST_Distance, 
     
    474478 
    475479        @Override 
    476         protected void append(GeneralDBSqlRight expr, GeneralDBSqlExprBuilder filter) 
    477                         throws UnsupportedRdbmsOperatorException 
    478                         { 
     480        protected void append(GeneralDBSqlRight expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException 
     481        { 
    479482                appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.right); 
    480                         } 
    481  
    482         @Override 
    483         protected void append(GeneralDBSqlAbove expr, GeneralDBSqlExprBuilder filter) 
    484                         throws UnsupportedRdbmsOperatorException 
    485                         { 
     483        } 
     484 
     485        @Override 
     486        protected void append(GeneralDBSqlAbove expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException 
     487        { 
    486488                appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.above); 
    487                         } 
    488  
    489         @Override 
    490         protected void append(GeneralDBSqlBelow expr, GeneralDBSqlExprBuilder filter) 
    491                         throws UnsupportedRdbmsOperatorException 
    492                         { 
     489        } 
     490 
     491        @Override 
     492        protected void append(GeneralDBSqlBelow expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException 
     493        { 
    493494                appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.below); 
    494                         } 
     495        } 
    495496 
    496497        @Override 
     
    508509         
    509510        @Override 
    510         protected void append(GeneralDBSqlMbbContains expr, GeneralDBSqlExprBuilder filter) 
    511                         throws UnsupportedRdbmsOperatorException { 
     511        protected void append(GeneralDBSqlMbbContains expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 
    512512                appendStSPARQLSpatialOperand(expr, filter, SpatialOperandsPostGIS.contains); 
    513513        } 
     
    762762        protected void append(GeneralDBSqlST_MakeLine expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 
    763763                appendGeneralDBSpatialFunctionBinary(expr, filter, SpatialFunctionsPostGIS.ST_MakeLine); 
     764        } 
     765         
     766        @Override 
     767        protected void append(GeneralDBSqlST_Centroid expr, GeneralDBSqlExprBuilder filter) throws UnsupportedRdbmsOperatorException { 
     768                appendGeneralDBSpatialFunctionUnary(expr, filter, SpatialFunctionsPostGIS.ST_Centroid); 
    764769        } 
    765770 
     
    21632168                        case ST_IsEmpty: filter.appendFunction("ST_IsEmpty"); break; 
    21642169                        case ST_IsSimple: filter.appendFunction("ST_IsSimple"); break; 
    2165                         } 
     2170                        case ST_Centroid: filter.appendFunction("ST_Centroid"); break; 
     2171                        } 
     2172                         
    21662173                        filter.openBracket(); 
    21672174                        if(expr.getArg() instanceof GeneralDBStringValue) 
  • vocab/src/main/java/eu/earthobservatory/vocabulary/PostGIS.java

    r1112 r1116  
    1717        public static final String NAMESPACE = "http://postgis.net/"; 
    1818         
    19         /** Construct functions **/ 
     19        /** Construct functions (binary) **/ 
    2020        public static final String ST_MAKELINE = NAMESPACE + "ST_MakeLine"; 
     21         
     22        /** Construct functions (unary) **/ 
     23        public static final String ST_CENTROID = NAMESPACE + "ST_Centroid"; 
    2124} 
Note: See TracChangeset for help on using the changeset viewer.