diff --git a/include/geos/simplify/LineSegmentIndex.h b/include/geos/simplify/LineSegmentIndex.h index 136d7bedb9..3a8de122d9 100644 --- a/include/geos/simplify/LineSegmentIndex.h +++ b/include/geos/simplify/LineSegmentIndex.h @@ -60,7 +60,7 @@ class GEOS_DLL LineSegmentIndex { void remove(const geom::LineSegment* seg); - std::unique_ptr< std::vector > + std::vector query(const geom::LineSegment* seg); diff --git a/src/simplify/LineSegmentIndex.cpp b/src/simplify/LineSegmentIndex.cpp index 42b99e18ae..7de458c1f4 100644 --- a/src/simplify/LineSegmentIndex.cpp +++ b/src/simplify/LineSegmentIndex.cpp @@ -54,15 +54,14 @@ class LineSegmentVisitor: public index::ItemVisitor { const LineSegment* querySeg; - std::unique_ptr< std::vector > items; + std::vector items; public: LineSegmentVisitor(const LineSegment* s) : ItemVisitor(), - querySeg(s), - items(new std::vector()) + querySeg(s) {} ~LineSegmentVisitor() override @@ -70,43 +69,23 @@ class LineSegmentVisitor: public index::ItemVisitor { // nothing to do, LineSegments are not owned by us } - LineSegmentVisitor(const LineSegmentVisitor& o) - : - ItemVisitor(), - querySeg(o.querySeg), - items(new std::vector(*(o.items.get()))) - { - } - - LineSegmentVisitor& - operator=(const LineSegmentVisitor& o) - { - if(this == &o) { - return *this; - } - querySeg = o.querySeg; - items.reset(new std::vector(*(o.items.get()))); - return *this; - } - void visitItem(void* item) override { - LineSegment* seg = static_cast(item); + const LineSegment* seg = static_cast(item); if(Envelope::intersects(seg->p0, seg->p1, querySeg->p0, querySeg->p1)) { - items->push_back(seg); + items.push_back(seg); } } - std::unique_ptr< std::vector > + std::vector getItems() { // NOTE: Apparently, this is 'source' method giving up the object resource. return std::move(items); } - }; @@ -144,7 +123,7 @@ LineSegmentIndex::remove(const LineSegment* seg) } /*public*/ -std::unique_ptr< std::vector > +std::vector LineSegmentIndex::query(const LineSegment* querySeg) { Envelope env(querySeg->p0, querySeg->p1); @@ -152,7 +131,7 @@ LineSegmentIndex::query(const LineSegment* querySeg) LineSegmentVisitor visitor(querySeg); index.query(&env, visitor); - std::unique_ptr< std::vector > itemsFound = visitor.getItems(); + auto itemsFound = visitor.getItems(); return itemsFound; } diff --git a/src/simplify/TaggedLineStringSimplifier.cpp b/src/simplify/TaggedLineStringSimplifier.cpp index b9d1cccc8b..04141bddb3 100644 --- a/src/simplify/TaggedLineStringSimplifier.cpp +++ b/src/simplify/TaggedLineStringSimplifier.cpp @@ -267,7 +267,7 @@ TaggedLineStringSimplifier::hasOutputIntersection( //std::unique_ptr> auto querySegs = outputIndex->query(&flatSeg); - for(const LineSegment* querySeg : *querySegs) { + for(const LineSegment* querySeg : querySegs) { if(hasInvalidIntersection(*querySeg, flatSeg)) { return true; } @@ -304,7 +304,7 @@ TaggedLineStringSimplifier::hasInputIntersection( { const auto& querySegs = inputIndex->query(&flatSeg); - for(const LineSegment* ls : *querySegs) { + for(const LineSegment* ls : querySegs) { const TaggedLineSegment* querySeg = static_cast(ls); if (hasInvalidIntersection(*ls, flatSeg)) {