From 78d881a67d312fef99000a7e815799d8c66cf009 Mon Sep 17 00:00:00 2001 From: Harry Bond Date: Thu, 18 Apr 2024 15:29:08 +0100 Subject: [PATCH 1/2] [generator][indexer] include collection_times in map data Signed-off-by: Harry Bond --- feature_list/feature_list.cpp | 5 +++-- generator/osm2meta.cpp | 6 ++++++ generator/osm2meta.hpp | 1 + indexer/feature_meta.cpp | 3 +++ indexer/feature_meta.hpp | 1 + indexer/map_object.cpp | 5 +++++ indexer/map_object.hpp | 4 ++++ 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/feature_list/feature_list.cpp b/feature_list/feature_list.cpp index b41700b24b..246beccda9 100644 --- a/feature_list/feature_list.cpp +++ b/feature_list/feature_list.cpp @@ -266,6 +266,7 @@ public: string const denomination(meta.Get(feature::Metadata::FMD_DENOMINATION)); string const wheelchair(GetWheelchairType(f)); string const opening_hours(meta.Get(feature::Metadata::FMD_OPEN_HOURS)); + string const collection_times(meta.Get(feature::Metadata::FMD_COLLECTION_TIMES)); string const wikipedia(meta.Get(feature::Metadata::FMD_WIKIPEDIA)); string const wikimedia_commons(meta.Get(feature::Metadata::FMD_WIKIMEDIA_COMMONS)); string const floor(meta.Get(feature::Metadata::FMD_LEVEL)); @@ -276,7 +277,7 @@ public: osmId, uid, lat, lon, mwmName, category, name, std::string(city), addrStreet, addrHouse, phone, website, stars, std::string(metaOperator), internet, denomination, wheelchair, opening_hours, wikipedia, floor, fee, atm, contact_facebook, - contact_instagram, contact_twitter, contact_vk, contact_line, wikimedia_commons}; + contact_instagram, contact_twitter, contact_vk, contact_line, wikimedia_commons, collection_times}; AppendNames(f, columns); PrintAsCSV(columns, ';', cout); @@ -290,7 +291,7 @@ void PrintHeader() "phone", "website", "cuisines", "stars", "operator", "internet", "denomination", "wheelchair", "opening_hours", "wikipedia", "floor", "fee", "atm", "contact_facebook", "contact_instagram", - "contact_twitter", "contact_vk", "contact_line", "wikimedia_commons"}; + "contact_twitter", "contact_vk", "contact_line", "wikimedia_commons", "collection_times"}; // Append all supported name languages in order. for (uint8_t idx = 1; idx < kLangCount; idx++) columns.push_back("name_" + string(StringUtf8Multilang::GetLangByCode(idx))); diff --git a/generator/osm2meta.cpp b/generator/osm2meta.cpp index 00ff4cad81..748b5c688c 100644 --- a/generator/osm2meta.cpp +++ b/generator/osm2meta.cpp @@ -152,6 +152,11 @@ std::string MetadataTagProcessorImpl::ValidateAndFormat_opening_hours(std::strin return v; } +std::string MetadataTagProcessorImpl::ValidateAndFormat_collection_times(std::string const & v) +{ + return v; +} + std::string MetadataTagProcessorImpl::ValidateAndFormat_ele(std::string const & v) const { if (IsNoNameNoAddressBuilding(m_params)) @@ -510,6 +515,7 @@ void MetadataTagProcessor::operator()(std::string const & k, std::string const & switch (mdType) { case Metadata::FMD_OPEN_HOURS: valid = ValidateAndFormat_opening_hours(v); break; + case Metadata::FMD_COLLECTION_TIMES: valid = ValidateAndFormat_collection_times(v); break; case Metadata::FMD_FAX_NUMBER: // The same validator as for phone. case Metadata::FMD_PHONE_NUMBER: valid = ValidateAndFormat_phone(v); break; case Metadata::FMD_STARS: valid = ValidateAndFormat_stars(v); break; diff --git a/generator/osm2meta.hpp b/generator/osm2meta.hpp index e9bae0d28b..b4c1d7efe6 100644 --- a/generator/osm2meta.hpp +++ b/generator/osm2meta.hpp @@ -15,6 +15,7 @@ struct MetadataTagProcessorImpl static std::string ValidateAndFormat_url(std::string const & v) ; static std::string ValidateAndFormat_phone(std::string const & v) ; static std::string ValidateAndFormat_opening_hours(std::string const & v) ; + static std::string ValidateAndFormat_collection_times(std::string const & v) ; std::string ValidateAndFormat_ele(std::string const & v) const; static std::string ValidateAndFormat_destination(std::string const & v) ; static std::string ValidateAndFormat_local_ref(std::string const & v) ; diff --git a/indexer/feature_meta.cpp b/indexer/feature_meta.cpp index f57ac1d655..a2ce85d36f 100644 --- a/indexer/feature_meta.cpp +++ b/indexer/feature_meta.cpp @@ -63,6 +63,8 @@ bool Metadata::TypeFromString(string_view k, Metadata::EType & outType) { if (k == "opening_hours") outType = Metadata::FMD_OPEN_HOURS; + else if (k == "collection_times") + outType = Metadata::FMD_COLLECTION_TIMES; else if (k == "phone" || k == "contact:phone" || k == "contact:mobile" || k == "mobile") outType = Metadata::FMD_PHONE_NUMBER; else if (k == "fax" || k == "contact:fax") @@ -213,6 +215,7 @@ string ToString(Metadata::EType type) { case Metadata::FMD_CUISINE: return "cuisine"; case Metadata::FMD_OPEN_HOURS: return "opening_hours"; + case Metadata::FMD_COLLECTION_TIMES: return "collection_times"; case Metadata::FMD_PHONE_NUMBER: return "phone"; case Metadata::FMD_FAX_NUMBER: return "fax"; case Metadata::FMD_STARS: return "stars"; diff --git a/indexer/feature_meta.hpp b/indexer/feature_meta.hpp index 84a823303a..690a5a7291 100644 --- a/indexer/feature_meta.hpp +++ b/indexer/feature_meta.hpp @@ -152,6 +152,7 @@ public: FMD_LOCAL_REF = 44, FMD_DRIVE_THROUGH = 45, FMD_WEBSITE_MENU = 46, + FMD_COLLECTION_TIMES = 47, FMD_COUNT }; diff --git a/indexer/map_object.cpp b/indexer/map_object.cpp index 04107651ab..f354130c49 100644 --- a/indexer/map_object.cpp +++ b/indexer/map_object.cpp @@ -146,6 +146,11 @@ std::string_view MapObject::GetOpeningHours() const return m_metadata.Get(MetadataID::FMD_OPEN_HOURS); } +std::string_view MapObject::GetCollectionTimes() const +{ + return m_metadata.Get(MetadataID::FMD_COLLECTION_TIMES); +} + feature::Internet MapObject::GetInternet() const { return feature::InternetFromString(m_metadata.Get(MetadataID::FMD_INTERNET)); diff --git a/indexer/map_object.hpp b/indexer/map_object.hpp index 220e0e519c..5831dc8c76 100644 --- a/indexer/map_object.hpp +++ b/indexer/map_object.hpp @@ -80,7 +80,11 @@ public: std::string FormatRoadShields() const; std::string_view GetOpeningHours() const; + + std::string_view GetCollectionTimes() const; + feature::Internet GetInternet() const; + int GetStars() const; /// @returns true if feature has ATM type. -- 2.45.3 From 2d43548f2f83a4c70b7bc8f3241c46b8519f876d Mon Sep 17 00:00:00 2001 From: Harry Bond Date: Sun, 30 Jun 2024 23:58:38 +0100 Subject: [PATCH 2/2] [android] basic collection_times on placepage Signed-off-by: Harry Bond --- .../organicmaps/bookmarks/data/Metadata.java | 3 ++- .../widget/placepage/PlacePageView.java | 8 +++++++ .../main/res/drawable/ic_collection_icon.xml | 14 ++++++++++++ .../layout/place_page_collection_times.xml | 22 +++++++++++++++++++ .../main/res/layout/place_page_details.xml | 2 ++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 android/app/src/main/res/drawable/ic_collection_icon.xml create mode 100644 android/app/src/main/res/layout/place_page_collection_times.xml diff --git a/android/app/src/main/java/app/organicmaps/bookmarks/data/Metadata.java b/android/app/src/main/java/app/organicmaps/bookmarks/data/Metadata.java index c79e25f7ac..5ef228ae16 100644 --- a/android/app/src/main/java/app/organicmaps/bookmarks/data/Metadata.java +++ b/android/app/src/main/java/app/organicmaps/bookmarks/data/Metadata.java @@ -64,7 +64,8 @@ public class Metadata implements Parcelable FMD_WHEELCHAIR(43), FMD_LOCAL_REF(44), FMD_DRIVE_THROUGH(45), - FMD_WEBSITE_MENU(46); + FMD_WEBSITE_MENU(46), + FMD_COLLECTION_TIMES(47); private final int mMetaType; MetadataType(int metadataType) diff --git a/android/app/src/main/java/app/organicmaps/widget/placepage/PlacePageView.java b/android/app/src/main/java/app/organicmaps/widget/placepage/PlacePageView.java index 67ae7d51e8..bcdc00e93e 100644 --- a/android/app/src/main/java/app/organicmaps/widget/placepage/PlacePageView.java +++ b/android/app/src/main/java/app/organicmaps/widget/placepage/PlacePageView.java @@ -114,6 +114,8 @@ public class PlacePageView extends Fragment implements View.OnClickListener, private View mAddOrganisation; private View mAddPlace; private View mEditTopSpace; + private View mCollectionTimes; + private TextView mTvCollectionTimes; // Data private CoordinatesFormat mCoordsFormat = CoordinatesFormat.LatLonDecimal; @@ -267,6 +269,9 @@ public class PlacePageView extends Fragment implements View.OnClickListener, mCapacity.setOnLongClickListener(this); mWheelchair.setOnLongClickListener(this); mDriveThrough.setOnLongClickListener(this); + mCollectionTimes = mFrame.findViewById(R.id.ll__place_collection_times); + mTvCollectionTimes = mFrame.findViewById(R.id.tv__place_collection_times); + mCollectionTimes.setOnLongClickListener(this); mDownloaderIcon = new DownloaderStatusIcon(mPreview.findViewById(R.id.downloader_status_frame)); @@ -408,6 +413,9 @@ public class PlacePageView extends Fragment implements View.OnClickListener, final String level = Utils.getLocalizedLevel(getContext(), mMapObject.getMetadata(Metadata.MetadataType.FMD_LEVEL)); refreshMetadataOrHide(level, mLevel, mTvLevel); + final String collectionTimes = mMapObject.getMetadata(Metadata.MetadataType.FMD_COLLECTION_TIMES); + refreshMetadataOrHide(collectionTimes, mCollectionTimes, mTvCollectionTimes); + final String cap = mMapObject.getMetadata(Metadata.MetadataType.FMD_CAPACITY); refreshMetadataOrHide(!TextUtils.isEmpty(cap) ? getString(R.string.capacity, cap) : "", mCapacity, mTvCapacity); diff --git a/android/app/src/main/res/drawable/ic_collection_icon.xml b/android/app/src/main/res/drawable/ic_collection_icon.xml new file mode 100644 index 0000000000..7fc1ea3303 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_collection_icon.xml @@ -0,0 +1,14 @@ + + + + diff --git a/android/app/src/main/res/layout/place_page_collection_times.xml b/android/app/src/main/res/layout/place_page_collection_times.xml new file mode 100644 index 0000000000..a23382de21 --- /dev/null +++ b/android/app/src/main/res/layout/place_page_collection_times.xml @@ -0,0 +1,22 @@ + + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/place_page_details.xml b/android/app/src/main/res/layout/place_page_details.xml index 3b6ba48746..f5d4d89061 100644 --- a/android/app/src/main/res/layout/place_page_details.xml +++ b/android/app/src/main/res/layout/place_page_details.xml @@ -35,6 +35,8 @@ android:layout_height="wrap_content" tools:layout="@layout/place_page_opening_hours_fragment" /> + + -- 2.45.3