Skip to content

v0.2.53..v0.2.54 changeset OsmApiChangeset.h

Garret Voltz edited this page Mar 31, 2020 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/io/OsmApiChangeset.h b/hoot-core/src/main/cpp/hoot/core/io/OsmApiChangeset.h
index d0695a2..be931a7 100644
--- a/hoot-core/src/main/cpp/hoot/core/io/OsmApiChangeset.h
+++ b/hoot-core/src/main/cpp/hoot/core/io/OsmApiChangeset.h
@@ -59,6 +59,7 @@ typedef std::map<long, std::set<long>> NodeIdToWayIdMap;
 typedef std::map<long, std::set<long>> NodeIdToRelationIdMap;
 typedef std::map<long, std::set<long>> WayIdToRelationIdMap;
 typedef std::map<long, std::set<long>> RelationIdToRelationIdMap;
+typedef std::vector<std::set<long>> ElementCountSet;
 
 /** XML Changeset data object */
 class XmlChangeset
@@ -66,6 +67,7 @@ class XmlChangeset
 public:
   /** Constructors */
   XmlChangeset();
+  explicit XmlChangeset(const QString& changeset);
   explicit XmlChangeset(const QList<QString>& changesets);
   /**  Allow test class to access protected members for white box testing */
   friend class OsmApiChangesetTest;
@@ -85,11 +87,6 @@ public:
    */
   void updateChangeset(const QString& changes);
   /**
-   * @brief updateChangeset Update the changeset setting all elements to "uploaded" for the apply test scenario
-   * @param changeset_info - Pointer to the changeset info object
-   */
-  void updateChangeset(const ChangesetInfoPtr& changeset_info);
-  /**
    * @brief fixChangeset Update the underlying element to fix changeset upload errors
    * @param update - OSM XML from OSM API to fix changeset errors
    * @return True if a change was made to fix the changeset
@@ -120,6 +117,8 @@ public:
     TypeDelete,
     TypeMax
   };
+  /** Convert ChangesetType to string */
+  static QString getString(ChangesetType type);
   /**
    * @brief calculateChangeset Create an atomic subset of this changeset that can be sent independently from others
    * @param changeset - Pointer to a ChangesetInfo object holding IDs for a subset of the changeset
@@ -285,7 +284,6 @@ public:
    * @return true if the file was written successfully
    */
   bool writeErrorFile();
-
   /**
    * @brief calculateRemainingChangeset This function is an error correction case for when a changeset cannot finish
    *  and the upload stalls indefinitely.  Move all remaining elements into a changeset so the job can finish or error out.
@@ -293,6 +291,12 @@ public:
    * @return true if there is anything in the changeset
    */
   bool calculateRemainingChangeset(ChangesetInfoPtr &changeset);
+  /**
+   * @brief isMatch Function to compare two changesets
+   * @param changeset Changeset object to compare this changeset against
+   * @return true if they are equivalent
+   */
+  bool isMatch(const XmlChangeset& changeset);
 
 private:
   /**
@@ -306,6 +310,11 @@ private:
    */
   void loadChangesetXml(const QString& changesetXml);
   /**
+   * @brief loadChangesetDirectory Load directory of changeset files, can include request/response changeset files
+   * @param changesetDirectory Full pathname of the directory to load
+   */
+  void loadChangesetDirectory(const QString& changesetDirectory);
+  /**
    * @brief loadChangeset Load a .osc changeset file
    * @param reader
    */
@@ -416,11 +425,15 @@ private:
    * @brief getObjectCount Get the number of elements affected by this node/way/relation
    * @param changeset Subset containing the element
    * @param node/way/relation Pointer to the element to count
+   * @param elements Reference to a vector of sets of IDs so that node/way/relation IDs aren't counted twice
    * @return total number of elements within this element
    */
-  size_t getObjectCount(ChangesetInfoPtr& changeset, ChangesetNode* node);
-  size_t getObjectCount(ChangesetInfoPtr& changeset, ChangesetWay* way);
-  size_t getObjectCount(ChangesetInfoPtr& changeset, ChangesetRelation* relation);
+  size_t getObjectCount(ChangesetNode* node, ElementCountSet& elements);
+  size_t getObjectCount(ChangesetWay* way, ElementCountSet& elements);
+  size_t getObjectCount(ChangesetRelation* relation, ElementCountSet& elements);
+  size_t getObjectCount(ChangesetInfoPtr& changeset, ChangesetNode* node, ElementCountSet& elements);
+  size_t getObjectCount(ChangesetInfoPtr& changeset, ChangesetWay* way, ElementCountSet& elements);
+  size_t getObjectCount(ChangesetInfoPtr& changeset, ChangesetRelation* relation, ElementCountSet& elements);
   /**
    * @brief isSent Check if this element's status is buffering, sent, or finalized
    * @param element Pointer to the element to check
@@ -491,8 +504,10 @@ private:
   ChangesetTypeMap _relations;
   /** Element ID to ID data structure for checking old ID to new ID and new ID to old ID lookups */
   ElementIdToIdMap _idMap;
-  /** Maximum changeset push size */
+  /** Maximum changeset push size, could be slightly over to get an entire element */
   long _maxPushSize;
+  /** Maximum size of a changeset that cannot be exceeded */
+  long _maxChangesetSize;
   /** Count of elements that have been sent */
   long _sentCount;
   /** Count of elements that have been processed */
Clone this wiki locally