Previous topic  Top  Next topic  Print this Topic
 

Geographic Coordinates

 

OntoBroker supports geographic coordinates, represented by latitude and longitude in decimal notation. The format of the new datatype _geo (obl:reserved:geo) in OL syntax is

"<latitude>;<longitude>"^^_geo

 

where the semicolon separated <latitude> and <longitude> have to be replaced by the actual values. Those values are stored with a precision of six decimal places. If a value with higher precision is given rounding is applied. An exemplary ontology, showing instances for the cities Karlsruhe, Brisbane and Marrakech with their geographical location might look like

karlsruhe:City[location->"49.013964;8.404455"^^_geo].

brisbane:City[location->"-27.336738;153.250909"^^_geo].

marrakech:City[location->"31.625828;-7.989094"^^_geo].

 

Using the built-in _geoDistance/3 the distance between those locations can be calculated. Please note that this built-in assumes a simplified model of the earth, i.e. a sphere, and therefore will not return the real exact distance. However this approximation should be sufficient for most applications. The arguments are first two geographic coordinates and finally the distance. The coordinates have to be ground, the distance might be. Based on the example from above he query

@{options[outorder(?city,?distanceToKarlsruhe),sort(?city)]} ?- karlsruhe[location->?lka] and ?city:City[location->?lx] and _geoDistance(?lka,?lx,?distanceToKarlsruhe).

 

will return the distance in kilometer from Karlsruhe to all cities of the ontology:

 ?city

 ?distanceToKarlsruhe

brisbane

16185.1272

karlsruhe

0.0

marakech

2372.835

Obviously the distance from Karlsruhe to itself is zero. All distances are calculated with a precision to 0.1 meter.

Additional related built-ins are _latitude/2 and _longitude/2 with a geographic coordinate as first argument and the latitude/longitude as second argument.