</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>
--
-- 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
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
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;
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