-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.55..v0.2.56 changeset ChangesetReplacementCreator.h
Garret Voltz edited this page Aug 14, 2020
·
3 revisions
diff --git a/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetReplacementCreator.h b/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetReplacementCreator.h
index 51a6581..a5ee162 100644
--- a/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetReplacementCreator.h
+++ b/hoot-core/src/main/cpp/hoot/core/algorithms/changeset/ChangesetReplacementCreator.h
@@ -40,52 +40,6 @@ namespace hoot
{
/**
- * Options used to control cropping at various stages of the replacement changeset workflow
- */
-struct BoundsOptions
-{
- // Determines whether features crossing the bounds should be kept when loading reference data.
- bool loadRefKeepEntireCrossingBounds;
- // Determines whether only features completely inside the bounds should be kept when loading
- // reference data.
- bool loadRefKeepOnlyInsideBounds;
- // Determines whether ways immediately connected to other ways being kept but completely outside
- // of the bounds should also be kept
- bool loadRefKeepImmediateConnectedWaysOutsideBounds;
- // Determines whether features crossing the bounds should be kept when loading secondary data.
- bool loadSecKeepEntireCrossingBounds;
- // Determines whether only features completely inside the bounds should be kept when loading
- // secondary data.
- bool loadSecKeepOnlyInsideBounds;
-
- // Determines whether features crossing the bounds should be kept when cookie cutting reference
- // data.
- bool cookieCutKeepEntireCrossingBounds;
- // Determines whether only features completely inside the bounds should be kept when cookie
- // cutting reference data.
- bool cookieCutKeepOnlyInsideBounds;
-
- // Determines whether reference features crossing the bounds should be kept when deriving a
- // changeset.
- bool changesetRefKeepEntireCrossingBounds;
- // Determines whether secondary features crossing the bounds should be kept when deriving a
- // changeset.
- bool changesetSecKeepEntireCrossingBounds;
- // Determines whether only reference features completely inside the bounds should be kept when
- // deriving a changeset.
- bool changesetRefKeepOnlyInsideBounds;
- // Determines whether only secondary features completely inside the bounds should be kept when
- // deriving a changeset.
- bool changesetSecKeepOnlyInsideBounds;
- // Determines whether deleting reference features existing either partially of completely outside
- // of the bounds is allowed during changeset generation
- bool changesetAllowDeletingRefOutsideBounds;
- // the strictness of the bounds calculation used in conjunction with
- // _changesetAllowDeletingRefOutsideBounds
- bool inBoundsStrict;
-};
-
-/**
* High level class for prepping data for replacement changeset generation (changesets which
* replace features inside of a specified bounds) and then calls on the appropriate changeset file
* writer to output a changeset file.
@@ -94,18 +48,79 @@ struct BoundsOptions
* generated for, whether all the reference features or just those that overlap secondary features
* are to be replaced, and how strict the AOI is to be interpreted. ChangesetCreator is used for the
* actual changeset generation and file output. This class handles the cookie cutting, conflation,
- * and a host of other things that need to happen before the changeset generation. The secondary
- * data added to the output changeset, as well as the reference data removed from the changeset can
- * be further restricted with a non-geometry type filter.
+ * and a host of other things that need to happen before the replacement changeset is generated.
+ * The secondary data added to the output changeset, as well as the reference data removed from the
+ * changeset can be further restricted with a non-geometry type filter.
+ *
+ * Occasionally, relations will be passed in with some members missing. This class will optionally
+ * tag those with a custom metadata tag to be passed to the changeset output. This allows for
+ * potential manual repairing of those relations after the changeset is written, and after that the
+ * tag can then be removed. This is also a configurable feature, which can be turned off.
*
* TODO: implement progress
* TODO: can probably break some of this up into separate classes now; e.g. filtering, etc.
+ * TODO: need to test missing way node refs
*/
class ChangesetReplacementCreator
{
+ /**
+ * Options used to control cropping at various stages of the replacement changeset workflow
+ */
+ struct BoundsOptions
+ {
+ // Determines whether features crossing the bounds should be kept when loading reference data.
+ bool loadRefKeepEntireCrossingBounds;
+ // Determines whether only features completely inside the bounds should be kept when loading
+ // reference data.
+ bool loadRefKeepOnlyInsideBounds;
+ // Determines whether ways immediately connected to other ways being kept but completely outside
+ // of the bounds should also be kept
+ bool loadRefKeepImmediateConnectedWaysOutsideBounds;
+ // Determines whether features crossing the bounds should be kept when loading secondary data.
+ bool loadSecKeepEntireCrossingBounds;
+ // Determines whether only features completely inside the bounds should be kept when loading
+ // secondary data.
+ bool loadSecKeepOnlyInsideBounds;
+
+ // Determines whether features crossing the bounds should be kept when cookie cutting reference
+ // data.
+ bool cookieCutKeepEntireCrossingBounds;
+ // Determines whether only features completely inside the bounds should be kept when cookie
+ // cutting reference data.
+ bool cookieCutKeepOnlyInsideBounds;
+
+ // Determines whether reference features crossing the bounds should be kept when deriving a
+ // changeset.
+ bool changesetRefKeepEntireCrossingBounds;
+ // Determines whether secondary features crossing the bounds should be kept when deriving a
+ // changeset.
+ bool changesetSecKeepEntireCrossingBounds;
+ // Determines whether only reference features completely inside the bounds should be kept when
+ // deriving a changeset.
+ bool changesetRefKeepOnlyInsideBounds;
+ // Determines whether only secondary features completely inside the bounds should be kept when
+ // deriving a changeset.
+ bool changesetSecKeepOnlyInsideBounds;
+ // Determines whether deleting reference features existing either partially of completely outside
+ // of the bounds is allowed during changeset generation
+ bool changesetAllowDeletingRefOutsideBounds;
+ // the strictness of the bounds calculation used in conjunction with
+ // _changesetAllowDeletingRefOutsideBounds
+ bool inBoundsStrict;
+ };
+
public:
+ // see command doc for more detail
+ // TODO: Hybrid may go away
+ enum BoundsInterpretation
+ {
+ Strict = 0, // only features completely inside or lines crossing that get cut at the boundary
+ Lenient, // features inside and overlapping
+ Hybrid // points inside, polys inside and overlapping, lines cut at the boundary
+ };
+
/**
* Constructor
*
@@ -134,7 +149,8 @@ public:
const QString& output);
void setFullReplacement(const bool full) { _fullReplacement = full; }
- void setLenientBounds(const bool lenient) { _lenientBounds = lenient; }
+ void setBoundsInterpretation(const BoundsInterpretation& interpretation)
+ { _boundsInterpretation = interpretation; }
void setGeometryFilters(const QStringList& filterClassNames);
void setReplacementFilters(const QStringList& filterClassNames);
void setChainReplacementFilters(const bool chain) { _chainReplacementFilters = chain; }
@@ -156,7 +172,7 @@ private:
bool _fullReplacement;
// determines how strict the handling of the bounds is during replacement
- bool _lenientBounds;
+ BoundsInterpretation _boundsInterpretation;
// A set of geometry type filters, organized by core geometry type (point, line, poly) to
// separately filter the input datasets on.
@@ -205,14 +221,17 @@ private:
// controls cropping
BoundsOptions _boundsOpts;
+ // determines if the current changeset map generation pass contains only linear features
+ bool _currentChangeDerivationPassIsLinear;
+
// handles changeset generation and output
std::shared_ptr<ChangesetCreator> _changesetCreator;
- bool _isNetworkConflate() const;
+ QString _boundsInterpretationToString(const BoundsInterpretation& boundsInterpretation) const;
- void _validateInputs(const QString& input1, const QString& input2);
+ void _validateInputs(const QString& input1, const QString& input2, const QString& output);
- QString _getJobDescription(
+ void _printJobDescription(
const QString& input1, const QString& input2, const QString& bounds,
const QString& output) const;
@@ -242,14 +261,15 @@ private:
const QString& debugFileName);
void _setGlobalOpts(const QString& boundsStr);
- void _parseConfigOpts(
- const bool lenientBounds, const GeometryTypeCriterion::GeometryType& geometryType);
+ void _parseConfigOpts(const GeometryTypeCriterion::GeometryType& geometryType);
OsmMapPtr _loadRefMap(const QString& input);
OsmMapPtr _loadSecMap(const QString& input);
/*
- * Adds a custom tag to any element from the input with a missing child
+ * Adds a custom tag to any element from the input with a missing child. This is primarily useful
+ * in repairing relations manually that were passed in without some of their child elements after
+ * the replacement changeset is written.
*/
void _markElementsWithMissingChildren(OsmMapPtr& map);
@@ -264,8 +284,13 @@ private:
*/
void _addChangesetDeleteExclusionTags(OsmMapPtr& map);
+ /*
+ * Cut out of the reference map what you don't want, and if there is anything in the secondary
+ * map, add that data in (not applicable in the cut only scenario).
+ */
OsmMapPtr _getCookieCutMap(OsmMapPtr doughMap, OsmMapPtr cutterMap,
- const GeometryTypeCriterion::GeometryType& geometryType);
+ const GeometryTypeCriterion::GeometryType& geometryType,
+ const geos::geom::Envelope& replacementBounds);
/*
* Copies all ways that are tagged with MetadataTags::HootConnectedWayOutsideBounds() out of a map
@@ -295,7 +320,7 @@ private:
*/
void _removeUnsnappedImmediatelyConnectedOutOfBoundsWays(OsmMapPtr& map);
- void _conflate(OsmMapPtr& map, const bool lenientBounds);
+ void _conflate(OsmMapPtr& map);
void _removeConflateReviews(OsmMapPtr& map);
void _clean(OsmMapPtr& map);