$include_dir="/home/hyper-archives/geometry/include"; include("$include_dir/msg-header.inc") ?>
Subject: [ggl] transform linestring into a ring
From: Simonson, Lucanus J (lucanus.j.simonson)
Date: 2011-04-13 12:44:25
Barend Gehrels wrote:
> Hi,
> 
> 
>> Dose ggl has any wrap class that able to wrap a linestring as a ring,
>> rather than copying the linestring into an actual ring?
> 
> A wrapper class, e.g. having a const reference to a linestring and
> behaving itself as a ring (so this is what you want I assume) does not
> exist.
> 
> Good idea. It is probably easy to create it yourself.
> 
> Regards, Barend
A general wrapper for viewing a model of one geometry concept as another geometry concept should be easy to add to the library.
Polygon can be viewed as a refinement of linestring since it restricts the definition of linestring to closed loops (perhaps non self intersecting also.)
To view a model of a concept as a refinement of that concept is not safe in general, but based on runtime information or knowledge of the programmer than the invariant of the refinement is true it is a very useful capability.  In Polygon I provide the view_as template function that returns a view_of wrapper type.
        template<typename concept_type, typename object_type>
        view_of<concept_type, object_type> view_as<concept_type>(object_type& obj);
All you have to do is make sure that view_of automatically satisfies the requirements of the concept type specified with a little template metaprogramming in the library.  It is not something I would expect most users to be able to do for themselves.  In general you may need to implement specializations of view_of for each legal combination of concept types and make sure that the default view_of is empty and will not compile if used with a nonsensical pair of concepts.
Regards,
Luke