]> granicus.if.org Git - postgis/commitdiff
Fix lineal TopoJSON output to keep multi components separated
authorSandro Santilli <strk@keybit.net>
Fri, 22 Mar 2013 12:34:34 +0000 (12:34 +0000)
committerSandro Santilli <strk@keybit.net>
Fri, 22 Mar 2013 12:34:34 +0000 (12:34 +0000)
REF: #2228

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

topology/sql/export/TopoJSON.sql.in
topology/test/regress/topojson_expected

index af367c1b1ea03aeb16e76444b1a1d99bed3d501a..3a58600774076f89e6d18c3a9e205a9a37f0b804 100644 (file)
@@ -37,7 +37,7 @@ DECLARE
   arcid int;
   arcs int[];
   ringtxt TEXT[];
-  polytxt TEXT[];
+  comptxt TEXT[];
   edges_found BOOLEAN;
   old_search_path TEXT;
   all_faces int[];
@@ -101,9 +101,13 @@ BEGIN
         arcs := arcs || arcid;
 
       END LOOP; -- }
+
+      comptxt := comptxt || ( '[' || array_to_string(arcs, ',') || ']' );
+      arcs := NULL;
+
     END LOOP; -- }
 
-    json := '{ "type": "LineString", "arcs": [' || array_to_string(arcs,',') || ']}';
+    json := '{ "type": "MultiLineString", "arcs": [' || array_to_string(comptxt,',') || ']}';
 
     return json;
 
@@ -260,7 +264,7 @@ FROM _edgepath
 #ifdef POSTGIS_TOPOLOGY_DEBUG
           RAISE DEBUG 'NO MORE holes, rings:%', ringtxt;
 #endif
-          polytxt := polytxt || ( '[' || array_to_string(ringtxt, ',') || ']' );
+          comptxt := comptxt || ( '[' || array_to_string(ringtxt, ',') || ']' );
           ringtxt := NULL;
           faces := all_faces;
           shell_faces := ARRAY[]::int[];
@@ -280,7 +284,7 @@ FROM _edgepath
 
     END LOOP; -- }
 
-    json := json || array_to_string(polytxt, ',') || ']}';
+    json := json || array_to_string(comptxt, ',') || ']}';
 
     EXECUTE 'SET search_path TO ' || old_search_path;
 
index 53083f81169775d8419fd79628d4953b78fbf65a..cd597712d4a13d728bb911a45fe2c2b908e82418 100644 (file)
@@ -18,12 +18,12 @@ E27
 E28
 E29
 E30
-L1-vanilla|R1|{ "type": "LineString", "arcs": [9,-11]}
-L1-vanilla|R2|{ "type": "LineString", "arcs": [4,-6]}
-L1-vanilla|R3|{ "type": "LineString", "arcs": [25]}
-L1-vanilla|R4|{ "type": "LineString", "arcs": [3]}
-L2-vanilla|R1R2|{ "type": "LineString", "arcs": [9,-11,4,-6]}
-L2-vanilla|R4|{ "type": "LineString", "arcs": [3]}
+L1-vanilla|R1|{ "type": "MultiLineString", "arcs": [[9,-11]]}
+L1-vanilla|R2|{ "type": "MultiLineString", "arcs": [[4,-6]]}
+L1-vanilla|R3|{ "type": "MultiLineString", "arcs": [[25]]}
+L1-vanilla|R4|{ "type": "MultiLineString", "arcs": [[3]]}
+L2-vanilla|R1R2|{ "type": "MultiLineString", "arcs": [[9,-11],[4,-6]]}
+L2-vanilla|R4|{ "type": "MultiLineString", "arcs": [[3]]}
 A1-vanilla|P1|{ "type": "MultiPolygon", "arcs": [[[20,5,-19,-20,-12,21]]]}
 A1-vanilla|P2|{ "type": "MultiPolygon", "arcs": [[[18,6,-17,-18,-13,19]]]}
 A1-vanilla|P3|{ "type": "MultiPolygon", "arcs": [[[16,7,-15,-16,-14,17]]]}
@@ -31,12 +31,12 @@ A1-vanilla|P4|{ "type": "MultiPolygon", "arcs": [[[-2]]]}
 A1-vanilla|P5|{ "type": "MultiPolygon", "arcs": [[[-1],[25]]]}
 A2-vanilla|P1P2|{ "type": "MultiPolygon", "arcs": [[[20,5,6,-17,-18,-13,-12,21]]]}
 A2-vanilla|P3P4|{ "type": "MultiPolygon", "arcs": [[[-2]],[[16,7,-15,-16,-14,17]]]}
-L1-edgemap|R1|{ "type": "LineString", "arcs": [0,-2]}
-L1-edgemap|R2|{ "type": "LineString", "arcs": [2,-4]}
-L1-edgemap|R3|{ "type": "LineString", "arcs": [4]}
-L1-edgemap|R4|{ "type": "LineString", "arcs": [5]}
-L2-edgemap|R1R2|{ "type": "LineString", "arcs": [0,-2,2,-4]}
-L2-edgemap|R4|{ "type": "LineString", "arcs": [4]}
+L1-edgemap|R1|{ "type": "MultiLineString", "arcs": [[0,-2]]}
+L1-edgemap|R2|{ "type": "MultiLineString", "arcs": [[2,-4]]}
+L1-edgemap|R3|{ "type": "MultiLineString", "arcs": [[4]]}
+L1-edgemap|R4|{ "type": "MultiLineString", "arcs": [[5]]}
+L2-edgemap|R1R2|{ "type": "MultiLineString", "arcs": [[0,-2],[2,-4]]}
+L2-edgemap|R4|{ "type": "MultiLineString", "arcs": [[4]]}
 A1-edgemap|P1|{ "type": "MultiPolygon", "arcs": [[[5,4,-4,-3,-2,0]]]}
 A1-edgemap|P2|{ "type": "MultiPolygon", "arcs": [[[3,9,-9,-8,-7,2]]]}
 A1-edgemap|P3|{ "type": "MultiPolygon", "arcs": [[[8,13,-13,-12,-11,7]]]}