diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp index e844e23218..db9d2d5077 100644 --- a/editor/changeset_wrapper.cpp +++ b/editor/changeset_wrapper.cpp @@ -27,6 +27,11 @@ m2::RectD GetBoundingRect(vector const & geometry) } return rect; } + +bool OsmFeatrueHasTags(pugi::xml_node const & osmFt) +{ + return osmFt.child("tag"); +} } // namespace namespace pugi @@ -97,6 +102,14 @@ XMLFeature ChangesetWrapper::GetMatchingNodeFeatureFromOSM(m2::PointD const & ce ("OSM does not have any nodes at the coordinates", ll, ", server has returned:", doc)); } + if (!OsmFeatrueHasTags(bestNode)) + { + stringstream sstr; + bestNode.print(sstr); + LOG(LDEBUG, ("Node has no tags", sstr.str())); + MYTHROW(EmptyFeatureException, ("Node has no tags")); + } + return XMLFeature(bestNode); } @@ -132,7 +145,15 @@ XMLFeature ChangesetWrapper::GetMatchingAreaFeatureFromOSM(vector co bestWayOrRelation.print(sstr); LOG(LDEBUG, ("Relation is the best match", sstr.str())); MYTHROW(RelationFeatureAreNotSupportedException, - ("Got relation as the best matching.")); + ("Got relation as the best matching")); + } + + if (!OsmFeatrueHasTags(bestWayOrRelation)) + { + stringstream sstr; + bestWayOrRelation.print(sstr); + LOG(LDEBUG, ("Way or relation has no tags", sstr.str())); + MYTHROW(EmptyFeatureException, ("Way or relation has no tags")); } // TODO: rename to wayOrRelation when relations are handled. diff --git a/editor/changeset_wrapper.hpp b/editor/changeset_wrapper.hpp index 0eefcf4788..3cc09f251d 100644 --- a/editor/changeset_wrapper.hpp +++ b/editor/changeset_wrapper.hpp @@ -30,6 +30,7 @@ public: DECLARE_EXCEPTION(LinearFeaturesAreNotSupportedException, ChangesetWrapperException); // TODO: Remove this when relations are handled properly. DECLARE_EXCEPTION(RelationFeatureAreNotSupportedException, ChangesetWrapperException); + DECLARE_EXCEPTION(EmptyFeatureException, ChangesetWrapperException); ChangesetWrapper(TKeySecret const & keySecret, ServerApi06::TKeyValueTags const & comments) noexcept; ~ChangesetWrapper(); diff --git a/indexer/osm_editor.cpp b/indexer/osm_editor.cpp index efb073862c..b0b7322a34 100644 --- a/indexer/osm_editor.cpp +++ b/indexer/osm_editor.cpp @@ -60,13 +60,16 @@ constexpr char const * kUploaded = "Uploaded"; constexpr char const * kDeletedFromOSMServer = "Deleted from OSM by someone"; constexpr char const * kRelationsAreNotSupported = "Relations are not supported yet"; constexpr char const * kNeedsRetry = "Needs Retry"; +constexpr char const * kSuspiciousMatch = "Suspiciuos match"; bool NeedsUpload(string const & uploadStatus) { return uploadStatus != kUploaded && uploadStatus != kDeletedFromOSMServer && // TODO: Remove this line when relations are supported. - uploadStatus != kRelationsAreNotSupported; + uploadStatus != kRelationsAreNotSupported && + // TODO: Remove this when we have better matching algorithm. + uploadStatus != kSuspiciousMatch; } string GetEditorFilePath() { return GetPlatform().WritablePathForFile(kEditorXMLFileName); } @@ -656,6 +659,14 @@ void Editor::UploadChanges(string const & key, string const & secret, TChangeset ++errorsCount; LOG(LWARNING, (ex.what())); } + catch (ChangesetWrapper::EmptyFeatureException const & ex) + { + fti.m_uploadStatus = kSuspiciousMatch; + fti.m_uploadAttemptTimestamp = time(nullptr); + fti.m_uploadError = ex.what(); + ++errorsCount; + LOG(LWARNING, (ex.what())); + } catch (RootException const & ex) { fti.m_uploadStatus = kNeedsRetry;