Database Reference
In-Depth Information
[[-10.101, -10.101], [24.08108108108108,
24.70270270270271], [18.07142857142857,
19.78571428571428], [6.5, -28.5],
[12.66666666666667, -3.833333333333333], [1.5,
11.5], [10.92857142857143, 11.21428571428572],
[7.772727272727273, 5.954545454545455], [6.5,
5.0], [2.666666666666667, 5.0], [3.5, 7.5],
999999999, [10, 6, 7, 8, 9], [10, 5, 0, 9], [7,
4, 1, 2, 6], [5, 2, 1, 0], [10, 5, 2, 6], [8,
3, 4, 7], [9, 0, 3, 8], [4, 1, 0, 3]]
Step four - translating into geometry
As indicated earlier, what returns from our function is two lists. The first is a list of
pointsmakinguptheboundariesoftheVoronoidiagram,andthesecondisalistof
thepointsassociatedwitheachofthepolygons.Weneedtoformallyconvertthese
to polygons. This is a bit tricky. First, we continue with our query but split the two
partsofourreturningstringintothepointsthatmakeuptheVoronoiregionsandthe
portion that defines the arrays of points that make up these regions. If you recall,
when we wrote the original Voronoi function, we slipped a unique delimiter into the
text before returning it. As such, we can use this with the SPLIT_PART function of
PostgreSQL to return two different strings by searching for the value 999999999
and using this to split the returned string.
WITH stringprep AS (
SELECT chp04.voronoi_prep(the_geom, gid) FROM
chp04.voronoi_test_points
),
aggstring AS (
SELECT '[' ||
STRING_AGG((voronoi_prep).geomstring, ',' ORDER
BY (voronoi_prep).gid) || ']' AS inputtext
FROM stringprep
),
voronoi_string AS (
SELECT chp04.voronoi_fast(inputtext) AS
vstring FROM aggstring
Search WWH ::




Custom Search