
Geometry : 
Subject: [geometry] what should be the minimum size of geometries supported in BG algorithms?
From: Menelaos Karavelas (menelaos.karavelas_at_[hidden])
Date: 20150113 10:36:20
Hello all and happy new year.
I have been facing the following issue when implementing support for
various algorithms in BG and for various geometries (especially with
bg::distance): what should be the minimum sized geometry that should be
supported by the algorithm?
More precise questions:
* should bg::distance be able to return a distance when onepoint
linestrings are passed to it?
* should bg::distance be able to return a distance when one of the two
input geometries is a closed polygon with less than four points?
In both cases above the geometries are invalid (in the OGC sense), and
this actually brings up a more general question. To what extend should
we support invalid geometries in BG algorithms?
In the current version of bg::distance if the uses passes an onepoint
linestring the algorithm sometimes returns something meaningful, and
other times an assertion is triggered. Such a behavior is IMHO in some
sense okay: BG algorithms are not guaranteed to work on invalid input
(but they should work with valid input). So either returning something
meaningful or triggering an assertion, or even returning something not
meaningful is okay in the sense that the algorithm's behavior is undefined.
Motivated by the above I decided to implement a new algorithm called
is_below_minimum_size. It takes a geometry as input and returns true if
the geometry's size is below the minimum acceptable valid size (see also
the corresponding PR: https://github.com/boostorg/geometry/pull/193). In
the PR there is a related new exception, and my intention was to use
that exception instead of the empty_geometry_exception currently used in
the bg::distance code. Using the new exception would avoid some
assertion failures, and would treat geometries with very few points in a
unified manner (through exceptions).
On the other hand, it would limit the support for bg::distance on
invalid geometries.
I would like your thoughts/suggestions/comments on any of the statements
made above.
All the best,
 m.
Geometry list run by mateusz at loskot.net