Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authortatiana-yan <tatiana.kondakova@gmail.com>2019-02-21 16:47:28 +0300
committermpimenov <mpimenov@users.noreply.github.com>2019-02-21 17:23:18 +0300
commit475663de45f661d55e5c660b7ae15203cfbbafff (patch)
tree1b416f0e55b959b8a8fb32cabf9e47da2e3ec3ca /editor
parentacf76f6d4d7effccf79db24e4a4d6735a7afb09b (diff)
[editor] Minor refactoring: do not copy FeatureType to save FeatureID + style fixes.
Diffstat (limited to 'editor')
-rw-r--r--editor/edits_migration.cpp21
-rw-r--r--editor/edits_migration.hpp10
2 files changed, 15 insertions, 16 deletions
diff --git a/editor/edits_migration.cpp b/editor/edits_migration.cpp
index a6631da2ab..2ece6d96c6 100644
--- a/editor/edits_migration.cpp
+++ b/editor/edits_migration.cpp
@@ -10,15 +10,14 @@
#include "base/logging.hpp"
-#include "std/algorithm.hpp"
-#include "std/unique_ptr.hpp"
+#include <boost/optional.hpp>
namespace editor
{
FeatureID MigrateNodeFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach,
XMLFeature const & xml,
FeatureStatus const featureStatus,
- TGenerateIDFn const & generateID)
+ GenerateIDFn const & generateID)
{
if (featureStatus == FeatureStatus::Created)
return generateID();
@@ -50,9 +49,9 @@ FeatureID MigrateNodeFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach
FeatureID MigrateWayOrRelatonFeatureIndex(
osm::Editor::ForEachFeaturesNearByFn & forEach, XMLFeature const & xml,
FeatureStatus const /* Unused for now (we don't create/delete area features)*/,
- TGenerateIDFn const & /*Unused for the same reason*/)
+ GenerateIDFn const & /*Unused for the same reason*/)
{
- unique_ptr<FeatureType> feature;
+ boost::optional<FeatureID> fid;
auto bestScore = 0.6; // initial score is used as a threshold.
auto geometry = xml.GetGeometry();
auto count = 0;
@@ -64,7 +63,7 @@ FeatureID MigrateWayOrRelatonFeatureIndex(
auto const someFeaturePoint = geometry[0];
forEach(
- [&feature, &geometry, &count, &bestScore](FeatureType & ft) {
+ [&fid, &geometry, &count, &bestScore](FeatureType & ft) {
if (ft.GetFeatureType() != feature::GEOM_AREA)
return;
++count;
@@ -87,7 +86,7 @@ FeatureID MigrateWayOrRelatonFeatureIndex(
if (score > bestScore)
{
bestScore = score;
- feature = make_unique<FeatureType>(ft);
+ fid = ft.GetID();
}
},
someFeaturePoint);
@@ -95,18 +94,18 @@ FeatureID MigrateWayOrRelatonFeatureIndex(
if (count == 0)
MYTHROW(MigrationError, ("No ways returned for point", someFeaturePoint));
- if (!feature)
+ if (!fid)
{
MYTHROW(MigrationError,
- ("None of returned ways suffice. Possibly, the feature have been deleted."));
+ ("None of returned ways suffice. Possibly, the feature has been deleted."));
}
- return feature->GetID();
+ return fid.get();
}
FeatureID MigrateFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach,
XMLFeature const & xml,
FeatureStatus const featureStatus,
- TGenerateIDFn const & generateID)
+ GenerateIDFn const & generateID)
{
switch (xml.GetType())
{
diff --git a/editor/edits_migration.hpp b/editor/edits_migration.hpp
index 650c2a3db0..992803290e 100644
--- a/editor/edits_migration.hpp
+++ b/editor/edits_migration.hpp
@@ -8,18 +8,18 @@
#include "base/exception.hpp"
-#include "std/functional.hpp"
+#include <functional>
namespace editor
{
DECLARE_EXCEPTION(MigrationError, RootException);
-using TGenerateIDFn = function<FeatureID()>;
+using GenerateIDFn = std::function<FeatureID()>;
-/// Tries to match xml feature with one on a new mwm and retruns FeatrueID
-/// of a found feature, thows MigrationError if migration fails.
+/// Tries to match xml feature with one on a new mwm and returns FeatureID
+/// of a found feature, throws MigrationError if migration fails.
FeatureID MigrateFeatureIndex(osm::Editor::ForEachFeaturesNearByFn & forEach,
XMLFeature const & xml,
FeatureStatus const featureStatus,
- TGenerateIDFn const & generateID);
+ GenerateIDFn const & generateID);
} // namespace editor