geojson-spec
geojson-spec copied to clipboard
Support for accuracy
I think that it would be very useful to be able to specify the accuracy at which the coordinates where obtained. E.g.
{
"type": "Point",
"coordinates": [ 18.076479, 59.334537, 14.507372 ],
"accuracy": [ 65, 65, 10 ]
}
We would need to decide on which unit to specify the accuracy in. In my example I used meters since that is what the HTML5 Geo API returns, but I'm not sure that it's the best way. Maybe GDOP could be the way to go...
I might add that the 65
in this case specifies that the position is somewhere in a circle with a radius of 65 meters and the center at the specified longitude and latitude. My first thought was to specify three accuracy value for the longitude
, latitude
and altitude
respectively, but this might have been a bad idea.
A better proposal would probably be to specify it as [ 65, 10 ]
with the second value being optional.
Some new examples:
{
"type": "Point",
"coordinates": [ 18.076479, 59.334537, 14.507372 ],
"accuracy": [ 65, 10 ]
}
{
"type": "Point",
"coordinates": [ 18.076479, 59.334537, 14.507372 ],
"accuracy": [ 65 ]
}
{
"type": "Point",
"coordinates": [ 18.076479, 59.334537 ],
"accuracy": [ 65 ]
}
Sample implementations:
Javascript
function currentLocation(cb) {
function error(err) { cb(err); }
function success(geo) {
cb(null, {
type: 'Point',
coordinates: [ geo.coords.longitude, geo.coords.latitude, geo.coords.altitude ],
accuracy: [ geo.coords.accuracy, geo.coords.altitudeAccuracy ]
});
}
navigator.geolocation.getCurrentPosition(success, error);
}
Swift
extension CLLocation {
func toGeoJSONDict() -> [String: AnyObject] {
return [
"type": "Point",
"coordinates": [ coordinate.longitude, coordinate.latitude, altitude ],
"accuracy": [ horizontalAccuracy, verticalAccuracy ]
]
}
}