Skip to content

v0.2.49..v0.2.50 changeset OsmUtils.h

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/elements/OsmUtils.h b/hoot-core/src/main/cpp/hoot/core/elements/OsmUtils.h
index 2c176ef..772082c 100644
--- a/hoot-core/src/main/cpp/hoot/core/elements/OsmUtils.h
+++ b/hoot-core/src/main/cpp/hoot/core/elements/OsmUtils.h
@@ -65,24 +65,73 @@ public:
                          const QList<std::shared_ptr<const Node>>& nodes);
 
   /**
-    Retrieves a collection of node ID's for a collection of nodes
+    Retrieves a collection of node IDs for a collection of nodes
 
     @param nodes a collection of nodes
-    @return a collection of node ID's
+    @return a collection of node IDs
     */
-  static const QList<long> nodesToNodeIds(const QList<std::shared_ptr<const Node>>& nodes);
+  static QList<long> nodesToNodeIds(const QList<std::shared_ptr<const Node>>& nodes);
 
   /**
-    Retrieves a collection of nodes given a collection of node ID's
+   * Retrieves a collection of node IDs for a collection of nodes
+   *
+   * @param nodes a collection of nodes
+   * @return a collection of node IDs
+   */
+  static std::vector<long> nodesToNodeIds(const std::vector<std::shared_ptr<const Node>>& nodes);
 
-    @param nodeIds a collection of node ID's
-    @param map the map owning the nodes with the given ID's
+  /**
+    Retrieves a collection of nodes given a collection of node IDs
+
+    @param nodeIds a collection of node IDs
+    @param map the map owning the nodes with the given IDs
     @return a collection of nodes
     */
   static QList<std::shared_ptr<const Node>> nodeIdsToNodes(
     const QList<long>& nodeIds, const std::shared_ptr<const OsmMap>& map);
 
   /**
+   * Retrieves a collection of nodes given a collection of node IDs
+   *
+   * @param nodeIds a collection of node IDs
+   * @param map the map owning the nodes with the given IDs
+   * @return a collection of nodes
+   */
+  static std::vector<std::shared_ptr<const Node>> nodeIdsToNodes(
+    const std::vector<long>& nodeIds, const std::shared_ptr<const OsmMap>& map);
+
+  /**
+   * Determines if the coordinates from two collection of nodes match, given a configurable
+   * tolerance
+   *
+   * @param nodes1 the first collection of nodes to compare
+   * @param nodes2 the second collection of nodes to compare
+   * @return true if the coordinates match; false otherwise
+   */
+  static bool nodeCoordsMatch(std::vector<std::shared_ptr<const Node>> nodes1,
+                              std::vector<std::shared_ptr<const Node>> nodes2);
+
+  /**
+   * Determines if the way node coordinates from two ways match, given a configurable
+   * tolerance
+   *
+   * @param way1 the first way with nodes to compare
+   * @param way2 the second way with nodes to compare
+   * @param map the map owning the ways
+   * @return true if the way node coordinates match; false otherwise
+   */
+  static bool nodeCoordsMatch(const ConstWayPtr& way1, const ConstWayPtr& way2,
+                              const ConstOsmMapPtr& map);
+
+  /**
+   * Returns a printable string for a collection of nodes
+   *
+   * @param nodes the nodes for which to create a string
+   * @return a string
+   */
+  static QString nodeCoordsToString(const std::vector<ConstNodePtr>& nodes);
+
+  /**
     Converts a OSM node to a coordinate
 
     @param node the node to convert
@@ -216,6 +265,15 @@ public:
                                                   const ConstOsmMapPtr& map);
 
   /**
+   * Get a detailed string respresenting a way's nodes
+   *
+   * @param way way to get info from
+   * @param map map owning the way
+   * @return a detailed way nodes string
+   */
+  static QString getWayNodesDetailedString(const ConstWayPtr& way, const ConstOsmMapPtr& map);
+
+  /**
    * Returns the first way ID from a set of relation members
    *
    * @param relation relation to check way ID for
@@ -366,6 +424,15 @@ public:
   static bool nodeContainedByAnyWay(const long nodeId, const ConstOsmMapPtr& map);
 
   /**
+   * Determines if a node is contained by more than one way in a map
+   *
+   * @param nodeId the ID of the node to search for
+   * @param map the map containing the nodes/ways
+   * @return true if more than one way contains the node; false otherwise
+   */
+  static bool nodeContainedByMoreThanOneWay(const long nodeId, const ConstOsmMapPtr& map);
+
+  /**
    * Determines if an element is contained by any relation in a map
    *
    * @param elementId the ID of the element to search for
@@ -406,6 +473,8 @@ public:
    */
   static bool mapIsPointsOnly(const OsmMapPtr& map);
 
+  // This group of allElements* methods really should probably be passing const elements and maps.
+
   /**
    * Determines if all elements in a specified collection have any tag key from a specified set of
    * keys
@@ -453,6 +522,58 @@ public:
    */
   static bool anyElementsHaveAnyKvp(const QStringList& kvps,
                                     const std::vector<ElementPtr>& elements);
+
+  /**
+   * Determines if all elements in a specified collection have any tag key from a specified set of
+   * keys
+   *
+   * @param tagKeys the tag keys to search for
+   * @param elementIds IDs of the elements to examine
+   * @param map the map containing the elements
+   * @return true if all elements from the input collection of elements contain at least one of the
+   * tag keys specified in tagKeys; false otherwise
+   */
+  static bool allElementsHaveAnyTagKey(const QStringList& tagKeys,
+                                       const std::set<ElementId>& elementIds, OsmMapPtr& map);
+
+  /**
+   * Determines if all elements in a specified collection have any tag key/value pair from a
+   * specified set of kvps
+   *
+   * @param kvp the tag key/value pairs to search for
+   * @param elementIds IDs of the elements to examine
+   * @param map the map containing the elements
+   * @return true if all elements from the input collection of elements contain at least one of the
+   * key/value pairs specified in kvps; false otherwise
+   */
+  static bool allElementsHaveAnyKvp(const QStringList& kvps,
+                                    const std::set<ElementId>& elementIds, OsmMapPtr& map);
+
+  /**
+   * Determines if any elements in a specified collection have any tag key from a specified set of
+   * keys
+   *
+   * @param tagKeys the tag keys to search for
+   * @param elementIds IDs of the elements to examine
+   * @param map the map containing the elements
+   * @return true if any elements from the input collection of elements contain at least one of the
+   * tag keys specified in tagKeys; false otherwise
+   */
+  static bool anyElementsHaveAnyTagKey(const QStringList& tagKeys,
+                                       const std::set<ElementId>& elementIds, OsmMapPtr& map);
+
+  /**
+   * Determines if any elements in a specified collection have any tag key/value pair from a
+   * specified set of kvps
+   *
+   * @param kvps the tag key/value pairs to search for
+   * @param elementIds IDs of the elements to examine
+   * @param map the map containing the elements
+   * @return true if any elements from the input collection of elements contain at least one of the
+   * key/value pairs specified in kvps; false otherwise
+   */
+  static bool anyElementsHaveAnyKvp(const QStringList& kvps,
+                                    const std::set<ElementId>& elementIds, OsmMapPtr& map);
 };
 
 }
Clone this wiki locally