[postgis-tickets] r14298 - Support for Puntal output in topology.AsTopoJSON

Sandro Santilli strk at keybit.net
Wed Oct 21 07:17:10 PDT 2015


Author: strk
Date: 2015-10-21 07:17:10 -0700 (Wed, 21 Oct 2015)
New Revision: 14298

Modified:
   trunk/doc/extras_topology.xml
   trunk/topology/sql/export/TopoJSON.sql.in
   trunk/topology/test/regress/topojson.sql
   trunk/topology/test/regress/topojson_expected
Log:
Support for Puntal output in topology.AsTopoJSON

Closes #3343

Modified: trunk/doc/extras_topology.xml
===================================================================
--- trunk/doc/extras_topology.xml	2015-10-19 20:43:21 UTC (rev 14297)
+++ trunk/doc/extras_topology.xml	2015-10-21 14:17:10 UTC (rev 14298)
@@ -3266,11 +3266,16 @@
     </note>
 
 		<para>
-A full TopoJSON document will be need to contain, in addition to the snippets returned by this function, the actual arcs plus some headers. See the <ulink url="http://github.com/mbostock/topojson/wiki/Specification">TopoJSON specification</ulink>.
+A full TopoJSON document will be need to contain, in
+addition to the snippets returned by this function,
+the actual arcs plus some headers. See the <ulink
+url="http://github.com/mbostock/topojson-specification/blob/master/README.md"
+>TopoJSON specification</ulink>.
 		</para>
               
                 <!-- use this format if new function -->
                 <para>Availability: 2.1.0 </para>
+                <para>Enhanced: 2.2.1 added support for puntal inputs</para>
 			</refsection>
 		
 		

Modified: trunk/topology/sql/export/TopoJSON.sql.in
===================================================================
--- trunk/topology/sql/export/TopoJSON.sql.in	2015-10-19 20:43:21 UTC (rev 14297)
+++ trunk/topology/sql/export/TopoJSON.sql.in	2015-10-21 14:17:10 UTC (rev 14298)
@@ -22,6 +22,9 @@
 --
 -- text AsTopoJSON(TopoGeometry, edgeMapTable)
 --
+-- Format specification here:
+-- http://github.com/mbostock/topojson-specification/blob/master/README.md
+--
 -- }{
 CREATE OR REPLACE FUNCTION topology.AsTopoJSON(tg topology.TopoGeometry, edgeMapTable regclass)
   RETURNS text AS
@@ -56,12 +59,12 @@
   SELECT name FROM topology.topology into toponame
               WHERE id = tg.topology_id;
 
-  -- Puntual TopoGeometry
+  -- TODO: implement scale ?
+
+  -- Puntal TopoGeometry, simply delegate to AsGeoJSON
   IF tg.type = 1 THEN
-    -- TODO: implement scale ?
-    --json := ST_AsGeoJSON(topology.Geometry(tg));
-    --return json;
-    RAISE EXCEPTION 'TopoJSON export does not support puntual objects';
+    json := ST_AsGeoJSON(topology.Geometry(tg));
+    return json;
   ELSIF tg.type = 2 THEN -- lineal
 
     FOR rec IN SELECT (ST_Dump(topology.Geometry(tg))).geom

Modified: trunk/topology/test/regress/topojson.sql
===================================================================
--- trunk/topology/test/regress/topojson.sql	2015-10-19 20:43:21 UTC (rev 14297)
+++ trunk/topology/test/regress/topojson.sql	2015-10-21 14:17:10 UTC (rev 14298)
@@ -92,5 +92,10 @@
  WHERE feature_name IN ('P6')
  ORDER BY feature_name;
 
+SELECT 'P1-vanilla', feature_name, topology.AsTopoJSON(feature, null)
+ FROM features.traffic_signs
+ WHERE feature_name IN ('S2')
+ ORDER BY feature_name;
+
 SELECT topology.DropTopology('city_data');
 DROP SCHEMA features CASCADE;

Modified: trunk/topology/test/regress/topojson_expected
===================================================================
--- trunk/topology/test/regress/topojson_expected	2015-10-19 20:43:21 UTC (rev 14297)
+++ trunk/topology/test/regress/topojson_expected	2015-10-21 14:17:10 UTC (rev 14298)
@@ -49,4 +49,5 @@
 E34
 E35
 A3-vanilla|P6|{ "type": "MultiPolygon", "arcs": [[[-33],[30,25],[1]],[[-34],[34]]]}
+P1-vanilla|S2|{"type":"MultiPoint","coordinates":[[35,14]]}
 Topology 'city_data' dropped



More information about the postgis-tickets mailing list