[postgis-tickets] r17419 - Change GeoJSON example to be self-contained

Paul Ramsey pramsey at cleverelephant.ca
Wed May 1 09:59:08 PDT 2019


Author: pramsey
Date: 2019-05-01 09:59:08 -0700 (Wed, 01 May 2019)
New Revision: 17419

Modified:
   trunk/doc/reference_output.xml
Log:
Change GeoJSON example to be self-contained


Modified: trunk/doc/reference_output.xml
===================================================================
--- trunk/doc/reference_output.xml	2019-04-30 16:45:35 UTC (rev 17418)
+++ trunk/doc/reference_output.xml	2019-05-01 16:59:08 UTC (rev 17419)
@@ -398,15 +398,19 @@
 		<para>You can test and view your GeoJSON data online on <ulink url="http://geojson.io/">geojson.io</ulink>.</para>
 
 		<para>ST_AsGeoJSON only builds geometry. You need to build the rest of Feature from your Postgres table yourself:</para>
-		<programlisting>
-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":"F
 eature","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"}}]}
-		</programlisting>
+		<programlisting>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"}}</programlisting>
+
 		<programlisting>SELECT ST_AsGeoJSON(geom) from fe_edges limit 1;
 					   st_asgeojson
 -----------------------------------------------------------------------------------------------------------



More information about the postgis-tickets mailing list