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
diff options
context:
space:
mode:
authorArsentiy Milchakov <a.milchakov@corp.mail.ru>2016-08-09 14:26:59 +0300
committerArsentiy Milchakov <a.milchakov@corp.mail.ru>2016-08-09 14:39:27 +0300
commitcfafe65ea046427b9c47b87752b91e854dbcf635 (patch)
tree4409b63fe563bbfdb7e8fcfc3187b7c7960604cd /indexer/osm_editor.cpp
parent73994023b9a409878496c9a3ca4aee959c532eb4 (diff)
review fixes
Diffstat (limited to 'indexer/osm_editor.cpp')
-rw-r--r--indexer/osm_editor.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/indexer/osm_editor.cpp b/indexer/osm_editor.cpp
index fd030434e5..5fdde75491 100644
--- a/indexer/osm_editor.cpp
+++ b/indexer/osm_editor.cpp
@@ -8,6 +8,9 @@
#include "indexer/ftypes_matcher.hpp"
#include "indexer/index.hpp"
#include "indexer/osm_editor.hpp"
+#include "indexer/index_helpers.hpp"
+
+#include "search/reverse_geocoder.hpp"
#include "platform/local_country_file_utils.hpp"
#include "platform/platform.hpp"
@@ -136,7 +139,7 @@ namespace osm
Editor::Editor()
: m_notes(editor::Notes::MakeNotes())
- , m_storage(make_unique <editor::StorageLocal> ())
+ , m_storage(make_unique<editor::LocalStorage>())
{}
Editor & Editor::Instance()
@@ -145,6 +148,42 @@ Editor & Editor::Instance()
return instance;
}
+void Editor::SetIndex(Index const & index)
+{
+ m_mwmIdByMapNameFn = [&index](string const & name) -> MwmSet::MwmId
+ {
+ return index.GetMwmIdByCountryFile(platform::CountryFile(name));
+ };
+
+ m_getOriginalFeatureFn = [&index](FeatureID const & fid) -> unique_ptr<FeatureType>
+ {
+ unique_ptr<FeatureType> feature(new FeatureType());
+ Index::FeaturesLoaderGuard const guard(index, fid.m_mwmId);
+ if (!guard.GetOriginalFeatureByIndex(fid.m_index, *feature))
+ return nullptr;
+ feature->ParseEverything();
+ return feature;
+ };
+
+ m_getOriginalFeatureStreetFn = [&index](FeatureType & ft) -> string
+ {
+ search::ReverseGeocoder const coder(index);
+ auto const streets = coder.GetNearbyFeatureStreets(ft);
+ if (streets.second < streets.first.size())
+ return streets.first[streets.second].m_name;
+ return {};
+ };
+
+ // Due to floating points accuracy issues (geometry is saved in editor up to 7 digits
+ // after decimal point) some feature vertexes are threated as external to a given feature.
+ auto const toleranceInMeters = 1e-2;
+ m_forEachFeatureAtPointFn =
+ [&index, toleranceInMeters](TFeatureTypeFn && fn, m2::PointD const & mercator)
+ {
+ indexer::ForEachFeatureAtPoint(index, move(fn), mercator, toleranceInMeters);
+ };
+}
+
void Editor::LoadMapEdits()
{
if (!m_mwmIdByMapNameFn)