Ticket #23 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Distance function

Reported by: kkyzir Owned by: stella
Priority: critical Milestone: Support for GeoSPARQL 1.0.1
Component: postgis Version: all
Keywords: Cc:

Description

The definition (and the implementation!) of the distance function needs to be modified. We could adopt the definition of the distance function defined in GeoSPARQL.

geof:distance (geom1: ogc:geomLiteral, geom2: ogc:geomLiteral, units: xsd:anyURI): xsd:double

Returns the shortest distance in units between any two Points in the two geometric objects as calculated in the spatial reference system of geom1.

Regarding the implementation of the distance function in PostGIS checkout http://workshops.opengeo.org/postgis-intro/geography.html

Change History

comment:1 Changed 5 years ago by kkyzir

  • Priority changed from major to critical

comment:2 Changed 5 years ago by kkyzir

  • Milestone set to Support for GeoSPARQL 1.0.1

comment:3 Changed 5 years ago by stella

  • Owner changed from pyravlos-team to stella
  • Status changed from new to assigned

comment:4 Changed 4 years ago by stella

  • Status changed from assigned to closed
  • Resolution set to fixed

Has not been tested for MonetDB.
Supports computation of distance in meters and degrees.

Last edited 4 years ago by stella (previous) (diff)

comment:5 follow-up: ↓ 8 Changed 4 years ago by charnik

  • Status changed from closed to reopened
  • Resolution fixed deleted

When I run the following query over the dataset of Greek Administrative Geography, I get an IndexOutOfBounds? exception. The query simply asks for the distance between two geometries in the select clause.

PREFIX gag: <http://geo.linkedopendata.gr/gag/ontology/>

SELECT ?g1 ?g2 (<http://strdf.di.uoa.gr/ontology#distance>(?g1, ?g2, <http://www.opengis.net/def/uom/OGC/1.0/metre>) as ?d)
WHERE
{

<http://geo.linkedopendata.gr/gag/id/501> gag:έχει_γεωμετρία ?g1 .
<http://geo.linkedopendata.gr/gag/id/502> gag:έχει_γεωμετρία ?g2 .

}

java.lang.IndexOutOfBoundsException?: Index: 2, Size: 2

at java.util.ArrayList?.RangeCheck?(ArrayList?.java:547)
at java.util.ArrayList?.get(ArrayList?.java:322)
at org.openrdf.sail.generaldb.algebra.factories.GeneralDBBooleanExprFactory.spatialMetricFunction(GeneralDBBooleanExprFactory.java:972)
at org.openrdf.sail.generaldb.algebra.factories.GeneralDBBooleanExprFactory.spatialFunction(GeneralDBBooleanExprFactory.java:804)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.meet(GeneralDBSelectQueryOptimizer.java:1013)
at org.openrdf.query.algebra.Extension.visit(Extension.java:90)
at org.openrdf.query.algebra.UnaryTupleOperator?.visitChildren(UnaryTupleOperator?.java:79)
at org.openrdf.query.algebra.Projection.visitChildren(Projection.java:74)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetNode(QueryModelVisitorBase?.java:658)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetUnaryTupleOperator(QueryModelVisitorBase?.java:686)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meet(QueryModelVisitorBase?.java:450)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.meet(GeneralDBSelectQueryOptimizer.java:872)
at org.openrdf.query.algebra.Projection.visit(Projection.java:66)
at org.openrdf.query.algebra.UnaryTupleOperator?.visitChildren(UnaryTupleOperator?.java:79)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetNode(QueryModelVisitorBase?.java:658)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetUnaryTupleOperator(QueryModelVisitorBase?.java:686)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meet(QueryModelVisitorBase?.java:510)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.meet(GeneralDBSelectQueryOptimizer.java:1247)
at org.openrdf.query.algebra.Slice.visit(Slice.java:85)
at org.openrdf.query.algebra.UnaryTupleOperator?.visitChildren(UnaryTupleOperator?.java:79)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetNode(QueryModelVisitorBase?.java:658)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meet(QueryModelVisitorBase?.java:468)
at org.openrdf.query.algebra.QueryRoot?.visit(QueryRoot?.java:34)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.optimize(GeneralDBSelectQueryOptimizer.java:184)
at org.openrdf.sail.generaldb.optimizers.GeneralDBQueryOptimizer.rdbmsOptimizations(GeneralDBQueryOptimizer.java:120)
at org.openrdf.sail.generaldb.optimizers.GeneralDBQueryOptimizer.optimize(GeneralDBQueryOptimizer.java:89)
at org.openrdf.sail.generaldb.GeneralDBConnection.evaluateInternal(GeneralDBConnection.java:216)
at org.openrdf.sail.helpers.SailConnectionBase?.evaluate(SailConnectionBase?.java:212)
at org.openrdf.repository.sail.SailTupleQuery?.evaluate(SailTupleQuery?.java:48)
at org.openrdf.repository.sail.SailTupleQuery?.evaluate(SailTupleQuery?.java:62)
at eu.earthobservatory.runtime.generaldb.Strabon.query(Strabon.java:284)
at eu.earthobservatory.org.StrabonEndpoint?.StrabonBeanWrapper?.query(StrabonBeanWrapper?.java:188)
at eu.earthobservatory.org.StrabonEndpoint?.QueryBean?.processVIEWRequest(QueryBean?.java:322)
at eu.earthobservatory.org.StrabonEndpoint?.QueryBean?.doPost(QueryBean?.java:143)
at javax.servlet.http.HttpServlet?.service(HttpServlet?.java:641)
at javax.servlet.http.HttpServlet?.service(HttpServlet?.java:722)
at org.apache.catalina.core.ApplicationFilterChain?.internalDoFilter(ApplicationFilterChain?.java:305)
at org.apache.catalina.core.ApplicationFilterChain?.doFilter(ApplicationFilterChain?.java:210)
at org.apache.catalina.core.StandardWrapperValve?.invoke(StandardWrapperValve?.java:224)
at org.apache.catalina.core.StandardContextValve?.invoke(StandardContextValve?.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase?.invoke(AuthenticatorBase?.java:472)
at org.apache.catalina.core.StandardHostValve?.invoke(StandardHostValve?.java:168)
at org.apache.catalina.valves.ErrorReportValve?.invoke(ErrorReportValve?.java:98)
at org.apache.catalina.valves.AccessLogValve?.invoke(AccessLogValve?.java:927)
at org.apache.catalina.core.StandardEngineValve?.invoke(StandardEngineValve?.java:118)
at org.apache.catalina.connector.CoyoteAdapter?.service(CoyoteAdapter?.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol?$AbstractConnectionHandler?.process(AbstractProtocol?.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor?.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor?$Worker.runTask(ThreadPoolExecutor?.java:895)
at java.util.concurrent.ThreadPoolExecutor?$Worker.run(ThreadPoolExecutor?.java:918)
at java.lang.Thread.run(Thread.java:680)

comment:6 follow-up: ↓ 7 Changed 4 years ago by charnik

The following query over the dataset of Greek Administrative Geography runs indefinitely.

select ?g1 ?g2
where {
?s1 <http://geo.linkedopendata.gr/gag/ontology/έχει_γεωμετρία> ?g1 .
?s2 <http://geo.linkedopendata.gr/gag/ontology/έχει_γεωμετρία> ?g2 .
filter (?s1 != ?s2 &&
<http://strdf.di.uoa.gr/ontology#distance>(?g1, ?g2, <http://www.opengis.net/def/uom/OGC/1.0/metre>) < 12000)
}

comment:7 in reply to: ↑ 6 Changed 4 years ago by charnik

Replying to charnik:

The following query over the dataset of Greek Administrative Geography runs indefinitely.

select ?g1 ?g2
where {
?s1 <http://geo.linkedopendata.gr/gag/ontology/έχει_γεωμετρία> ?g1 .
?s2 <http://geo.linkedopendata.gr/gag/ontology/έχει_γεωμετρία> ?g2 .
filter (?s1 != ?s2 &&
<http://strdf.di.uoa.gr/ontology#distance>(?g1, ?g2, <http://www.opengis.net/def/uom/OGC/1.0/metre>) < 12000)
}

In a stronger machine runs perfect. We have to be patient with the distance and meters.

comment:8 in reply to: ↑ 5 Changed 4 years ago by charnik

  • Status changed from reopened to closed
  • Resolution set to fixed

Replying to charnik:

When I run the following query over the dataset of Greek Administrative Geography, I get an IndexOutOfBounds? exception. The query simply asks for the distance between two geometries in the select clause.

PREFIX gag: <http://geo.linkedopendata.gr/gag/ontology/>

SELECT ?g1 ?g2 (<http://strdf.di.uoa.gr/ontology#distance>(?g1, ?g2, <http://www.opengis.net/def/uom/OGC/1.0/metre>) as ?d)
WHERE
{

<http://geo.linkedopendata.gr/gag/id/501> gag:έχει_γεωμετρία ?g1 .
<http://geo.linkedopendata.gr/gag/id/502> gag:έχει_γεωμετρία ?g2 .

}

java.lang.IndexOutOfBoundsException?: Index: 2, Size: 2

at java.util.ArrayList?.RangeCheck?(ArrayList?.java:547)
at java.util.ArrayList?.get(ArrayList?.java:322)
at org.openrdf.sail.generaldb.algebra.factories.GeneralDBBooleanExprFactory.spatialMetricFunction(GeneralDBBooleanExprFactory.java:972)
at org.openrdf.sail.generaldb.algebra.factories.GeneralDBBooleanExprFactory.spatialFunction(GeneralDBBooleanExprFactory.java:804)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.meet(GeneralDBSelectQueryOptimizer.java:1013)
at org.openrdf.query.algebra.Extension.visit(Extension.java:90)
at org.openrdf.query.algebra.UnaryTupleOperator?.visitChildren(UnaryTupleOperator?.java:79)
at org.openrdf.query.algebra.Projection.visitChildren(Projection.java:74)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetNode(QueryModelVisitorBase?.java:658)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetUnaryTupleOperator(QueryModelVisitorBase?.java:686)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meet(QueryModelVisitorBase?.java:450)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.meet(GeneralDBSelectQueryOptimizer.java:872)
at org.openrdf.query.algebra.Projection.visit(Projection.java:66)
at org.openrdf.query.algebra.UnaryTupleOperator?.visitChildren(UnaryTupleOperator?.java:79)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetNode(QueryModelVisitorBase?.java:658)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetUnaryTupleOperator(QueryModelVisitorBase?.java:686)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meet(QueryModelVisitorBase?.java:510)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.meet(GeneralDBSelectQueryOptimizer.java:1247)
at org.openrdf.query.algebra.Slice.visit(Slice.java:85)
at org.openrdf.query.algebra.UnaryTupleOperator?.visitChildren(UnaryTupleOperator?.java:79)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meetNode(QueryModelVisitorBase?.java:658)
at org.openrdf.query.algebra.helpers.QueryModelVisitorBase?.meet(QueryModelVisitorBase?.java:468)
at org.openrdf.query.algebra.QueryRoot?.visit(QueryRoot?.java:34)
at org.openrdf.sail.generaldb.optimizers.GeneralDBSelectQueryOptimizer.optimize(GeneralDBSelectQueryOptimizer.java:184)
at org.openrdf.sail.generaldb.optimizers.GeneralDBQueryOptimizer.rdbmsOptimizations(GeneralDBQueryOptimizer.java:120)
at org.openrdf.sail.generaldb.optimizers.GeneralDBQueryOptimizer.optimize(GeneralDBQueryOptimizer.java:89)
at org.openrdf.sail.generaldb.GeneralDBConnection.evaluateInternal(GeneralDBConnection.java:216)
at org.openrdf.sail.helpers.SailConnectionBase?.evaluate(SailConnectionBase?.java:212)
at org.openrdf.repository.sail.SailTupleQuery?.evaluate(SailTupleQuery?.java:48)
at org.openrdf.repository.sail.SailTupleQuery?.evaluate(SailTupleQuery?.java:62)
at eu.earthobservatory.runtime.generaldb.Strabon.query(Strabon.java:284)
at eu.earthobservatory.org.StrabonEndpoint?.StrabonBeanWrapper?.query(StrabonBeanWrapper?.java:188)
at eu.earthobservatory.org.StrabonEndpoint?.QueryBean?.processVIEWRequest(QueryBean?.java:322)
at eu.earthobservatory.org.StrabonEndpoint?.QueryBean?.doPost(QueryBean?.java:143)
at javax.servlet.http.HttpServlet?.service(HttpServlet?.java:641)
at javax.servlet.http.HttpServlet?.service(HttpServlet?.java:722)
at org.apache.catalina.core.ApplicationFilterChain?.internalDoFilter(ApplicationFilterChain?.java:305)
at org.apache.catalina.core.ApplicationFilterChain?.doFilter(ApplicationFilterChain?.java:210)
at org.apache.catalina.core.StandardWrapperValve?.invoke(StandardWrapperValve?.java:224)
at org.apache.catalina.core.StandardContextValve?.invoke(StandardContextValve?.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase?.invoke(AuthenticatorBase?.java:472)
at org.apache.catalina.core.StandardHostValve?.invoke(StandardHostValve?.java:168)
at org.apache.catalina.valves.ErrorReportValve?.invoke(ErrorReportValve?.java:98)
at org.apache.catalina.valves.AccessLogValve?.invoke(AccessLogValve?.java:927)
at org.apache.catalina.core.StandardEngineValve?.invoke(StandardEngineValve?.java:118)
at org.apache.catalina.connector.CoyoteAdapter?.service(CoyoteAdapter?.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol?$AbstractConnectionHandler?.process(AbstractProtocol?.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor?.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor?$Worker.runTask(ThreadPoolExecutor?.java:895)
at java.util.concurrent.ThreadPoolExecutor?$Worker.run(ThreadPoolExecutor?.java:918)
at java.lang.Thread.run(Thread.java:680)

This query runs ok in mac (PostgreSQL 9.1, PostGIS 2.0) using strabon script. I assume that the exception was raised due a non-upgraded strabon endpoint. Therefore, the bug is closed again.

Note: See TracTickets for help on using tickets.