woeip
woeip copied to clipboard
Update /pollutant_value to return structured time_geo
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 thetime_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 thetime_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.
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
}
Related to #171