oeplatform
oeplatform copied to clipboard
ReadTheDocs Advanced API misleading function
In the documentation for the advanced API (http://oep-data-interface.readthedocs.io/en/latest/api/advanced.html), there is a misleading function example regarding geoJSON representation, the last example in the function section. It calls ST_AsGeoJSON on some geom column with the integer argument 4236. Looking at the number, one might expect that function to return a geoJSON object in a specific WGS (although WGS84 is EPSG:4326). What it actually does is truncating the coordinates to 4236 decimal places.
See also: http://www.postgis.org/docs/ST_AsGeoJSON.html
I think this is about this section. (scroll down to just before the "Joins" section)
I think we can fix this as indicated in the postgis documentation by adding this transformation, or we could require the table to have a column with this WGS 4236?:
@wingechr I think you are more familiar with the advanced API than me. Is it possible to nest a function in the json api request like
ST_AsGeoJSON(ST_Transform(geom,4326))
Would be nice to know :)
in theory, you should be able to nest the functions like this, but i have not tested it:
data = {
"query": {
"fields": [
{
"type": "function",
"function": "ST_AsGeoJSON",
"operands": [
{
"type": "function",
"function": "ST_Transform",
"operands": [
{"type": "column", "column": "geom"},
4326
],
}
],
}
],
"from": {"type": "table", "table": "example_table", "schema": "sandbox"},
}
}
Nice, thanks I will try it out.