]> granicus.if.org Git - postgis/commitdiff
Support for Puntal output in topology.AsTopoJSON
authorSandro Santilli <strk@keybit.net>
Wed, 21 Oct 2015 14:17:10 +0000 (14:17 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 21 Oct 2015 14:17:10 +0000 (14:17 +0000)
Closes #3343

git-svn-id: http://svn.osgeo.org/postgis/trunk@14298 b70326c6-7e19-0410-871a-916f4a2858ee

doc/extras_topology.xml
topology/sql/export/TopoJSON.sql.in
topology/test/regress/topojson.sql
topology/test/regress/topojson_expected

index 45fc82c4a38153895dece21e2085b5a6be4b5627..1482f3f447d89cf5befc55c4d4ad6c6fd8b5ec5b 100644 (file)
@@ -3266,11 +3266,16 @@ in the "edgeMapTable" table.
     </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>
                
                
index 847875cfef9613e75a7b850b1f8d41bba8e52e81..4d331634eace41284847ed228757d50261568513 100644 (file)
@@ -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 @@ BEGIN
   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
index 82d7675b1eb8d71374f90d107f99a7ec79fcac65..5f154b06030ebbadcd2a6a968f1cf0b944fcc2b2 100644 (file)
@@ -92,5 +92,10 @@ SELECT 'A3-vanilla', feature_name, topology.AsTopoJSON(feature, null)
  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;
index cd597712d4a13d728bb911a45fe2c2b908e82418..0b19011935cde8c42ede1ea45675d5abd773f736 100644 (file)
@@ -49,4 +49,5 @@ E33
 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