[postgis-tickets] [PostGIS] #2444: Wrong example in asTopoJON manual
PostGIS
trac at osgeo.org
Thu Aug 22 06:52:07 PDT 2013
#2444: Wrong example in asTopoJON manual
---------------------------+------------------------------------------------
Reporter: tilt | Owner: robe
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS 2.1.1
Component: documentation | Version: 2.1.x
Keywords: astopojson |
---------------------------+------------------------------------------------
TopoJson seems to require delta values in the coordinates instead of pure
coordinates given in the example. Additionally, the indexing in arcs is
wrong and some comma's are missing in the example.
A better output example would be:
{{{
{ "type": "Topology", "transform": { "scale": [1,1], "translate":
[0,0] }, "objects": {
"P3P4": { "type": "MultiPolygon", "arcs": [[[0]],[[1,2,3,4,5,6]]]}
}, "arcs": [
[[25,30],[6,0],[0,10],[-14,0],[0,-10],[14,0]],
[[35,14],[0,-8]],
[[35,6],[12,0]],
[[47,6],[0,8]],
[[47,14],[0,8]],
[[47,22],[-12,0]],
[[35,22],[0,-8]]
]}
}}}
To get the deltas from the coordinates is a bit tricky. Here's a
suggestion that works but it's open for improvement:
{{{
WITH points as (
SELECT nextval('mycounter') as id, m.edge_id as groupid,
(st_dumppoints(geom)).geom
FROM edgemap m, <yourTopoTable>.edge e WHERE e.edge_id = m.edge_id
),
compare as (
SELECT id, groupid,
first_value(geom) OVER (PARTITION BY groupid ORDER BY id )
geom0,
(geom) geom1,
(lead(geom) OVER (PARTITION BY groupid ORDER BY id ))
geom2
FROM points
)
SELECT
'[[' || ST_X(geom0) || ','||ST_Y(geom0)|| '],' || string_agg('['
|| ROUND(ST_X(geom2) - ST_X(geom1)) || ',' || ROUND(ST_Y(geom2) -
ST_Y(geom1)) || ']',',') || '],' as arc
FROM compare
}}}
--
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2444>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list