Wrong results on geof:with

8 views
Skip to first unread message

s.ar...@geophy.com

unread,
Dec 15, 2016, 9:17:52 AM12/15/16
to Stardog
The query with geof:within does not seem  to work correctly. 

The query returns triples while should return nothing

Below it is a simple example:

Is it a known bug?

DATA
----------------------------------------------------------------

@prefix gn: <http://sws.geonames.org/> . 



gn:49518 a sf:Polygon ;    

geo:asWKT "POLYGON((0 0,1 0,1 1,0 1,0 0))"^^geo:wktLiteral . 

gn:42 a sf:Point ;    

geo:asWKT "POINT(0.5 0.5)"^^geo:wktLiteral .

:MyPolygon geo:hasGeometry gn:49518 . 

:MyPoint geo:hasGeometry gn:42 .


QUERY
---------------------------------------------------------



SELECT * WHERE {    
  ?g geo:asWKT ?gWKT .   
   FILTER (geof:within( "POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral  ,?g)) .}

Zachary Whitley

unread,
Dec 15, 2016, 11:07:25 AM12/15/16
to Stardog
I'm getting the following error when trying to reproduce. I'm not sure why you're not seeing the same error but the query would run successfully when you transpose the arguments to geof:with as follows. From the error message it looks like Stardog is expecting the second argument to be a constant value. I'm not sure what the geosparql specification has to say about that so I couldn't say if it's incorrect.


SELECT * WHERE {    
  ?g geo:asWKT ?gWKT .   
   FILTER (geof:within( ?g, "POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral)) .}


Stardog 4.1.2/Windows
jts-core-1.14.0.jar located in $STARDOG_HOME/server/ext
stardog.properties located in $STARDOG_HOME contains only spatial.use.jts=true

Create "test" database through webconsole and enable spatial index.
Load data above
Execute query above

result "Error! Internal Server Error" at webconsole

stardog.log error

ERROR 2016-12-15 11:01:00,756 [Stardog.Executor-0] com.complexible.stardog.protocols.server.SPECServerFunction:query(536): There was an error executing query: prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>


PREFIX geo: <http://www.opengis.net/ont/geosparql#>

PREFIX geof: <http://www.opengis.net/def/function/geosparql/>

SELECT * WHERE {   
  ?g geo:asWKT ?gWKT .  
   FILTER (geof:within( "POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral  ,?g)) .
} limit 50 offset 0
org.openrdf.query.QueryEvaluationException: com.complexible.stardog.plan.eval.ExecutionException: com.complexible.stardog.plan.filter.expr.ConstantImpl cannot be cast to com.complexible.stardog.plan.filter.expr.Variable
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:179) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:162) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.protocols.server.SPECServerFunction.query(SPECServerFunction.java:512) ~[stardog-protocols-spec-server-4.2.1.jar:?]
    at com.complexible.stardog.protocols.server.SPECServerFunction.handleMessage(SPECServerFunction.java:152) ~[stardog-protocols-spec-server-4.2.1.jar:?]
    at com.complexible.stardog.protocols.http.annex.QueryPanelEndpoint.handleMessage(QueryPanelEndpoint.java:89) ~[stardog-webconsole-annex-4.2.1.jar:?]
    at com.complexible.common.protocols.server.rpc.ServerHandler.lambda$handleMessage$1(ServerHandler.java:336) ~[stardog-protocols-api-server-4.2.1.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_111]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_111]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: com.complexible.stardog.plan.eval.ExecutionException: com.complexible.stardog.plan.filter.expr.ConstantImpl cannot be cast to com.complexible.stardog.plan.filter.expr.Variable
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.createOptimized(ExecutablePlanFactory.java:107) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.getExecutablePlan(QueryEngine.java:240) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.executeSelect(QueryEngine.java:127) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:176) ~[stardog-4.2.1.jar:?]
    ... 10 more
Caused by: java.lang.ClassCastException: com.complexible.stardog.plan.filter.expr.ConstantImpl cannot be cast to com.complexible.stardog.plan.filter.expr.Variable
    at com.complexible.stardog.spatial.db.query.SpatialQueryToFilterOptimizer$Visitor.transform(SpatialQueryToFilterOptimizer.java:97) ~[stardog-spatial-core-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:631) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.FilterPlanNodeImpl.accept(FilterPlanNodeImpl.java:75) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryVisit(TransformingPlanNodeVisitor.java:549) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryTransform(TransformingPlanNodeVisitor.java:79) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:306) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:767) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.ProjectionPlanNodeImpl.accept(ProjectionPlanNodeImpl.java:104) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryVisit(TransformingPlanNodeVisitor.java:549) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryTransform(TransformingPlanNodeVisitor.java:79) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:316) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:759) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.SlicePlanNodeImpl.accept(SlicePlanNodeImpl.java:103) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.optimizer.VisitingPlanNodeOptimizer.optimize(VisitingPlanNodeOptimizer.java:33) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.optimizer.OptimizationPipeline.execute(OptimizationPipeline.java:131) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.optimizePlan(ExecutablePlanFactory.java:135) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.lambda$createOptimized$150(ExecutablePlanFactory.java:101) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.cache.SimplePlanCache.get(SimplePlanCache.java:70) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.createOptimized(ExecutablePlanFactory.java:101) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.getExecutablePlan(QueryEngine.java:240) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.executeSelect(QueryEngine.java:127) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:176) ~[stardog-4.2.1.jar:?]
    ... 10 more
ERROR 2016-12-15 11:01:00,760 [Stardog.Executor-0] com.complexible.common.protocols.server.rpc.ServerHandler:exceptionCaught(413): exceptionCaughtServerHandler
org.openrdf.query.QueryEvaluationException: com.complexible.stardog.plan.eval.ExecutionException: com.complexible.stardog.plan.filter.expr.ConstantImpl cannot be cast to com.complexible.stardog.plan.filter.expr.Variable
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:179) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:162) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.protocols.server.SPECServerFunction.query(SPECServerFunction.java:512) ~[stardog-protocols-spec-server-4.2.1.jar:?]
    at com.complexible.stardog.protocols.server.SPECServerFunction.handleMessage(SPECServerFunction.java:152) ~[stardog-protocols-spec-server-4.2.1.jar:?]
    at com.complexible.stardog.protocols.http.annex.QueryPanelEndpoint.handleMessage(QueryPanelEndpoint.java:89) ~[stardog-webconsole-annex-4.2.1.jar:?]
    at com.complexible.common.protocols.server.rpc.ServerHandler.lambda$handleMessage$1(ServerHandler.java:336) ~[stardog-protocols-api-server-4.2.1.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_111]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_111]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: com.complexible.stardog.plan.eval.ExecutionException: com.complexible.stardog.plan.filter.expr.ConstantImpl cannot be cast to com.complexible.stardog.plan.filter.expr.Variable
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.createOptimized(ExecutablePlanFactory.java:107) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.getExecutablePlan(QueryEngine.java:240) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.executeSelect(QueryEngine.java:127) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:176) ~[stardog-4.2.1.jar:?]
    ... 10 more
Caused by: java.lang.ClassCastException: com.complexible.stardog.plan.filter.expr.ConstantImpl cannot be cast to com.complexible.stardog.plan.filter.expr.Variable
    at com.complexible.stardog.spatial.db.query.SpatialQueryToFilterOptimizer$Visitor.transform(SpatialQueryToFilterOptimizer.java:97) ~[stardog-spatial-core-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:631) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.FilterPlanNodeImpl.accept(FilterPlanNodeImpl.java:75) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryVisit(TransformingPlanNodeVisitor.java:549) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryTransform(TransformingPlanNodeVisitor.java:79) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:306) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:767) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.ProjectionPlanNodeImpl.accept(ProjectionPlanNodeImpl.java:104) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryVisit(TransformingPlanNodeVisitor.java:549) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.unaryTransform(TransformingPlanNodeVisitor.java:79) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.transform(TransformingPlanNodeVisitor.java:316) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.TransformingPlanNodeVisitor.visit(TransformingPlanNodeVisitor.java:759) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.SlicePlanNodeImpl.accept(SlicePlanNodeImpl.java:103) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.optimizer.VisitingPlanNodeOptimizer.optimize(VisitingPlanNodeOptimizer.java:33) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.optimizer.OptimizationPipeline.execute(OptimizationPipeline.java:131) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.optimizePlan(ExecutablePlanFactory.java:135) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.lambda$createOptimized$150(ExecutablePlanFactory.java:101) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.cache.SimplePlanCache.get(SimplePlanCache.java:70) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.ExecutablePlanFactory.createOptimized(ExecutablePlanFactory.java:101) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.getExecutablePlan(QueryEngine.java:240) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.plan.eval.QueryEngine.executeSelect(QueryEngine.java:127) ~[stardog-4.2.1.jar:?]
    at com.complexible.stardog.query.DefaultQueryFactory$TupleQuery.execute(DefaultQueryFactory.java:176) ~[stardog-4.2.1.jar:?]
    ... 10 more


--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+unsubscribe@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to the Google Groups "Stardog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stardog+unsubscribe@clarkparsia.com.

Samur Araujo

unread,
Dec 15, 2016, 11:15:29 AM12/15/16
to sta...@clarkparsia.com
Hi Zachary,  it does not work.
 
This is the actual query I run. The same you proposed.

prefix g: <http://geophy.com/>


SELECT * WHERE {    ?g geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 



Surprisingly, if I enable inference then nothing is returned. Very strange behavior! 

Best,

You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+unsubscribe@clarkparsia.com.



--
Senior Data Scientist 
Geophy 

Nieuwe Plantage 54-55
2611XK  Delft
+31 (0)70 7640725 

1 Fore Street
EC2Y 9DT  London
+44 (0)20 37690760

Zachary Whitley

unread,
Dec 15, 2016, 11:17:39 AM12/15/16
to Stardog
Looks like I missed a comm between the arguments. Can you try it again with the comma below

SELECT * WHERE {    ?g, geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 



On Thu, Dec 15, 2016 at 11:15 AM, Samur Araujo <s.ar...@geophy.com> wrote:
Hi Zachary,  it does not work.
 
This is the actual query I run. The same you proposed.

prefix g: <http://geophy.com/>


SELECT * WHERE {    ?g geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 



Surprisingly, if I enable inference then nothing is returned. Very strange behavior! 

Best,

Zachary Whitley

unread,
Dec 15, 2016, 11:19:46 AM12/15/16
to Stardog
Ignore that last message. Sorry, I was a bit distracted and shouldn't have fired off that response so quickly. What exactly doesn't work? Are there any log messages? What version of stardog are you running?

On Thu, Dec 15, 2016 at 11:17 AM, Zachary Whitley <zachary...@wavestrike.com> wrote:
Looks like I missed a comm between the arguments. Can you try it again with the comma below

SELECT * WHERE {    ?g, geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 


On Thu, Dec 15, 2016 at 11:15 AM, Samur Araujo <s.ar...@geophy.com> wrote:
Hi Zachary,  it does not work.
 
This is the actual query I run. The same you proposed.

prefix g: <http://geophy.com/>


SELECT * WHERE {    ?g geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 



Surprisingly, if I enable inference then nothing is returned. Very strange behavior! 

Best,

Samur Araujo

unread,
Dec 15, 2016, 11:20:46 AM12/15/16
to sta...@clarkparsia.com
The query you just sent have a syntax issue. 

Could you check it?


On 15 December 2016 at 17:17, Zachary Whitley <zachary...@wavestrike.com> wrote:
Looks like I missed a comm between the arguments. Can you try it again with the comma below

SELECT * WHERE {    ?g, geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 


On Thu, Dec 15, 2016 at 11:15 AM, Samur Araujo <s.ar...@geophy.com> wrote:
Hi Zachary,  it does not work.
 
This is the actual query I run. The same you proposed.

prefix g: <http://geophy.com/>


SELECT * WHERE {    ?g geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 



Surprisingly, if I enable inference then nothing is returned. Very strange behavior! 

Best,

Stephen Nowell

unread,
Dec 15, 2016, 11:21:00 AM12/15/16
to sta...@clarkparsia.com
Zach/Samur,

This may very well be a bug on our end. I'm looking into it and plan to report back here when I find something.

Cheers,
Stephen

Stephen Nowell

unread,
Dec 16, 2016, 9:21:40 AM12/16/16
to sta...@clarkparsia.com
Hi Samur,

I believe we have tracked down the bug that you are experiencing with geof:within inside a filter. I have created internal ticket #3373 to address it.
For now, try executing the following steps as a workaround:

stardog-admin db offline myDb
stardog-admin metadata set query.plan.reuse=never -- myDb
stardog-admin db online myDb
<Restart stardog>

Let me know if this works!

Cheers,
Stephen

Samur Araujo

unread,
Dec 16, 2016, 10:25:14 AM12/16/16
to sta...@clarkparsia.com
Hi Stephen, thank you! It worked!

On 16 December 2016 at 15:21, Stephen Nowell <ste...@stardog.com> wrote:
Hi Samur,

I believe we have tracked down the bug that you are experiencing with geof:within inside a filter. I have created internal ticket #3373 to address it.
For now, try executing the following steps as a workaround:

stardog-admin db offline myDb
stardog-admin metadata set query.plan.reuse=never -- myDb
stardog-admin db online myDb
<Restart stardog>

Let me know if this works!

Cheers,
Stephen


On 12/15/16 11:15, Samur Araujo wrote:
Hi Zachary,  it does not work.
 
This is the actual query I run. The same you proposed.

prefix g: <http://geophy.com/>


SELECT * WHERE {    ?g geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) } 



Surprisingly, if I enable inference then nothing is returned. Very strange behavior! 

Best,

Samur Araujo

unread,
Dec 16, 2016, 10:42:07 AM12/16/16
to sta...@clarkparsia.com, Gianluca Gindro
Hi Stephen, I am running the same query now on top of geonames.


SELECT * WHERE {    
  ?g geo:asWKT ?gWKT .   
   FILTER (geof:within(?g, "POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral  )) .}

The polygon is not very large, around 10 KM2.

The selection should not take long but the queries just take hours to execute. 

Could you please explain us why it is so slow? Are you using any R-tree index under stardog? 

Could you detail this architecture so we can understand what to expect from stardog on this query,  w.r.t. performance.  

Best,
Samur

P.S below is the query plan. I do not see any r-tree access. 

-------------------------
 $STARDOG/bin/stardog query explain fm-geonames stardog-geo-test.sparql
Explaining Query:

prefix g: <http://geophy.com/>


 

SELECT * WHERE {    ?g geo:asWKT ?gWKT .    FILTER (geof:within(?g, "POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^geo:wktLiteral)) }

The Query Plan:
Projection(?g, ?gWKT) [cardinality=0]
  Filter(Bound(?g)) [cardinality=0]
    Within("POLYGON((-99.872246 32.304972,-99.872246 32.504972,-99.672246 32.504972,-99.672246 32.304972,-99.872246 32.304972))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>) -> ?g
      Scan[PSOC](?g, geo:asWKT, ?gWKT) [cardinality=2.2M]


 

Michael Grove

unread,
Dec 16, 2016, 11:15:14 AM12/16/16
to stardog
Samur,

On Fri, Dec 16, 2016 at 10:42 AM, Samur Araujo <s.ar...@geophy.com> wrote:
Hi Stephen, I am running the same query now on top of geonames.


SELECT * WHERE {    
  ?g geo:asWKT ?gWKT .   
   FILTER (geof:within(?g, "POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral  )) .}

The polygon is not very large, around 10 KM2.

The selection should not take long but the queries just take hours to execute. 

Your query is basically asking “for all known shapes, see if they are within this given shape". As the cardinality of the scan indicates, that's 2.2M shapes. If we can do those checks in 1ms, that's still 2,200s to execute.

In your *specific* case, we could inline the `?g geo:asWKT ?gWKT .` directly into `within` and rely on the spatial index to list the points within the given shape, that would be faster. But generally, we cannot. 

Consider if you had an additional BGP `?g foaf:name "Shopping Mall"`. Additional information about the spatial structures are not stored in the spatial index and must be handled external to lookups in the spatial index. This how the evaluation works in general; we use the rest of the query to narrow down the shapes that are passed to the spatial function when its input is a variable. Since your query doesn't narrow down the list of shapes at all, we have to check all of them.

We'll investigate more sophisticated optimization techniques for spatial queries, #3377.

In the meantime, you should consider restricting your queries a bit more.
 

Could you please explain us why it is so slow? Are you using any R-tree index under stardog? 

For the spatial index, we're using Lucene Spatial, which relies on spatial4j, and optionally, as you know, integrates with JTS.

This post [1] is mentioned in the Lucene spatial documentation.
 

Could you detail this architecture so we can understand what to expect from stardog on this query,  w.r.t. performance.  

Best,
Samur

P.S below is the query plan. I do not see any r-tree access. 

The `Within` operator is calling out to the spatial index.

Samur Araujo

unread,
Dec 17, 2016, 9:27:53 AM12/17/16
to sta...@clarkparsia.com
HI Mike, It is still unclear some points. Could you please clarify, I list them below.

On 16 December 2016 at 17:15, Michael Grove <mi...@stardog.com> wrote:
Samur,

On Fri, Dec 16, 2016 at 10:42 AM, Samur Araujo <s.ar...@geophy.com> wrote:
Hi Stephen, I am running the same query now on top of geonames.


SELECT * WHERE {    
  ?g geo:asWKT ?gWKT .   
   FILTER (geof:within(?g, "POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral  )) .}

The polygon is not very large, around 10 KM2.

The selection should not take long but the queries just take hours to execute. 

Your query is basically asking “for all known shapes, see if they are within this given shape". As the cardinality of the scan indicates, that's 2.2M shapes. If we can do those checks in 1ms, that's still 2,200s to execute.

In your *specific* case, we could inline the `?g geo:asWKT ?gWKT .` directly into `within` and rely on the spatial index to list the points within the given shape, that would be faster. But generally, we cannot. 

Are you saying I can rewrite the query more efficient without Filter? Can u give me the example?

Notice: The polygon is the restriction. The polygon is a spatial restriction. I do not have another restriction.
 

Consider if you had an additional BGP `?g foaf:name "Shopping Mall"`. Additional information about the spatial structures are not stored in the spatial index and must be handled external to lookups in the spatial index. This how the evaluation works in general; we use the rest of the query to narrow down the shapes that are passed to the spatial function when its input is a variable. Since your query doesn't narrow down the list of shapes at all, we have to check all of them.

1) I would expect that the polygon above would filter the 30 points out of 2.2 M available via an efficient r-tree index, . Then, any results of an extra BGP would be further intersected to select the final result out of the 30 resources of the spatial Filter.  
2) In the way you said is the opposite, the spatial Filter is executed for every single result in the BPG, which sound very counter intuitive and inefficient. 

Did you implement the 1) or 2) on version 2.4.1?
 

We'll investigate more sophisticated optimization techniques for spatial queries, #3377.

In the meantime, you should consider restricting your queries a bit more.

As before, it is a spatial query. The polygon is the restriction. The polygon is a spatial restriction. I do not have another restriction.
 
 

Could you please explain us why it is so slow? Are you using any R-tree index under stardog? 

For the spatial index, we're using Lucene Spatial, which relies on spatial4j, and optionally, as you know, integrates with JTS.

This post [1] is mentioned in the Lucene spatial documentation.
 

Could you detail this architecture so we can understand what to expect from stardog on this query,  w.r.t. performance.  

Best,
Samur

P.S below is the query plan. I do not see any r-tree access. 

The `Within` operator is calling out to the spatial index.

If so, what / when is the spatial index used for? Could you clarify this to me?

Evren Sirin

unread,
Dec 17, 2016, 2:12:54 PM12/17/16
to Stardog
Hi Samur,

There are two different strategies Stardog may use for executing
spatial queries. In one strategy (adopted in this case) it will
evaluate some part of the BGPs first and then filters the result with
the spatial index. In the other strategy it will use the spatial index
first to find the matching shapes and join those results with the
BGPs. Which join strategy will be more efficient depends on the
selectivity of the spatial function and the BGPs. But I believe in the
case you use a FILTER function Stardog always goes with the first
strategy and in your case it is extremely slow. But if you use the
property function within then the second strategy will be used. I
tried this with the version of geonames I have and see the difference
in query plans:

select * {?x a gn:Feature . FILTER (geof:within (?x, "POLYGON((-99.8
32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral))
}

Projection(?x) [cardinality=0]
Filter(Bound(?x)) [cardinality=0]
Within("POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6 32.3,-99.8
32.3))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>) -> ?x
Scan[POSC](?x, rdf:type,
<http://www.geonames.org/ontology#Feature>) [cardinality=11.0M]


select * {?x a gn:Feature ; geof:within "POLYGON((-99.8 32.3,-99.8
32.5,-99.6 32.5,-99.6 32.3,-99.8 32.3))"^^geo:wktLiteral }

Projection(?x) [cardinality=1]
MergeJoin[?x] [cardinality=1]
Sort(?x) [cardinality=1]
Within("POLYGON((-99.8 32.3,-99.8 32.5,-99.6 32.5,-99.6
32.3,-99.8 32.3))"^^<http://www.opengis.net/ont/geosparql#wktLiteral>)
-> ?x
Scan[POSC](?x, rdf:type,
<http://www.geonames.org/ontology#Feature>) [cardinality=11.0M]

First query, as in your case, takes a very long time (for me it times
out at 5 minutes) whereas the second version completes in 10 seconds.
We are looking into this issue so that both versions of the query are
answered efficiently but until then you can use the property function
instead of the filter.

Best,
Evren
>>>>>>> stardog+u...@clarkparsia.com
>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Stardog" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to stardog+u...@clarkparsia.com.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> -- --
>>>>>> You received this message because you are subscribed to the C&P
>>>>>> "Stardog" group.
>>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>>> To unsubscribe from this group, send email to
>>>>>> stardog+u...@clarkparsia.com
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>> ---
>>>>>> You received this message because you are subscribed to a topic in the
>>>>>> Google Groups "Stardog" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>>> stardog+u...@clarkparsia.com.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Senior Data Scientist
>>>>> Geophy
>>>>> www.geophy.com
>>>>>
>>>>> Nieuwe Plantage 54-55
>>>>> 2611XK Delft
>>>>> +31 (0)70 7640725
>>>>>
>>>>> 1 Fore Street
>>>>> EC2Y 9DT London
>>>>> +44 (0)20 37690760
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to
>>>>> stardog+u...@clarkparsia.com
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to
>>>>> stardog+u...@clarkparsia.com
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>> ---
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "Stardog" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to
>>>>> stardog+u...@clarkparsia.com.
>>> stardog+u...@clarkparsia.com
>>> For more options, visit this group at
>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>
>>
>> --
>> -- --
>> You received this message because you are subscribed to the C&P "Stardog"
>> group.
>> To post to this group, send email to sta...@clarkparsia.com
>> To unsubscribe from this group, send email to
>> stardog+u...@clarkparsia.com
>> For more options, visit this group at
>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Stardog" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> stardog+u...@clarkparsia.com.
>
>
>
>
> --
> Senior Data Scientist
> Geophy
> www.geophy.com
>
> Nieuwe Plantage 54-55
> 2611XK Delft
> +31 (0)70 7640725
>
> 1 Fore Street
> EC2Y 9DT London
> +44 (0)20 37690760
>
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to
> stardog+u...@clarkparsia.com

Pavel Klinov

unread,
Dec 17, 2016, 3:11:25 PM12/17/16
to sta...@clarkparsia.com
We have created an internal ticket #3377 to address this issue. Once the next release is out you can look into the release notes to see if it's been closed.

Cheers,
Pavel


>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Stardog" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to stardog+unsubscribe@clarkparsia.com.

>>>>>>
>>>>>>
>>>>>> --
>>>>>> -- --
>>>>>> You received this message because you are subscribed to the C&P
>>>>>> "Stardog" group.
>>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>>> To unsubscribe from this group, send email to

>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>> ---
>>>>>> You received this message because you are subscribed to a topic in the
>>>>>> Google Groups "Stardog" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to

>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Senior Data Scientist
>>>>> Geophy
>>>>> www.geophy.com
>>>>>
>>>>> Nieuwe Plantage 54-55
>>>>> 2611XK  Delft
>>>>> +31 (0)70 7640725
>>>>>
>>>>> 1 Fore Street
>>>>> EC2Y 9DT  London
>>>>> +44 (0)20 37690760
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to

>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to

>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>> ---
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "Stardog" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to

>>> For more options, visit this group at
>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>
>>
>> --
>> -- --
>> You received this message because you are subscribed to the C&P "Stardog"
>> group.
>> To post to this group, send email to sta...@clarkparsia.com
>> To unsubscribe from this group, send email to

>> For more options, visit this group at
>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Stardog" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>
>
>
>
> --
> Senior Data Scientist
> Geophy
> www.geophy.com
>
> Nieuwe Plantage 54-55
> 2611XK  Delft
> +31 (0)70 7640725
>
> 1 Fore Street
> EC2Y 9DT  London
> +44 (0)20 37690760
>
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to

> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to

Samur Araujo

unread,
Dec 19, 2016, 4:57:28 AM12/19/16
to sta...@clarkparsia.com
Hi Evren, thank you for the explanation. It is very clear!

I will try the second approach you mentioned.

Best,
Samur


>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Stardog" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to stardog+unsubscribe@clarkparsia.com.

>>>>>>
>>>>>>
>>>>>> --
>>>>>> -- --
>>>>>> You received this message because you are subscribed to the C&P
>>>>>> "Stardog" group.
>>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>>> To unsubscribe from this group, send email to

>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>> ---
>>>>>> You received this message because you are subscribed to a topic in the
>>>>>> Google Groups "Stardog" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to

>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Senior Data Scientist
>>>>> Geophy
>>>>> www.geophy.com
>>>>>
>>>>> Nieuwe Plantage 54-55
>>>>> 2611XK  Delft
>>>>> +31 (0)70 7640725
>>>>>
>>>>> 1 Fore Street
>>>>> EC2Y 9DT  London
>>>>> +44 (0)20 37690760
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to

>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to

>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>> ---
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "Stardog" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to

>>> For more options, visit this group at
>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>
>>
>> --
>> -- --
>> You received this message because you are subscribed to the C&P "Stardog"
>> group.
>> To post to this group, send email to sta...@clarkparsia.com
>> To unsubscribe from this group, send email to

>> For more options, visit this group at
>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Stardog" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>
>
>
>
> --
> Senior Data Scientist
> Geophy
> www.geophy.com
>
> Nieuwe Plantage 54-55
> 2611XK  Delft
> +31 (0)70 7640725
>
> 1 Fore Street
> EC2Y 9DT  London
> +44 (0)20 37690760
>
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to

> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+unsubscribe@clarkparsia.com.

Samur Araujo

unread,
Dec 19, 2016, 4:58:26 AM12/19/16
to sta...@clarkparsia.com
Hi Pavel, I have access to zendesk but I cannot see the tickets. Do I need to get access / authorization?

Best,

Pavel Klinov

unread,
Dec 19, 2016, 5:11:07 AM12/19/16
to sta...@clarkparsia.com
The internal issue tracker is private. We disclose the numbers so that you can look the up in the release notes and see what's been fixed and what hasn't.

We're investigating different ways how to make selected issues accessible to users/customers. 

Cheers,
Pavel

Samur Araujo

unread,
Dec 19, 2016, 6:14:28 AM12/19/16
to sta...@clarkparsia.com
Thank you Pavel!

Samur Araujo

unread,
Dec 19, 2016, 10:30:46 AM12/19/16
to sta...@clarkparsia.com
Hi Evren, 

could you please send me an example of these cases 
  • (?aLowerLeftPoint, ?anUpperRightPoint)
  • (?aMinLatitude, ?aMinLongitude, ?aMaxLatitude, ?aMaxLongitude)
For the query below:

select * {?x a gn:Feature ; geof:within "POLYGON((0 0,1 0,1 1,0 1,0 0))"^^geo:wktLiteral }

I could not find the right syntax there to replace the polygon by these other forms.

  • geof:within
    • Returns all geo features within a given shape
    • Examples:
      • As BGP:  { ?feature geof:within ?shape }
      • FILTER (geof:within(?feature, ?shape))
      • NOTE: ?shape in this case can be defined one of 4 ways:
        • ?aGeoShape
        • (?aLowerLeftPoint, ?anUpperRightPoint)
        • (?aMinLatitude, ?aMinLongitude, ?aMaxLatitude, ?aMaxLongitude)




On 17 December 2016 at 20:12, Evren Sirin <ev...@stardog.com> wrote:

>>>>>>> For more options, visit this group at
>>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "Stardog" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>> send an email to stardog+unsubscribe@clarkparsia.com.

>>>>>>
>>>>>>
>>>>>> --
>>>>>> -- --
>>>>>> You received this message because you are subscribed to the C&P
>>>>>> "Stardog" group.
>>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>>> To unsubscribe from this group, send email to

>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>> ---
>>>>>> You received this message because you are subscribed to a topic in the
>>>>>> Google Groups "Stardog" group.
>>>>>> To unsubscribe from this topic, visit
>>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, send an email to

>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Senior Data Scientist
>>>>> Geophy
>>>>> www.geophy.com
>>>>>
>>>>> Nieuwe Plantage 54-55
>>>>> 2611XK  Delft
>>>>> +31 (0)70 7640725
>>>>>
>>>>> 1 Fore Street
>>>>> EC2Y 9DT  London
>>>>> +44 (0)20 37690760
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to

>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>>
>>>>>
>>>>> --
>>>>> -- --
>>>>> You received this message because you are subscribed to the C&P
>>>>> "Stardog" group.
>>>>> To post to this group, send email to sta...@clarkparsia.com
>>>>> To unsubscribe from this group, send email to

>>>>> For more options, visit this group at
>>>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>>>> ---
>>>>> You received this message because you are subscribed to a topic in the
>>>>> Google Groups "Stardog" group.
>>>>> To unsubscribe from this topic, visit
>>>>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>>>>> To unsubscribe from this group and all its topics, send an email to

>>> For more options, visit this group at
>>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>>
>>
>> --
>> -- --
>> You received this message because you are subscribed to the C&P "Stardog"
>> group.
>> To post to this group, send email to sta...@clarkparsia.com
>> To unsubscribe from this group, send email to

>> For more options, visit this group at
>> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Stardog" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to

>
>
>
>
> --
> Senior Data Scientist
> Geophy
> www.geophy.com
>
> Nieuwe Plantage 54-55
> 2611XK  Delft
> +31 (0)70 7640725
>
> 1 Fore Street
> EC2Y 9DT  London
> +44 (0)20 37690760
>
> --
> -- --
> You received this message because you are subscribed to the C&P "Stardog"
> group.
> To post to this group, send email to sta...@clarkparsia.com
> To unsubscribe from this group, send email to

> For more options, visit this group at
> http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Stardog" group.
To unsubscribe from this topic, visit https://groups.google.com/a/clarkparsia.com/d/topic/stardog/4hEmgeixjaY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stardog+unsubscribe@clarkparsia.com.

Stephen Nowell

unread,
Dec 19, 2016, 4:34:46 PM12/19/16
to sta...@clarkparsia.com
Samur,

Your polygon is a rectangle with the 4 corners at (0,0), (1,0), (1,1), (0,1). So you could represent it any of the following ways:
  • (?aLowerLeftPoint, ?anUpperRightPoint)
    • select * {?x a gn:Feature ; geof:within ( "Point(0 0)"^^geo:wktLiteral, "Point(1 1)"^^geo:wktLiteral ) } -- NOTE: No comma in between the x and y when declaring a Point
  • (?aMinLatitude, ?aMinLongitude, ?aMaxLatitude, ?aMaxLongitude)
    • select * {?x a gn:Feature ; geof:within ( 0, 0, 1, 1 ) } -- Two corners are 0,0 and 1,1 like above
  • BONUS!: Using Envelope
    • select * {?x a gn:Feature ; geof:within "Envelope(0, 1, 1, 0"^^geo:wktLiteral } -- NOTE: Order is weird here: minLat, maxLat, MAXLong, minLong

Cheers,
Stephen

Reply all
Reply to author
Forward
0 new messages