woeip icon indicating copy to clipboard operation
woeip copied to clipboard

Update /pollutant_value to return structured time_geo

Open jayqi opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe.

Currently the /pollutant_values endpoint returns the timestamp and geolocation of observation as a string formatted like "2020-02-10 11:15:24 (37.803838, -122.272514)". This is not ideal as consumers have to do string parsing to grab the timestamp and location.

Describe the solution you'd like

Instead, the endpoint should returned the time_geo in a structured way.

The best place to put this logic will be the PollutantValuesSerializer.

Ways to do this:

  • Preferred: Have the PollutantValuesSerializer look up and parse the time_geo object and put the time and location in serialized object. (As a flat object)
{
    "time": "2020-02-10T11:15:24Z",
    "location" [37.803838, -122.272514]
    "pollutant": "PM1",
    "value": 0.012
},
  • Have the PollutantValuesSerializer to return the time_geo field as a nested object.
{
    "time_geo": {
        "location": "SRID=4326;POINT (37.803838 -122.272514)",
        "time": "2020-02-10T11:15:24Z"
    },
    "pollutant": "PM1",
    "value": 0.012
},

Note that we will want to make sure any consumers, e.g., #185 are updated to follow this format.

jayqi avatar Apr 01 '20 02:04 jayqi

Other potential structures discussed:

{
    "time": "2020-02-10T11:15:24Z",
    "lat": 37.803838, 
    "lng": -122.272514,
    "pollutant": "PM1",
    "value": 0.012
}

or

{
    "time": "2020-02-10T11:15:24Z",
    "coordinates": {
        "latitude": 37.803838, 
        "longitude": -122.272514},
    "pollutant": "PM1",
    "value": 0.012
}

nbilenko avatar Apr 01 '20 23:04 nbilenko

Related to #171

theecrit avatar Jun 10 '20 03:06 theecrit