oeplatform icon indicating copy to clipboard operation
oeplatform copied to clipboard

ReadTheDocs Advanced API misleading function

Open stefansc1 opened this issue 7 years ago • 3 comments

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

stefansc1 avatar Jan 22 '18 10:01 stefansc1

I think this is about this section. (scroll down to just before the "Joins" section) image

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?: image

@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 :)

jh-RLI avatar Aug 19 '22 16:08 jh-RLI

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"},
    }
}

wingechr avatar Aug 23 '22 07:08 wingechr

Nice, thanks I will try it out.

jh-RLI avatar Aug 23 '22 10:08 jh-RLI