[postgis-users] st_geojson like st_mvt function

RĂ©mi Desgrange rdesgrange at gmail.com
Tue Dec 12 12:56:11 PST 2017


Hi,

this is my first mail on this list, I didn't know if I should have posted
on dev list or this one. Don't hesitate to correct.

With postgis 2.4 we now have the possibility to generate mvt format
directly in SQL, what I really like is the ability to construct a mvt
response with geometrie + data. The sql result is directly well formated
and ready to use. When I need to use geojson in my app I need something
like that :

{ "type": "Feature",
  "geometry":
      {
        "type": "Point",
        "coordinates": [125.6, 10.1]
      },
      "properties": { "name": "Dinagat Islands" }
 }

In order to do that I do :
SELECT name, st_geojson(geom) as geom FROM mytable

And then I my code I manipulate "name" to put it in the json under
"properties" there hack around to directly return geojson, but they're hack
not actual solutions.

What I imagine is something like that :

SELECT st_geojson(x) FROM (SELECT name, geom FROM mytable) x

the signature would be :

text St_AsGeoJSON(anyelement set row)

I do not know if this question has already been asked, I found nothing when
I googled. Do you think that this is a legitimate feature request ?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20171212/70ecb1b2/attachment.html>


More information about the postgis-users mailing list