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



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





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:









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.