mapillary / mapillary-python-sdk

A Python 3 library built on the Mapillary API v4 to facilitate retrieving and working with Mapillary data.
MIT License
39 stars 15 forks source link

[Utility] Reformat JSON to GeoJSON #26

Closed OmarMuhammedAli closed 3 years ago

OmarMuhammedAli commented 3 years ago

Is your feature request related to a problem? Please describe. Required implementation of a utility that reformats a JSON input to a GeoJSON format.

Describe the solution you'd like The implementation will be a pure function that takes in a JSON input, reformats it (e.g. nest all the properties under the properties attribute), and returns an appropriate GeoJSON

Describe alternatives you've considered NA

Resources RFC 7946 - Specification of GeoJSON

cbeddow commented 3 years ago

As a test, we can look at this API request, it returns a JSON object:

https://graph.mapillary.com/1933525276802129?fields=id,thumb_2048_url,compass_angle,quality_score,captured_at,geometry&access_token=MLY|XXX

We can convert this to a geojson feature/object which looks like:

{
      "type": "Feature",
      "properties": {
        "id": "1933525276802129",
        "thumb_2048_url": "https://scontent-sea1-1.xx.fbcdn.net/m1/v/An9HiV2KRnL7YvbqqbCrJJCO3O_RVxfbw94vaMO6A_7d_IW6YtX8xlijLIQWAvcQessYZe6cpeMo-kLVqHDNG9Q3EZNCq5Ac3vCV8AVWWqSnjE6fxVEdk5nH97vqjeGua_l44SSpiXSIqt8fvtI2Ww?stp=s2048x1152&tp=1&ccb=9-4&oh=cd54d20a4075283b4b4f098331e72432&oe=60DCF8F3",
        "compass_angle": 200.93476466846,
        "quality_score": 0.54237648233351,
         "captured_at": 1507560881000,
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          -97.743279722222,
          30.270651388889
        ]
      }
}
Rubix982 commented 3 years ago

Solved in #44