Subject: [ggl] Ring type as template parameter for polygon
From: Barend Gehrels (barend)
Date: 2011-11-20 17:02:57
On 20-11-2011 16:39, Tarem, Zvi wrote:
> I totally agree regarding the uncontrolled proliferation of macros.
> As for consistency, consider this:
> ->A coordinate type lays underneath the entire object structure.
> ->A point is a basic building block that depends on the coordinate type.
> ->boxes, linestrings and rings are all a collection of points, so they
> naturally depend on their element type - the point type.
> ->polygons are a collection of rings, existing only to allow the
> specification of holes. All other 'polygon-like' attributes are
> associated with rings, so they should naturally depend on their
> element type - the ring type.
> ->multi_polygons are a collection of polygons, so they naturally depend
> on their element type - the polygon type.
> I fail to see the advantage in the dependency of polygons on the point
> type, even for consistency.
Yes, you have a point of course.
However, the polygon is probably the most widely used geometry. If it
would be defined as:
polygon<ring<point<...>>> it is just looking complicated.
The first versions of Boost.Geometry tried to look as simple as
possible, also for users not accustomed to templates. That is partly
still the case, so people can use bg::within(a,b) without even noticing
the template system behind. But for geometries, we don't have those
shortcuts anymore indeed.
Anyway, it cannot be changed anymore, this feature is used by probably
everybody using Boost.Geometry.
> Note that if the polygon template depends on the ring type, then no custom
> polygon type is required for a custom ring type, a simple typedef will suffice.
> Perhaps in my spare time(?) I will try to implement a ring-dependent
> polygon type and see where it leads.
That is welcome! ;-)
Geometry list run by mateusz at loskot.net