इसके अलावा PostgreSQL / PostGIS का उपयोग करके अपने कार्य को हल करने का एक और तरीका।
यदि लाइनें छोटी और सरल हैं, तो स्क्रिप्ट चलाएँ:
WITH
tbla AS (SELECT (ST_Dump(geom)).geom geom FROM <line_name_table>),
tblb AS (SELECT (ST_DumpPoints(geom)).geom geom FROM tbla
UNION
SELECT ST_Centroid(geom) geom FROM tbla),
tblc AS (SELECT ((ST_Dump(ST_VoronoiPolygons(ST_Collect(geom)))).geom) geom FROM tblb)
SELECT ST_Union(a.geom) geom FROM tblc a JOIN tbla b ON ST_Intersects(a.geom, b.geom) GROUP BY b.geom;
परिणाम देखें।
यदि लाइनें लंबी हैं, तो स्क्रिप्ट चलाएँ:
WITH
tbla AS (SELECT (ST_Dump(geom)).geom geom FROM <line_name_table>),
tblb AS (WITH btbl AS (SELECT (ST_Dump(geom)).geom geom FROM tbla),
intervals AS (SELECT generate_series (0, 9) as steps)
SELECT steps AS stp, ST_LineInterpolatePoint(geom, steps/(SELECT count(steps)::float-1 FROM intervals)) geom FROM btbl, intervals GROUP BY intervals.steps, geom),
tblc AS (SELECT ((ST_Dump(ST_VoronoiPolygons(ST_Collect(geom)))).geom) geom FROM tblb)
SELECT ST_Union(a.geom) geom FROM tblc a JOIN tbla b ON ST_Intersects(a.geom, b.geom) GROUP BY b.geom;
परिणाम देखें।
यदि आवश्यक हो, तर्ज पर बिंदुओं की संख्या को संकुचित करें, मेरे उदाहरण में यह 10 बिंदु है।
मूल समाधान।
इस स्क्रिप्ट को कहा जाता है: ST_VoronoiDiagramsFromLines।