diff --git a/feature_list/feature_list.cpp b/feature_list/feature_list.cpp index b88d062b4e..003d7981b8 100644 --- a/feature_list/feature_list.cpp +++ b/feature_list/feature_list.cpp @@ -3,6 +3,8 @@ #include "coding/file_name_utils.hpp" +#include "generator/utils.hpp" + #include "geometry/mercator.hpp" #include "geometry/point2d.hpp" @@ -105,6 +107,18 @@ string GetWheelchairType(FeatureType const & f) return result; } +bool HasAtm(FeatureType const & f) +{ + static const uint32_t atm = classif().GetTypeByPath({"amenity", "atm"}); + bool result = false; + f.ForEachType([&result](uint32_t type) + { + if (type == atm) + result = true; + }); + return result; +} + string BuildUniqueId(ms::LatLon const & coords, string const & name) { ostringstream ss; @@ -175,15 +189,17 @@ public: void ClearCache() { m_villagesCache.Clear(); } - void operator()(FeatureType const & f, uint32_t const & id) { Process(f); } + void operator()(FeatureType const & f, map const & ft2osm) { Process(f, ft2osm); } - void Process(FeatureType const & f) + void Process(FeatureType const & f, map const & ft2osm) { f.ParseBeforeStatistic(); string const & category = GetReadableType(f); // "operator" is a reserved word, hence "operatr". This word is pretty common in C++ projects. string const & operatr = f.GetMetadata().Get(feature::Metadata::FMD_OPERATOR); - if ((!f.HasName() && operatr.empty()) || f.GetFeatureType() == feature::GEOM_LINE || category.empty()) + auto const & osmIt = ft2osm.find(f.GetID().m_index); + if ((!f.HasName() && operatr.empty()) || f.GetFeatureType() == feature::GEOM_LINE || + category.empty() || osmIt == ft2osm.cend()) return; m2::PointD const & center = FindCenter(f); ms::LatLon const & ll = MercatorBounds::ToLatLon(center); @@ -200,6 +216,7 @@ public: f.GetPreferredNames(name, secondary); if (name.empty()) name = operatr; + string const & osmId = strings::to_string(osmIt->second.EncodedId()); string const & uid = BuildUniqueId(ll, name); string const & lat = strings::to_string_with_digits_after_comma(ll.lat, 6); string const & lon = strings::to_string_with_digits_after_comma(ll.lon, 6); @@ -230,11 +247,15 @@ public: string const & denomination = f.GetMetadata().Get(feature::Metadata::FMD_DENOMINATION); string const & wheelchair = GetWheelchairType(f); string const & opening_hours = f.GetMetadata().Get(feature::Metadata::FMD_OPEN_HOURS); + string const & wikipedia = f.GetMetadata().Get(feature::Metadata::FMD_WIKIPEDIA); + string const & floor = f.GetMetadata().Get(feature::Metadata::FMD_LEVEL); + string const & fee = strings::EndsWith(category, "-fee") ? "yes" : ""; + string const & atm = HasAtm(f) ? "yes" : ""; - vector columns = {uid, lat, lon, mwmName, category, + vector columns = {osmId, uid, lat, lon, mwmName, category, name, city, addrStreet, addrHouse, phone, website, cuisine, stars, operatr, internet, - denomination, wheelchair, opening_hours}; + denomination, wheelchair, opening_hours, wikipedia, floor, fee, atm}; AppendNames(f, columns); PrintAsCSV(columns, ';', cout); } @@ -242,16 +263,23 @@ public: void PrintHeader() { - vector columns = {"id", "lat", "lon", "mwm", "category", + vector columns = {"id", "old_id", "lat", "lon", "mwm", "category", "name", "city", "street", "house", "phone", "website", "cuisines", "stars", "operator", "internet", - "denomination", "wheelchair", "opening_hours"}; + "denomination", "wheelchair", "opening_hours", "wikipedia", "floor", "fee", "atm"}; // Append all supported name languages in order. for (uint8_t idx = 1; idx < kLangCount; idx++) columns.push_back("name_" + string(StringUtf8Multilang::GetLangByCode(idx))); PrintAsCSV(columns, ';', cout); } +bool ParseFeatureIdToOsmIdMapping(string const & path, map & mapping) +{ + return generator::ForEachOsmId2FeatureId(path, [&](osm::Id const & osmId, uint32_t const featureId) { + mapping[featureId] = osmId; + }); +} + void DidDownload(storage::TCountryId const & /* countryId */, shared_ptr const & /* localFile */) { @@ -316,13 +344,16 @@ int main(int argc, char ** argv) if (argc > 3 && !strings::StartsWith(mwmInfo->GetCountryName() + DATA_FILE_EXTENSION, argv[3])) continue; LOG(LINFO, ("Processing", mwmInfo->GetCountryName())); + string osmToFeatureFile = my::JoinFoldersToPath(argv[1], mwmInfo->GetCountryName() + DATA_FILE_EXTENSION + OSM2FEATURE_FILE_EXTENSION); + map featureIdToOsmId; + ParseFeatureIdToOsmIdMapping(osmToFeatureFile, featureIdToOsmId); MwmSet::MwmId mwmId(mwmInfo); Index::FeaturesLoaderGuard loader(index, mwmId); for (uint32_t ftIndex = 0; ftIndex < loader.GetNumFeatures(); ftIndex++) { FeatureType ft; if (loader.GetFeatureByIndex(static_cast(ftIndex), ft)) - doProcess.Process(ft); + doProcess.Process(ft, featureIdToOsmId); } doProcess.ClearCache(); } diff --git a/storage/storage.cpp b/storage/storage.cpp index ae40df96c9..eeef9ebd9b 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -709,7 +709,7 @@ void Storage::LoadCountriesFile(string const & pathToCountriesFile, string const if (!m_dataDir.empty() && !Platform::MkDirChecked(my::JoinFoldersToPath(GetPlatform().WritableDir(), m_dataDir))) { - MYTHROW(FileSystemException, ("Unable to find or create directory", m_dataDir)); + // MYTHROW(FileSystemException, ("Unable to find or create directory", m_dataDir)); } if (m_countries.IsEmpty())