From bfe853231979609129c458807ec39b6bb777947e Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Wed, 1 May 2019 16:59:08 +0000 Subject: [PATCH] Change GeoJSON example to be self-contained git-svn-id: http://svn.osgeo.org/postgis/trunk@17419 b70326c6-7e19-0410-871a-916f4a2858ee --- doc/reference_output.xml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/reference_output.xml b/doc/reference_output.xml index 7cea2f22a..84cb057a7 100644 --- a/doc/reference_output.xml +++ b/doc/reference_output.xml @@ -398,14 +398,18 @@ CIRCULARSTRING(220268 150415 1,220227 150505 2,220227 150406 3) You can test and view your GeoJSON data online on geojson.io. ST_AsGeoJSON only builds geometry. You need to build the rest of Feature from your Postgres table yourself: - -SELECT planet_osm_point.* -FROM planet_osm_point -LIMIT 10; - st_asgeojson ------------------------------------------------------------------------------------------------------------ -{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[23.569251,51.541599]},"properties":{"osm_id":3424148658,"place":"locality"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.625174,51.511718]},"properties":{"osm_id":4322036818,"place":"locality"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.613928,51.5417]},"properties":{"osm_id":242979330,"place":"hamlet"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.586361,51.563272]},"properties":{"osm_id":3424148656,"place":"locality"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.605488,51.553886]},"properties":{"osm_id":242979323,"place":"village"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.6067,51.57609]},"properties":{"osm_id":242979327,"place":"village"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.636533,51.575683]},"properties":{"osm_id":5737800420,"place":"locality"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.656733,51.518733]},"properties":{"osm_id":5737802397,"place":"locality"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.672542,51.504584]},"properties":{"osm_id":242979320,"place":"hamlet"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[23.574094,51.63389]},"properties":{"osm_id":242979333,"place":"village"}}]} - + SELECT ST_AsGeoJSON(t.*) +FROM (VALUES + (1, 'one', 'POINT(1 1)'::geometry), + (2, 'two', 'POINT(2 2)'), + (3, 'three', 'POINT(3 3)')) +AS t(id, name, geom); + + st_asgeojson +----------------------------------------------------------------------------------------------------------------- + {"type": "Feature", "geometry": {"type":"Point","coordinates":[1,1]}, "properties": {"id": 1, "name": "one"}} + {"type": "Feature", "geometry": {"type":"Point","coordinates":[2,2]}, "properties": {"id": 2, "name": "two"}} + {"type": "Feature", "geometry": {"type":"Point","coordinates":[3,3]}, "properties": {"id": 3, "name": "three"}} SELECT ST_AsGeoJSON(geom) from fe_edges limit 1; st_asgeojson -- 2.40.0