Merge pull request 'Add SnappingNoder seeding' (!116) from mdavis/geos:add-snappingnoder-seeding into main
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #116gh-autolink
commit
c693615c05
|
|
@ -73,6 +73,9 @@ private:
|
|||
std::vector<SegmentString*>* nodedResult;
|
||||
|
||||
// Methods
|
||||
|
||||
void seedSnapIndex(std::vector<SegmentString*>& segStrings);
|
||||
|
||||
void snapVertices(std::vector<SegmentString*>& segStrings, std::vector<SegmentString*>& nodedStrings);
|
||||
|
||||
SegmentString* snapVertices(SegmentString* ss);
|
||||
|
|
@ -115,6 +118,3 @@ public:
|
|||
} // namespace geos::noding::snap
|
||||
} // namespace geos::noding
|
||||
} // namespace geos
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#include <geos/noding/snap/SnappingNoder.h>
|
||||
#include <geos/noding/snap/SnappingIntersectionAdder.h>
|
||||
|
||||
//#include <geos/profiler.h>
|
||||
|
||||
#include <algorithm> // for std::min and std::max
|
||||
#include <memory>
|
||||
|
||||
|
|
@ -53,12 +55,43 @@ SnappingNoder::computeNodes(std::vector<SegmentString*>* inputSegStrings)
|
|||
void
|
||||
SnappingNoder::snapVertices(std::vector<SegmentString*>& segStrings, std::vector<SegmentString*>& nodedStrings)
|
||||
{
|
||||
//geos::util::Profiler* profiler = geos::util::Profiler::instance();
|
||||
//auto sw = profiler->get(std::string("SnappingNoder::snapVertices"));
|
||||
//sw->start();
|
||||
|
||||
seedSnapIndex(segStrings);
|
||||
for (SegmentString* ss: segStrings) {
|
||||
nodedStrings.push_back(snapVertices(ss));
|
||||
}
|
||||
|
||||
//sw->stop();
|
||||
//std::cout << sw->name << " - " << sw->getTotFormatted() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
/*private*/
|
||||
void
|
||||
SnappingNoder::seedSnapIndex(std::vector<SegmentString*>& segStrings)
|
||||
{
|
||||
double PHI_INV = (sqrt(5) - 1.0) / 2.0;
|
||||
|
||||
for (SegmentString* ss: segStrings) {
|
||||
CoordinateSequence* cs = ss->getCoordinates();
|
||||
int numPts = (int) cs->size();
|
||||
int numPtsToLoad = numPts / 100;
|
||||
double rand = 0.0;
|
||||
|
||||
for (int i = 0; i < numPtsToLoad; i++) {
|
||||
// quasi-random sequennce generated by additive recurrence with irrational constant
|
||||
rand = rand + PHI_INV;
|
||||
if (rand > 1) rand = rand - floor(rand);
|
||||
|
||||
int index = (int) (numPts * rand);
|
||||
snapIndex.snap(cs->getAt(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*private*/
|
||||
SegmentString*
|
||||
SnappingNoder::snapVertices(SegmentString* ss)
|
||||
|
|
|
|||
Loading…
Reference in New Issue