Skip to content

Commit 9e61f28

Browse files
author
Sandro Santilli
committed
Support for Puntal output in topology.AsTopoJSON
Closes #3343 git-svn-id: http://svn.osgeo.org/postgis/trunk@14298 b70326c6-7e19-0410-871a-916f4a2858ee
1 parent 1c5d638 commit 9e61f28

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

doc/extras_topology.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3266,11 +3266,16 @@ in the "edgeMapTable" table.
32663266
</note>
32673267

32683268
<para>
3269-
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>.
3269+
A full TopoJSON document will be need to contain, in
3270+
addition to the snippets returned by this function,
3271+
the actual arcs plus some headers. See the <ulink
3272+
url="http://github.com/mbostock/topojson-specification/blob/master/README.md"
3273+
>TopoJSON specification</ulink>.
32703274
</para>
32713275

32723276
<!-- use this format if new function -->
32733277
<para>Availability: 2.1.0 </para>
3278+
<para>Enhanced: 2.2.1 added support for puntal inputs</para>
32743279
</refsection>
32753280

32763281

topology/sql/export/TopoJSON.sql.in

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
--
2323
-- text AsTopoJSON(TopoGeometry, edgeMapTable)
2424
--
25+
-- Format specification here:
26+
-- http://github.com/mbostock/topojson-specification/blob/master/README.md
27+
--
2528
-- }{
2629
CREATE OR REPLACE FUNCTION topology.AsTopoJSON(tg topology.TopoGeometry, edgeMapTable regclass)
2730
RETURNS text AS
@@ -56,12 +59,12 @@ BEGIN
5659
SELECT name FROM topology.topology into toponame
5760
WHERE id = tg.topology_id;
5861

59-
-- Puntual TopoGeometry
62+
-- TODO: implement scale ?
63+
64+
-- Puntal TopoGeometry, simply delegate to AsGeoJSON
6065
IF tg.type = 1 THEN
61-
-- TODO: implement scale ?
62-
--json := ST_AsGeoJSON(topology.Geometry(tg));
63-
--return json;
64-
RAISE EXCEPTION 'TopoJSON export does not support puntual objects';
66+
json := ST_AsGeoJSON(topology.Geometry(tg));
67+
return json;
6568
ELSIF tg.type = 2 THEN -- lineal
6669

6770
FOR rec IN SELECT (ST_Dump(topology.Geometry(tg))).geom

topology/test/regress/topojson.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,10 @@ SELECT 'A3-vanilla', feature_name, topology.AsTopoJSON(feature, null)
9292
WHERE feature_name IN ('P6')
9393
ORDER BY feature_name;
9494

95+
SELECT 'P1-vanilla', feature_name, topology.AsTopoJSON(feature, null)
96+
FROM features.traffic_signs
97+
WHERE feature_name IN ('S2')
98+
ORDER BY feature_name;
99+
95100
SELECT topology.DropTopology('city_data');
96101
DROP SCHEMA features CASCADE;

topology/test/regress/topojson_expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ E33
4949
E34
5050
E35
5151
A3-vanilla|P6|{ "type": "MultiPolygon", "arcs": [[[-33],[30,25],[1]],[[-34],[34]]]}
52+
P1-vanilla|S2|{"type":"MultiPoint","coordinates":[[35,14]]}
5253
Topology 'city_data' dropped

0 commit comments

Comments
 (0)