[geos-commits] [SCM] GEOS branch master updated. 1ba1e6cba3e877d4f42525272b2c9f12b04977f8
git at osgeo.org
git at osgeo.org
Thu Sep 20 10:22:53 PDT 2018
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, master has been updated
via 1ba1e6cba3e877d4f42525272b2c9f12b04977f8 (commit)
via 066e5290dbe5332320910e8de2ebb101a5d42a0c (commit)
via 4c714189907c9f95516c34b5b373e13e2ad1b6bb (commit)
from f7867f9e6ff5379a14dd78890925e7ecd1bf22dc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 1ba1e6cba3e877d4f42525272b2c9f12b04977f8
Merge: f7867f9 066e529
Author: Daniel Baston <dbaston at gmail.com>
Date: Thu Sep 20 13:22:34 2018 -0400
Merge branch 'indexed-point-in-area-reduce-heap'
commit 066e5290dbe5332320910e8de2ebb101a5d42a0c
Author: Daniel Baston <dbaston at gmail.com>
Date: Thu Sep 20 13:22:16 2018 -0400
Remove unneeded constructor call
diff --git a/src/algorithm/locate/IndexedPointInAreaLocator.cpp b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
index dbc1e35..47fbed5 100644
--- a/src/algorithm/locate/IndexedPointInAreaLocator.cpp
+++ b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
@@ -36,8 +36,7 @@ namespace locate {
//
// private:
//
-IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry( const geom::Geometry & g) :
-index{index::intervalrtree::SortedPackedIntervalRTree()}
+IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry( const geom::Geometry & g)
{
init( g);
}
commit 4c714189907c9f95516c34b5b373e13e2ad1b6bb
Author: Daniel Baston <dbaston at gmail.com>
Date: Tue Sep 18 12:34:35 2018 -0400
Minimize heap allocations in IndexedPointInAreaLocator
diff --git a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
index 369b042..c6bb288 100644
--- a/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
+++ b/include/geos/algorithm/locate/IndexedPointInAreaLocator.h
@@ -4,6 +4,7 @@
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
+ * Copyright (C) 2018 Daniel Baston <dbaston at gmail.com>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
@@ -18,7 +19,9 @@
#include <geos/algorithm/locate/PointOnGeometryLocator.h> // inherited
#include <geos/index/ItemVisitor.h> // inherited
+#include <geos/index/intervalrtree/SortedPackedIntervalRTree.h> // inherited
+#include <memory>
#include <vector> // composition
namespace geos {
@@ -31,11 +34,6 @@ namespace geos {
class CoordinateSequence;
class LineSegment;
}
- namespace index {
- namespace intervalrtree {
- class SortedPackedIntervalRTree;
- }
- }
}
namespace geos {
@@ -58,17 +56,16 @@ private:
class IntervalIndexedGeometry
{
private:
- index::intervalrtree::SortedPackedIntervalRTree * index;
+ index::intervalrtree::SortedPackedIntervalRTree index;
void init( const geom::Geometry & g);
- void addLine( geom::CoordinateSequence * pts);
+ void addLine(const geom::CoordinateSequence * pts);
- // To keep track of allocated LineSegments
- std::vector< geom::LineSegment* > allocatedSegments;
+ // To keep track of LineSegments
+ std::vector< geom::LineSegment > segments;
public:
IntervalIndexedGeometry( const geom::Geometry & g);
- ~IntervalIndexedGeometry();
void query(double min, double max, index::ItemVisitor * visitor);
};
@@ -92,7 +89,7 @@ private:
const geom::Geometry & areaGeom;
- IntervalIndexedGeometry * index;
+ std::unique_ptr<IntervalIndexedGeometry> index;
void buildIndex( const geom::Geometry & g);
@@ -107,8 +104,6 @@ public:
*/
IndexedPointInAreaLocator( const geom::Geometry & g);
- ~IndexedPointInAreaLocator() override;
-
/**
* Determines the {@link Location} of a point in an areal {@link Geometry}.
*
diff --git a/src/algorithm/locate/IndexedPointInAreaLocator.cpp b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
index d670f55..dbc1e35 100644
--- a/src/algorithm/locate/IndexedPointInAreaLocator.cpp
+++ b/src/algorithm/locate/IndexedPointInAreaLocator.cpp
@@ -4,6 +4,7 @@
* http://geos.osgeo.org
*
* Copyright (C) 2001-2002 Vivid Solutions Inc.
+ * Copyright (C) 2018 Daniel Baston <dbaston at gmail.com>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
@@ -35,51 +36,35 @@ namespace locate {
//
// private:
//
-IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry( const geom::Geometry & g)
+IndexedPointInAreaLocator::IntervalIndexedGeometry::IntervalIndexedGeometry( const geom::Geometry & g) :
+index{index::intervalrtree::SortedPackedIntervalRTree()}
{
- index = new index::intervalrtree::SortedPackedIntervalRTree();
init( g);
}
-IndexedPointInAreaLocator::IntervalIndexedGeometry::~IntervalIndexedGeometry( )
-{
- delete index;
-
- for ( size_t i = 0, ni = allocatedSegments.size(); i < ni; ++i )
- {
- delete allocatedSegments[i];
- }
-}
-
void
IndexedPointInAreaLocator::IntervalIndexedGeometry::init( const geom::Geometry & g)
{
geom::LineString::ConstVect lines;
geom::util::LinearComponentExtracter::getLines( g, lines);
- for ( size_t i = 0, ni = lines.size(); i < ni; i++ )
- {
- const geom::LineString * line = lines[ i ];
- geom::CoordinateSequence * pts = line->getCoordinates();
-
- addLine( pts);
+ for (const geom::LineString* line : lines) {
+ addLine(line->getCoordinatesRO());
+ }
- delete pts;
+ for (geom::LineSegment & seg : segments) {
+ index.insert(
+ std::min( seg.p0.y, seg.p1.y),
+ std::max( seg.p0.y, seg.p1.y),
+ &seg);
}
}
void
-IndexedPointInAreaLocator::IntervalIndexedGeometry::addLine( geom::CoordinateSequence * pts)
+IndexedPointInAreaLocator::IntervalIndexedGeometry::addLine(const geom::CoordinateSequence * pts)
{
- for ( size_t i = 1, ni = pts->size(); i < ni; i++ )
- {
- geom::LineSegment * seg = new geom::LineSegment( (*pts)[ i - 1 ], (*pts)[ i ]);
- double const min = std::min( seg->p0.y, seg->p1.y);
- double const max = std::max( seg->p0.y, seg->p1.y);
-
- // NOTE: seg ownership still ours
- allocatedSegments.push_back(seg);
- index->insert( min, max, seg);
+ for (size_t i = 1, ni = pts->size(); i < ni; i++) {
+ segments.emplace_back((*pts)[i - 1], (*pts)[i]);
}
}
@@ -87,7 +72,7 @@ IndexedPointInAreaLocator::IntervalIndexedGeometry::addLine( geom::CoordinateSeq
void
IndexedPointInAreaLocator::buildIndex( const geom::Geometry & g)
{
- index = new IndexedPointInAreaLocator::IntervalIndexedGeometry( g);
+ index = std::unique_ptr<IntervalIndexedGeometry>(new IntervalIndexedGeometry(g));
}
@@ -105,16 +90,9 @@ IndexedPointInAreaLocator::IndexedPointInAreaLocator( const geom::Geometry & g)
&& typeid( areaGeom) != typeid( geom::MultiPolygon) )
throw util::IllegalArgumentException("Argument must be Polygonal");
- //areaGeom = g;
-
buildIndex( areaGeom);
}
-IndexedPointInAreaLocator::~IndexedPointInAreaLocator()
-{
- delete index;
-}
-
int
IndexedPointInAreaLocator::locate( const geom::Coordinate * /*const*/ p)
{
@@ -130,15 +108,15 @@ IndexedPointInAreaLocator::locate( const geom::Coordinate * /*const*/ p)
void
IndexedPointInAreaLocator::SegmentVisitor::visitItem( void * item)
{
- geom::LineSegment * seg = (geom::LineSegment *)item;
+ geom::LineSegment* seg = static_cast<geom::LineSegment*>(item);
- counter->countSegment( (*seg)[ 0 ], (*seg)[ 1 ]);
+ counter->countSegment(seg->p0, seg->p1);
}
void
IndexedPointInAreaLocator::IntervalIndexedGeometry::query( double min, double max, index::ItemVisitor * visitor)
{
- index->query( min, max, visitor);
+ index.query( min, max, visitor);
}
-----------------------------------------------------------------------
Summary of changes:
.../algorithm/locate/IndexedPointInAreaLocator.h | 21 ++++-----
src/algorithm/locate/IndexedPointInAreaLocator.cpp | 55 +++++++---------------
2 files changed, 24 insertions(+), 52 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list