From cfddd1b4736c2ab8e2456105d02ff080f1cf32d9 Mon Sep 17 00:00:00 2001 From: Thomas Fischer <thomas.fischer@ufz.de> Date: Tue, 23 Oct 2012 11:22:55 +0200 Subject: [PATCH] changed SHPInterface::adjustPolylines() in order to omit line segments with zero length --- FileIO/SHPInterface.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/FileIO/SHPInterface.cpp b/FileIO/SHPInterface.cpp index c8a9e16f155..8fd5d0db272 100644 --- a/FileIO/SHPInterface.cpp +++ b/FileIO/SHPInterface.cpp @@ -167,8 +167,17 @@ void SHPInterface::adjustPolylines (std::vector<GeoLib::Polyline*>* lines, for (size_t i = 0; i < lines->size(); i++) { GeoLib::Polyline* line( (*lines)[i] ); - size_t nPoints( line->getNumberOfPoints() ); - for (size_t j = 0; j < nPoints; j++) - line->setPointID(j, id_map[line->getPointID(j)]); + size_t previous_pnt_id (std::numeric_limits<size_t>::max()); + + for (size_t j = 0; j < line->getNumberOfPoints(); j++) { + size_t jth_pnt_id(id_map[line->getPointID(j)]); + if (previous_pnt_id == jth_pnt_id) { + line->removePoint(j); + j--; + } else { + line->setPointID(j, jth_pnt_id); + } + previous_pnt_id = jth_pnt_id; + } } } -- GitLab