mirror of https://github.com/CGAL/cgal
Deal with read_WKT()
This commit is contained in:
parent
8cedde9036
commit
b23eb7e7b4
|
|
@ -476,6 +476,7 @@ bool read_WKT(std::istream& is,
|
||||||
{
|
{
|
||||||
auto fail = [&is]() { is.clear(is.rdstate() | std::ios::failbit); return false; };
|
auto fail = [&is]() { is.clear(is.rdstate() | std::ios::failbit); return false; };
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
std::string line;
|
std::string line;
|
||||||
while(is >> std::ws && is.good() && std::getline(is, line))
|
while(is >> std::ws && is.good() && std::getline(is, line))
|
||||||
{
|
{
|
||||||
|
|
@ -505,44 +506,57 @@ bool read_WKT(std::istream& is,
|
||||||
{
|
{
|
||||||
Point p;
|
Point p;
|
||||||
if(!IO::read_point_WKT(iss, p) ) return fail();
|
if(!IO::read_point_WKT(iss, p) ) return fail();
|
||||||
|
found = true;
|
||||||
points.push_back(p);
|
points.push_back(p);
|
||||||
}
|
}
|
||||||
else if(type == "LINESTRING")
|
else if(type == "LINESTRING")
|
||||||
{
|
{
|
||||||
LineString l;
|
LineString l;
|
||||||
if(!IO::read_linestring_WKT(iss, l)) return fail();
|
if(!IO::read_linestring_WKT(iss, l)) return fail();
|
||||||
|
found = true;
|
||||||
polylines.push_back(std::move(l));
|
polylines.push_back(std::move(l));
|
||||||
}
|
}
|
||||||
else if(type == "POLYGON")
|
else if(type == "POLYGON")
|
||||||
{
|
{
|
||||||
Polygon p;
|
Polygon p;
|
||||||
if(!IO::read_polygon_WKT(iss, p)) return fail();
|
if(!IO::read_polygon_WKT(iss, p)) return fail();
|
||||||
if(!p.outer_boundary().is_empty())
|
if(!p.outer_boundary().is_empty()){
|
||||||
|
found = true;
|
||||||
polygons.push_back(std::move(p));
|
polygons.push_back(std::move(p));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(type == "MULTIPOINT")
|
else if(type == "MULTIPOINT")
|
||||||
{
|
{
|
||||||
MultiPoint mp;
|
MultiPoint mp;
|
||||||
if(!IO::read_multi_point_WKT(iss, mp)) return fail();
|
if(!IO::read_multi_point_WKT(iss, mp)) return fail();
|
||||||
for(const Point& point : mp)
|
for(const Point& point : mp){
|
||||||
points.push_back(point);
|
points.push_back(point);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(type == "MULTILINESTRING")
|
else if(type == "MULTILINESTRING")
|
||||||
{
|
{
|
||||||
MultiLineString mls;
|
MultiLineString mls;
|
||||||
if(!IO::read_multi_linestring_WKT(iss, mls)) return fail();
|
if(!IO::read_multi_linestring_WKT(iss, mls)) return fail();
|
||||||
for(LineString& ls : mls)
|
for(LineString& ls : mls){
|
||||||
polylines.push_back(std::move(ls));
|
polylines.push_back(std::move(ls));
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(type == "MULTIPOLYGON")
|
else if(type == "MULTIPOLYGON")
|
||||||
{
|
{
|
||||||
MultiPolygon mp;
|
MultiPolygon mp;
|
||||||
if(!IO::read_multi_polygon_WKT(iss, mp)) return fail();
|
if(!IO::read_multi_polygon_WKT(iss, mp)) return fail();
|
||||||
for(Polygon& poly : mp)
|
for(Polygon& poly : mp){
|
||||||
polygons.push_back(std::move(poly));
|
polygons.push_back(std::move(poly));
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!found){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return !is.fail();
|
return !is.fail();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue