Boost logo

Geometry :

Subject: [geometry] problem with wkt io
From: lepere renaud (lepere.renaud_at_[hidden])
Date: 2013-10-09 15:00:07


  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 closed. The function read_wkt and wkt do not handle the last point,
is this normal or did i missed something ?

A small code to illustrate the problem.

#include "boost/geometry.hpp"
#include "boost/geometry/geometries/geometries.hpp"
#include "boost/geometry/io/wkt/wkt.hpp"

using namespace boost::geometry;

typedef model::point< double, 2, boost::geometry::cs::cartesian > Point;
typedef model::polygon< Point, false, false > Polygon;

int main()
{
     Polygon p;
     read_wkt("POLYGON((0.0 0.0, 10.0 0.0, 10.0 10.0, 0 10.0, 0.0
0.0))", p);
     // p is invalid according to the definition above
     // (do not repeat last point)
     correct(p);
     std::cout << p.outer().size() << std::endl;

     // i thought that wkt impose last point to be equal to the
     // first one. this is not the case here.
     std::cout << wkt(p) << std::endl;

     return 0;
}

Thanks,

Renaud


Geometry list run by mateusz at loskot.net