[geos-commits] [SCM] GEOS branch master updated. 53f842fb79cdb3f44291bfdbe05388dbbb99a6f5
git at osgeo.org
git at osgeo.org
Wed Sep 4 13:11:30 PDT 2019
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 53f842fb79cdb3f44291bfdbe05388dbbb99a6f5 (commit)
from cd3af0d40a9ab78fddf16abf29bd4d7bce099868 (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 53f842fb79cdb3f44291bfdbe05388dbbb99a6f5
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Wed Sep 4 13:10:59 2019 -0700
MonotoneChainBuilder can be refactored to avoid using
an array of indexes completely, by constructing
MonotoneChain objects as they determined.
https://github.com/locationtech/jts/pull/467
diff --git a/include/geos/index/chain/MonotoneChainBuilder.h b/include/geos/index/chain/MonotoneChainBuilder.h
index aa82fcf..5bb1e5a 100644
--- a/include/geos/index/chain/MonotoneChainBuilder.h
+++ b/include/geos/index/chain/MonotoneChainBuilder.h
@@ -55,18 +55,19 @@ public:
/** \brief
* Return a newly-allocated vector of newly-allocated
* MonotoneChain objects for the given CoordinateSequence.
- *
- * @note Remember to deep-delete the result.
*/
static std::unique_ptr<std::vector<std::unique_ptr<MonotoneChain>>> getChains(
const geom::CoordinateSequence* pts,
void* context);
/** \brief
- * Fill the provided vector with newly-allocated MonotoneChain objects
- * for the given CoordinateSequence.
+ * Computes a list of the {@link MonotoneChain}s
+ * for a list of coordinates,
+ * attaching a context data object to each.
*
- * @note Remember to delete vector elements!
+ * @param pts the list of points to compute chains for
+ * @param context a data object to attach to each chain
+ * @return a list of the monotone chains for the points
*/
static void getChains(const geom::CoordinateSequence* pts,
void* context,
@@ -78,16 +79,6 @@ public:
return getChains(pts, nullptr);
}
- /** \brief
- * Fill the given vector with start/end indexes of the monotone chains
- * for the given CoordinateSequence.
- *
- * The last entry in the array points to the end point of the point
- * array, for use as a sentinel.
- */
- static void getChainStartIndices(const geom::CoordinateSequence& pts,
- std::vector<std::size_t>& startIndexList);
-
/**
* Disable copy construction and assignment. Apparently needed to make this
* class compile under MSVC. (See https://stackoverflow.com/q/29565299)
@@ -102,9 +93,11 @@ private:
* Finds the index of the last point in a monotone chain
* starting at a given point.
*
- * Any repeated points (0-length segments) will be included
+ * Repeated points (0-length segments) are included
* in the monotone chain returned.
*
+ * @param pts the points to scan
+ * @param start the index of the start of this chain
* @return the index of the last point in the monotone chain
* starting at <code>start</code>.
*
diff --git a/src/geomgraph/index/MonotoneChainEdge.cpp b/src/geomgraph/index/MonotoneChainEdge.cpp
index 42126cf..d3dbcfa 100644
--- a/src/geomgraph/index/MonotoneChainEdge.cpp
+++ b/src/geomgraph/index/MonotoneChainEdge.cpp
@@ -57,8 +57,8 @@ MonotoneChainEdge::MonotoneChainEdge(Edge* newE):
pts(newE->getCoordinates())
{
assert(e);
- MonotoneChainIndexer mcb;
- mcb.getChainStartIndices(pts, startIndex);
+ MonotoneChainIndexer mci;
+ mci.getChainStartIndices(pts, startIndex);
assert(e);
}
diff --git a/src/index/chain/MonotoneChainBuilder.cpp b/src/index/chain/MonotoneChainBuilder.cpp
index 64fce94..db5cc20 100644
--- a/src/index/chain/MonotoneChainBuilder.cpp
+++ b/src/index/chain/MonotoneChainBuilder.cpp
@@ -54,38 +54,19 @@ MonotoneChainBuilder::getChains(const CoordinateSequence* pts, void* context)
/* static public */
void
MonotoneChainBuilder::getChains(const CoordinateSequence* pts, void* context,
- vector<std::unique_ptr<MonotoneChain>>& mcList)
+ std::vector<std::unique_ptr<MonotoneChain>>& mcList)
{
- vector<std::size_t> startIndex;
- getChainStartIndices(*pts, startIndex);
- std::size_t nindexes = startIndex.size();
- if(nindexes > 0) {
- std::size_t n = nindexes - 1;
- for(std::size_t i = 0; i < n; i++) {
- mcList.emplace_back(new MonotoneChain(*pts, startIndex[i], startIndex[i + 1], context));
- }
- }
-}
-
-/* static public */
-void
-MonotoneChainBuilder::getChainStartIndices(const CoordinateSequence& pts,
- vector<std::size_t>& startIndexList)
-{
- // find the startpoint (and endpoints) of all monotone chains
- // in this edge
- std::size_t start = 0;
- startIndexList.push_back(start);
- const std::size_t n = pts.getSize() - 1;
+ std::size_t chainStart = 0;
do {
- std::size_t last = findChainEnd(pts, start);
- startIndexList.push_back(last);
- start = last;
+ std::size_t chainEnd = findChainEnd(*pts, chainStart);
+ MonotoneChain *mc = new MonotoneChain(*pts, chainStart, chainEnd, context);
+ mcList.emplace_back(mc);
+ chainStart = chainEnd;
}
- while(start < n);
-
+ while (chainStart < (pts->size() - 1));
}
+
/* private static */
std::size_t
MonotoneChainBuilder::findChainEnd(const CoordinateSequence& pts, std::size_t start)
-----------------------------------------------------------------------
Summary of changes:
include/geos/index/chain/MonotoneChainBuilder.h | 25 +++++++-----------
src/geomgraph/index/MonotoneChainEdge.cpp | 4 +--
src/index/chain/MonotoneChainBuilder.cpp | 35 ++++++-------------------
3 files changed, 19 insertions(+), 45 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list