On Tue, 10 Feb 2015 04:34:01 -0800 (PST), Marcel Gangwisch wrote:
> Hi All!
>
> I want to calculate a Voronoi Diagram based on line segments or
> complete polygons and points.
>
Hi Marcel,
a Voronoi Diagram is always expected to be based on a collection
of *POINTS*
accordingly to Wikipedia [1]:
"In mathematics, a Voronoi diagram is a partitioning of a plane into
regions based on distance to points in a specific subset of the plane.
That set of points (called seeds, sites, or generators) is specified
beforehand, and for each seed there is a corresponding region
consisting
of all points closer to that seed than to any other. These regions are
called Voronoi cells. The Voronoi diagram of a set of points is dual
to its Delaunay triangulation."
as you can easily check, pretending to pass line segments or polygons
as Voronoi "seeds" seems to be a mathematical nonsense.
[1]
http://en.wikipedia.org/wiki/Voronoi_diagram
> [1]
> There it says that the "input Geometry can be of absolutely arbitrary
> type; all Linestrings and / or Polygons will eventually be dissolved
> into Points corresponding to vertices. So after all
> ST_VoronojDiagram() (exactly as ST_DelaunayTriangulation) will always
> process a MultiPoint."
>
> So even if I use ST_VoronojDiagram(geometry) on polygons I only get
> an
> approximation of what I want.
>
sorry, I disagree: extracting all individual vertices from input
Linestrings / Polygons isn't at all "an approximation"; it's the unique
possible way to create a mathematically acceptable set of Points (aka
seeds) required by Voronoi as its input set.
> Currently it works with an implementation of fortunes algorithm and
> sampled line segments.
>
sorry again, this is incorrect; it currently works on *points* (forget
at all "line segments", it's a misconception) because this is a strict
Delaunay/Voronoi mathematical requirement.
the underlaying algorithm adopted by SpatiaLite is entirely based on
the GEOS implementation of Delaunay Triangulation.
GEOS does not directly supports the Voronoi Diagram; anyway Voronoi
simply is the dual graph of Delaunay, so SpatiaLite will simply apply
the reverse operations required to derive a Voronoi set out from a
Delaunay set. no more and no less than this.
> It works, but its slow
>
surely yes: computing a GEOS Delaunay set is an intrinsically slow
operation; then reversing the Delaunay set so to get the Voronoi set
is another complex (thus slow) operation.
the overall time is never expected to be a very brilliant one, and
will certainly dramatically increase when an huge number of points
(aka seeds) are passed as the input set.
> and sometimes not correct if two different line segments have a
> smaller distance than the sample rate used before.
>
the ST_VoronojDiagram() SQL function accepts a "tolerance" optional
argument; do you have tested if different tolerance values can
eventually help to get better (more accurate) results ?
OTH,
Sandro