Skip to content

v0.2.49..v0.2.50 changeset Way.h

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/elements/Way.h b/hoot-core/src/main/cpp/hoot/core/elements/Way.h
index 2804227..80fc093 100644
--- a/hoot-core/src/main/cpp/hoot/core/elements/Way.h
+++ b/hoot-core/src/main/cpp/hoot/core/elements/Way.h
@@ -137,6 +137,14 @@ public:
   bool isOneWay() const;
 
   /**
+   * Determines if a node ID represents the start and end node
+   *
+   * @param nodeId ID of the node to search for
+   * @return true if the node ID maps to the start and end node; false otherwise
+   */
+  bool isFirstAndLastNode(const long nodeId) const;
+
+  /**
    * @brief isSimpleLoop - checks to see if the way starts and ends at the same
    *                       node. If it does, return true.
    * @return true if the way starts and ends at the same node
@@ -169,7 +177,7 @@ public:
 
   /**
    * Replaces any node instance with oldId with newId. If oldId isn't referenced by this way then
-   * no action is taken.
+   * no action is taken. If newId already exists in the way, it is first removed before replacement.
    */
   void replaceNode(long oldId, long newId);
 
@@ -179,6 +187,15 @@ public:
   void reverseOrder();
 
   /**
+   * Determines if two ways have the same node IDs
+   *
+   * @param other way to compare node IDs with
+   * @return true if the other way has the same node IDs in the same order as this way; false
+   * otherwise
+   */
+  bool hasSameNodeIds(const Way& other) const;
+
+  /**
    * This is rarely used. Primarily it is useful when loading the way from a file that does
    * cache way envelope bounds (see .osm.pbf).
    */
@@ -217,6 +234,10 @@ private:
    * This envelope may be cached, but it also may not be exact.
    */
   mutable geos::geom::Envelope _cachedEnvelope;
+
+  // for debugging only; SLOW - We don't check for duplicated nodes (outside of start/end) at
+  // runtime due to the performance hit. So, use this to debug when that occurs.
+  bool _nodeIdsAreDuplicated(const std::vector<long>& ids) const;
 };
 
 typedef std::shared_ptr<Way> WayPtr;
Clone this wiki locally