geojson-spec icon indicating copy to clipboard operation
geojson-spec copied to clipboard

Support for accuracy

Open LinusU opened this issue 10 years ago • 2 comments

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...

LinusU avatar Feb 20 '15 11:02 LinusU

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 ]
}

LinusU avatar Feb 20 '15 11:02 LinusU

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 ]
        ]
    }
}

LinusU avatar Feb 20 '15 11:02 LinusU