http://franz.com/ns/allegrograph/5.0/geo/nd/fn#haversineLatLonLatLon
Returns the haversine distance between <lat1
, lon1
> and <lat2
, lon2
>. lat1
, lon1
, lat2
, and lon2
specify two points in spherical coordinates and must be bound to numeric values.
For example:
PREFIX ndfn: <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
PREFIX : <http://franz.com/ns/keyword#>
SELECT * {
bind(ndfn:haversineLatLonLatLon(38.889, -77.035, 38.889, -77.050, :km) as ?distance)
}
An optional fifth argument may be http://franz.com/ns/keyword#km (default) or http://franz.com/ns/keyword#miles to specify the units of the result.
http://franz.com/ns/allegrograph/5.0/geo/nd/fn#haversineLatLonLoc
Returns the haversine distance between <lat
, lon
> and the location specified by the nD encoded literal loc
. lat
and lon
must be bound to numeric values, and the datatype encoding of loc
must have one :latitude and one :longitude type ordinate.
For example:
PREFIX ndfn: <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
PREFIX ex: <http://ex.com/>
PREFIX : <http://franz.com/ns/keyword#>
SELECT ?distance {
ex:WashingtonMonument ex:location ?loc .
bind(ndfn:haversineLatLonLoc(38.889, -77.035, ?loc, :miles) as ?distance)
}
An optional fourth argument may be http://franz.com/ns/keyword#km (default) or http://franz.com/ns/keyword#miles to specify the units of the result.
http://franz.com/ns/allegrograph/5.0/geo/nd/fn#haversineLocLoc
Returns the haversine distance between loc1
and loc2
which must be nD encoded literals.. The nD encoding datatypes of loc1
and loc2
need not be the same, but each must have one :latitude and one :longitude type ordinate.
For example:
PREFIX ndfn: <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
PREFIX ex: <http://ex.com/>
SELECT ?distance {
ex:WashingtonMonument ex:location ?loc1 .
ex:LincolnMemorial ex:location ?loc2 .
bind(ndfn:haversineLocLoc(?loc1, ?loc2) as ?distance)
}
An optional third argument may be http://franz.com/ns/keyword#km (default) or http://franz.com/ns/keyword#miles to specify the units of the result.
http://franz.com/ns/allegrograph/5.0/geo/nd/fn#ordinateValue
Returns the value of a named ordinate from an n-Dimensionally encoded literal.
For example, if ?point is bound to an n-Dimensionally encoded literal, then the following expression would retrieve the value of the ordinate named latitude:
bind(ndfn:ordinateValue(?point, :latitude) as ?lat)
Note that this assumes the usual default namespaces and that ?point has been bound previously in the query.
http://franz.com/ns/allegrograph/5.0/geo/nd/fn#ordinatesToValue
Encodes a list of keys and values into an n-Dimensional literal.
For example, if http://example.com/phone-calls#phoneCallTargetLocation is an n-Dimensional subtype defined with time, latitude, and longitude, then the following expression would encode the
bind(ndfn:ordinatesToValue(
<http://example.com/phone-calls#phoneCallTargetLocation>,
:time, ?time, :longitude, 37.8, :longitude, -122.5) as ?plist)
Note that this assumes the usual default namespaces and that ?time has been bound previously in the query.
Notes
The following namespace abbreviations are used:
- fti - <http://franz.com/ns/allegrograph/2.2/textindex/>
- geo - <http://franz.com/ns/allegrograph/3.0/geospatial/>
- geofn - <http://franz.com/ns/allegrograph/3.0/geospatial/fn/>
- nd - <http://franz.com/ns/allegrograph/5.0/geo/nd#>
- ndfn - <http://franz.com/ns/allegrograph/5.0/geo/nd/fn#>
- sna - <http://franz.com/ns/allegrograph/4.11/sna/>
The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.