-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.54..v0.2.55 changeset HighwaySnapMergerJs.cpp
Garret Voltz edited this page Aug 14, 2020
·
1 revision
diff --git a/hoot-js/src/main/cpp/hoot/js/conflate/merging/HighwaySnapMergerJs.cpp b/hoot-js/src/main/cpp/hoot/js/conflate/merging/HighwaySnapMergerJs.cpp
index df219ab..1c5e81f 100644
--- a/hoot-js/src/main/cpp/hoot/js/conflate/merging/HighwaySnapMergerJs.cpp
+++ b/hoot-js/src/main/cpp/hoot/js/conflate/merging/HighwaySnapMergerJs.cpp
@@ -29,6 +29,7 @@
// hoot
#include <hoot/core/util/Factory.h>
#include <hoot/core/conflate/highway/HighwayTagOnlyMerger.h>
+#include <hoot/core/conflate/river/RiverSnapMerger.h>
#include <hoot/js/JsRegistrar.h>
#include <hoot/js/elements/OsmMapJs.h>
@@ -98,7 +99,7 @@ void HighwaySnapMergerJs::New(const FunctionCallbackInfo<Value>& args)
HandleScope scope(current);
HighwaySnapMergerJs* obj = new HighwaySnapMergerJs();
- // node::ObjectWrap::Wrap takes ownership of the pointer in a v8::Persistent<v8::Object>
+ // node::ObjectWrap::Wrap takes ownership of the pointer in a v8::Persistent<v8::Object>
obj->Wrap(args.This());
args.GetReturnValue().Set(args.This());
@@ -113,8 +114,21 @@ void HighwaySnapMergerJs::apply(const FunctionCallbackInfo<Value>& args)
OsmMapPtr map = toCpp<OsmMapPtr>(args[1]);
MergerBase::PairsSet pairs = toCpp<MergerBase::PairsSet>(args[2]);
vector<pair<ElementId, ElementId>> replaced =
- toCpp<vector<pair<ElementId, ElementId>>>(args[3]);
+ toCpp<vector<pair<ElementId, ElementId>>>(args[3]);
const QString matchedBy = toCpp<QString>(args[4]);
+ SublineStringMatcherPtr sublineMatcher2;
+ if (args.Length() > 5)
+ {
+ // This is little unusual, but we're allowing an extra subline matcher to be passed info for
+ // river conflation only and the actual one used will be determined based on the input data.
+ // See RiverSnapMerger for more info.
+ if (matchedBy != "Waterway")
+ {
+ throw IllegalArgumentException(
+ "Only river merging allows passing in multiple subline matchers.");
+ }
+ sublineMatcher2 = toCpp<SublineStringMatcherPtr>(args[5]);
+ }
// see explanation in ConflateCmd as to why we use this option to identify Attribute Conflation
const bool isAttributeConflate = ConfigOptions().getHighwayMergeTagsOnly();
@@ -124,11 +138,18 @@ void HighwaySnapMergerJs::apply(const FunctionCallbackInfo<Value>& args)
// HighwayTagOnlyMerger inherits from HighwaySnapMerger, so this works.
snapMerger.reset(new HighwayTagOnlyMerger(pairs, sublineMatcher));
}
+ else if (matchedBy == "Waterway")
+ {
+ // see note above about multiple subline matchers here
+ snapMerger.reset(new RiverSnapMerger(pairs, sublineMatcher, sublineMatcher2));
+ }
else
{
snapMerger.reset(new HighwaySnapMerger(pairs, sublineMatcher));
}
snapMerger->setMatchedBy(matchedBy);
+ // Some attempts were made to use cached subline matches from SublineStringMatcherJst for
+ // performance reasons, but the results were unstable. See branch 3969b.
snapMerger->apply(map, replaced);
// modify the parameter that was passed in