|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (18)
View Page History{toc}
h1. Introduction
GraphDB-SE has special support for 2-dimensional geo-spatial data that data, which uses the [WGS84 Geo Positioning RDF vocabulary (World Geodetic System 1984)|http://www.w3.org/2003/01/geo/wgs84_pos]. Special indices can be used for this data that data, which permit the efficient evaluation of special query forms and extension functions that allow finding locations, which are:
* locations to be found that are within a certain distance of a point, i.e. within the specified circle on the surface of the sphere (Earth), using the nearby(...) construction;
* locations that are within rectangles and polygons, where the vertices are defined using spherical polar coordinates, using the within(...) construction.
{note}
The following jar files (included with the GraphDB distribution) must be on the classpath in order for the geo-spatial extensions to function correctly: jsi-1*.jar, log4j-1*.jar, sil-0*.jar, trove4j-2*.jar
{note}
The following jar files (included with the GraphDB distribution) must be on the classpath in order for the geo-spatial extensions to function correctly: jsi-1*.jar, log4j-1*.jar, sil-0*.jar, trove4j-2*.jar
{note}
The WGS84 ontology can be found at: [http://www.w3.org/2003/01/geo/wgs84_pos] and contains several classes and predicates:
|| Element || Description ||
| {{SpatialThing}} | Class used to represent anything with spatial extent, i.e. size, shape or position. |
| {{SpatialThing}} | Class used to represent anything with spatial extent, i.e. size, shape or position. |
| {{Point}} | Class used to represent a point (relative to Earth) defined using latitude, longitude (and altitude). \\
subClassOf [http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing] |
| {{location}} | The relation between a thing and where it is. \\
| {{location}} | The relation between a thing and where it is. \\

domain [http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing] |
h1. Creating Geo-spatial Index
{note}
The following jar files (included with the GraphDB distribution) must be on the classpath, in order for the geo-spatial extensions to function correctly: jsi-1*.jar, log4j-1*.jar, sil-0*.jar, trove4j-2*.jar
{note}
{note}
The following jar files (included with the GraphDB distribution) must be on the classpath, in order for the geo-spatial extensions to function correctly: jsi-1*.jar, log4j-1*.jar, sil-0*.jar, trove4j-2*.jar
{note}
Before the geo-spatial extensions can be used, the geo-spatial index must be built. This is achieved by inserting and committing a dummy statement (that is not actually stored) that stored), which uses a special predicate:
{noformat}PREFIX ontogeo: <http://www.ontotext.com/owlim/geo#>
INSERT DATA { _:b1 ontogeo:createIndex _:b2. }
{noformat}
INSERT DATA { _:b1 ontogeo:createIndex _:b2. }
{noformat}
If the indexing is successful, the above update will succeed, succeeds, otherwise an exception will be is thrown. Information about the indexing process and any errors can be found in the log. Note that this update will fail if there is no geo-spatial data in the repository, i.e. no statements describing resources with latitude and longitude properties.
h1. Geo-spatial query syntax
The special syntax used to query geo-spatial data makes use of SPARQL's [RDF Collections syntax|http://www.w3.org/TR/rdf-sparql-query/#collections]. This syntax uses round brackets as a shorthand for the statements connecting a list of values using {{rdf:first}} and {{rdf:rest}} predicates with terminating {{rdf:nil}}. Statement patterns that use one of the special geo-spatial predicates supported by GraphDB-SE are treated differently by the query engine. The following special syntax is supported when evaluating SPARQL queries (the descriptions all use the namespace:
The Geo-spatial query syntax is the SPARQL's [RDF Collections syntax|http://www.w3.org/TR/rdf-sparql-query/#collections]. This syntax uses round brackets as a shorthand for the statements, connecting a list of values using {{rdf:first}} and {{rdf:rest}} predicates with terminating {{rdf:nil}}. Statement patterns that use one of the special geo-spatial predicates, supported by GraphDB-SE, are treated differently by the query engine. The following special syntax is supported when evaluating SPARQL queries. All descriptions use the namespace:
{{omgeo: <[http://www.ontotext.com/owlim/geo#]>}}

* Shortest great circle distance from (?plat, ?plong) to (?lat, ?long) <= ?distance \\
\\
\\
Such a construction will use uses the geo-spatial indices to find bindings for ?point that ?point, which lie within the defined circle. \\
Constants are allowed for any of *?lat ?long ?distance*, where latitude and longitude are specified in decimal degrees and distance is specified in either kilometres ('km' suffix) or miles ('mi' suffix). If the units are not specified, then 'km' is assumed. ||
|| Restrictions | Latitude is limited to the range \-90 (South) to \+90 (North) \\
|| Restrictions | Latitude is limited to the range \-90 (South) to \+90 (North) \\

\\
Note that the corners must be specified most westerly and southerly (first) and most northerly and easterly (second). Proper account is taken for rectangles that cross the \+/-180 degree meridian. \\
Note that the corners must be specified most westerly and southerly (first) and most northerly and easterly (second). Proper account is taken for rectangles that cross the \+/-180 degree meridian. \\
Constants are allowed for any of *?lat{*}{*}{~}1{~}* *?long{*}{*}{~}1{~}* *?lat{*}{*}{~}2{~}* *\*long{*}{*}{~}2{~}*, where latitude and longitude are specified in decimal degrees. If *?point* is unbound, then bindings for all points within the rectangle will be produced. ||
|| Restrictions | Latitude is limited to the range \-90 (South) to \+90 (North) \\
Longitude is limited to the range \-180 (West) to \+180 (East) \\
Longitude is limited to the range \-180 (West) to \+180 (East) \\

* ?point geo:long ?plong . \\
* the position ?plat ?plong is enclosed by the polygon \\
* the position ?plat ?plong is enclosed by the polygon \\
The polygon is closed automatically if the first and last vertices do not coincide. The vertices must be constants or bound values. Coordinates are specified in decimal degrees. If *?point* is unbound, then bindings for all points within the polygon will be produced. ||
|| Restrictions | Latitude is limited to the range \-90 (South) to \+90 (North) \\
Longitude is limited to the range \-180 (West) to \+180 (East) ||
Longitude is limited to the range \-180 (West) to \+180 (East) ||

h1. Implementation details
Knowledge of the implementation's algorithms and assumptions will allow users to make the best use of the GraphDB-SE geo-spatial extensions. The following points are significant and can affect the expected behaviour during query answering:
* Spherical Earth -- the current implementation treats the Earth as a perfect sphere with a radius of 6371.009km;
* Only 2-Dimensional points are supported, i.e. there is no special handling of geo:alt (metres above the reference surface of the Earth);
* All latitude and longitude values must be specified using decimal degrees, where East and North are positive and \-90 <= latitude <= \+90 and \-180 <= longitude <= \+180;
* Distances must be in units of kilometres (suffix 'km') or statute miles (suffix 'mi'). If the suffix is omitted, kilometres are assumed;
* Only 2-Dimensional points are supported, i.e. there is no special handling of geo:alt (metres above the reference surface of the Earth);
* All latitude and longitude values must be specified using decimal degrees, where East and North are positive and \-90 <= latitude <= \+90 and \-180 <= longitude <= \+180;
* Distances must be in units of kilometres (suffix 'km') or statute miles (suffix 'mi'). If the suffix is omitted, kilometres are assumed;
* {{omgeo:within( rectangle )}} construct uses a 'rectangle' whose edges are lines of latitude and longitude, so the north-south distance is constant, and the rectangle described forms a band around the Earth that Earth, which starts and stops at the given longitudes;
* {{omgeo:within( polygon )}} joins vertices with straight lines on a cylindrical projection of the Earth tangential to the equator. A straight line starting at the point under test and continuing East out of the polygon is examined to see how many polygon edges it intersects. If the number of intersections is even, then the point is outside the polygon, if polygon. If the number of intersections is odd, the point is inside the polygon. With the current algorithm, the order of vertices is not relevant (clockwise or anticlockwise);
* {{omgeo:within()}} may not work correctly when the region (polygon or rectangle) spans the \+/-180 meridian;
* {{omgeo:nearby()}} uses the great circle distance between points.
* {{omgeo:nearby()}} uses the great circle distance between points.