Subject: Re: [geometry] problem with wkt io
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2013-10-10 18:36:31
On 10 October 2013 23:20, Barend Gehrels <barend_at_[hidden]> wrote:
> On 10-10-2013 0:28, Mateusz Loskot wrote:
>> On 9 October 2013 20:00, lepere renaud <lepere.renaud_at_[hidden]> wrote:
>>> I am using read_wkt to read wkt polygons and wkt to convert them to string
>>> but i have some problems. I though that wkt polygons should have the last
>>> point equal to the first one ; however in my model polygons are not
>>> The function read_wkt and wkt do not handle the last point, is this
>>> normal or did i missed something ?
>> On reflection, I think it is a good idea to fix it indeed.
>> I submitted patch with a fix proposal
>> "Impose closed rings of polygon in WKT output"
>> If the patch is acceptable, I will commit, so please confirm.
> Yes, I agree it is a good idea to have the WKT always closed for polygons,
> and I agree with the patch.
Ok, I will submit.
> One detail, it can also be done at compiletime (check if model is closed)
> with the same boolean flag, or even with a compile-time iterator (more
> complex), but the proposed solution is OK too and has the advantage that
> open polygons which are closed (somehow) are not closed again.
I was considering the compile-time check, but we
still have to inspect actual data at run-time.
Like in the original example from this thread:
typedef model::point< double, 2, boost::geometry::cs::cartesian > Point;
typedef model::polygon< Point, false, false> Polygon;
read_wkt("POLYGON((1 1, 5 1, 5 5, 1 5, 1 1))", p);
if correct(p) is not called, then p has 5 points,
despite the model declares non-closed.
Or, I'm not understanding what compile-time action you mean exactly.
By the way, hmm, the example above made me realise that read_wkt
should skip last repeated point if model is non-closed,
-- Mateusz Loskot, http://mateusz.loskot.net
Geometry list run by mateusz at loskot.net