From: Sandro Santilli Date: Fri, 22 Mar 2013 12:34:34 +0000 (+0000) Subject: Fix lineal TopoJSON output to keep multi components separated X-Git-Tag: 2.1.0beta2~152 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5372e109735c8756c7c9fd5b8be5856f26d5c41;p=postgis Fix lineal TopoJSON output to keep multi components separated REF: #2228 git-svn-id: http://svn.osgeo.org/postgis/trunk@11196 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/export/TopoJSON.sql.in b/topology/sql/export/TopoJSON.sql.in index af367c1b1..3a5860077 100644 --- a/topology/sql/export/TopoJSON.sql.in +++ b/topology/sql/export/TopoJSON.sql.in @@ -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; diff --git a/topology/test/regress/topojson_expected b/topology/test/regress/topojson_expected index 53083f811..cd597712d 100644 --- a/topology/test/regress/topojson_expected +++ b/topology/test/regress/topojson_expected @@ -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]]]}