You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Luigi Selmi <se...@hotmail.com> on 2014/08/20 18:35:12 UTC
indexing of polygons in jena spatial
Hi Andy,
thanks again for the previous help related to jena spatial. After that I added new data using the ogc:asWKT property to index POINTs and Polygon. The data file can be seen at the url
http://www.sharesemantics.com/test/jena/spatial-data-wkt.ttl
The indexing works fine with POINTs. I had just to add the SpatialContextFactory in the assembler and the JTS jar file ( jts-1.13.jar ) to the classpath. After that I can use the query
PREFIX spatial: <http://jena.apache.org/spatial#>SELECT * { ?place spatial:nearby (40.77 -73.87 10 'km') .
}
to discover that the nearby point is the LaGuardia Airport. Running the next query
PREFIX spatial: <http://jena.apache.org/spatial#>SELECT * { ?place spatial:nearby (51.21 -2.00 10 'km') .}
I would expect to find one of the vertices of one polygon but it return an empty result that means my assumption, that vertices of polygons are indexed, is false.
My questions are the following:
1) How polygons are indexed in jena spatial ?2) How to implement a property function to find a point within a polygon, so that I can use a new property, something like spatial:withinBox but for polygons of any shape, in a SPARQL query ?
Thanks
Luigi
Re: indexing of polygons in jena spatial
Posted by Andy Seaborne <an...@apache.org>.
On 20/08/14 17:35, Luigi Selmi wrote:
> Hi Andy,
> thanks again for the previous help related to jena spatial. After that I added new data using the ogc:asWKT property to index POINTs and Polygon. The data file can be seen at the url
> http://www.sharesemantics.com/test/jena/spatial-data-wkt.ttl
> The indexing works fine with POINTs. I had just to add the SpatialContextFactory in the assembler and the JTS jar file ( jts-1.13.jar ) to the classpath. After that I can use the query
> PREFIX spatial: <http://jena.apache.org/spatial#>SELECT * { ?place spatial:nearby (40.77 -73.87 10 'km') .
> }
> to discover that the nearby point is the LaGuardia Airport. Running the next query
> PREFIX spatial: <http://jena.apache.org/spatial#>SELECT * { ?place spatial:nearby (51.21 -2.00 10 'km') .}
> I would expect to find one of the vertices of one polygon but it return an empty result that means my assumption, that vertices of polygons are indexed, is false.
> My questions are the following:
> 1) How polygons are indexed in jena spatial ?2) How to implement a property function to find a point within a polygon, so that I can use a new property, something like spatial:withinBox but for polygons of any shape, in a SPARQL query ?
> Thanks
> Luigi
Hi Luigi,
jena-spatial only indexes points, not polygons in the data. That's
what's behind "simple spatial query".
You could add a property function to do point-in-polygon like there is
point-in-circle and point-in-rectangle. The direct way is to find the
bound box of the polygon and then test results for being in the polygon.
Looks the source code for one of the existing property functions - each
property function is isn't huge.
GeoSPAQL has been asked for (JENA-664) -- it would be great if someone
stepped up to do that. I can't see it making progress without someone
stepping up to work on it.
Andy
PS A lazy way to use jena-spatial, and indeed any of the jena command
line tools, is to use just the Fuseki jar because it has all the jena
jars and dependencies recombined in it.