mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 21:13:55 +00:00
Add "Business is vacant"/'disused' option to editor (#526)
Signed-off-by: map-per <map-per@gmx.de> Co-authored-by: map-per <map-per@gmx.de> Co-committed-by: map-per <map-per@gmx.de>
This commit is contained in:
@@ -33,6 +33,7 @@ set(SRC
|
||||
xml_feature.cpp
|
||||
xml_feature.hpp
|
||||
yes_no_unknown.hpp
|
||||
keys_to_remove.hpp
|
||||
)
|
||||
|
||||
omim_add_library(${PROJECT_NAME} ${SRC})
|
||||
|
||||
@@ -57,6 +57,9 @@ std::string GetTypeForFeature(editor::XMLFeature const & node)
|
||||
}
|
||||
}
|
||||
|
||||
if (node.HasTag("disused:shop") || node.HasTag("disused:amenity"))
|
||||
return "vacant business";
|
||||
|
||||
if (node.HasTag("addr:housenumber") || node.HasTag("addr:street") || node.HasTag("addr:postcode"))
|
||||
return "address";
|
||||
|
||||
|
||||
135
libs/editor/keys_to_remove.hpp
Normal file
135
libs/editor/keys_to_remove.hpp
Normal file
@@ -0,0 +1,135 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
// Keys that should be removed when a place in OSM is replaced, copied from
|
||||
// https://github.com/mnalis/StreetComplete-taginfo-categorize/blob/master/sc_to_remove.txt
|
||||
|
||||
// Changes to the list: don't remove 'wheelchair' and addresses in the 'contact:' style
|
||||
|
||||
inline constexpr std::string_view kKeysToRemove[] = {
|
||||
"shop_?[1-9]?(:.*)?", "craft_?[1-9]?", "amenity_?[1-9]?", "club_?[1-9]?", "old_amenity",
|
||||
"old_shop", "information", "leisure", "office_?[1-9]?", "tourism",
|
||||
// popular shop=* / craft=* subkeys
|
||||
"marketplace", "household", "swimming_pool", "laundry", "golf", "sports", "ice_cream",
|
||||
"scooter", "music", "retail", "yes", "ticket", "newsagent", "lighting", "truck", "car_repair",
|
||||
"car_parts", "video", "fuel", "farm", "car", "tractor", "hgv", "ski", "sculptor",
|
||||
"hearing_aids", "surf", "photo", "boat", "gas", "kitchen", "anime", "builder", "hairdresser",
|
||||
"security", "bakery", "bakehouse", "fishing", "doors", "kiosk", "market", "bathroom", "lamps",
|
||||
"vacant", "insurance(:.*)?", "caravan", "gift", "bicycle", "bicycle_rental", "insulation",
|
||||
"communication", "mall", "model", "empty", "wood", "hunting", "motorcycle", "trailer",
|
||||
"camera", "water", "fireplace", "outdoor", "blacksmith", "electronics", "fan", "piercing",
|
||||
"stationery", "sensory_friendly(:.*)?", "street_vendor", "sells(:.*)?", "safety_equipment",
|
||||
// obsoleted information
|
||||
"(demolished|abandoned|disused)(:(?!bui).+)?", "was:.*", "not:.*", "damage", "created_by",
|
||||
"check_date", "opening_date", "last_checked", "checked_exists:date", "pharmacy_survey",
|
||||
"old_ref", "update", "import_uuid", "review", "fixme:atp",
|
||||
// classifications / links to external databases
|
||||
"fhrs:.*", "old_fhrs:.*", "fvst:.*", "ncat", "nat_ref", "gnis:.*", "winkelnummer",
|
||||
"type:FR:FINESS", "type:FR:APE", "kvl_hro:amenity", "ref:DK:cvr(:.*)?", "certifications?",
|
||||
"transiscope", "opendata:type", "local_ref", "official_ref",
|
||||
// names and identifications
|
||||
"name_?[1-9]?(:.*)?", ".*_name_?[1-9]?(:.*)?", "noname", "branch(:.*)?", "brand(:.*)?",
|
||||
"not:brand(:.*)?", "network(:.*)?", "operator(:.*)?", "operator_type", "ref", "ref:vatin",
|
||||
"designation", "SEP:CLAVEESC", "identifier", "ref:FR:SIRET", "ref:FR:SIREN", "ref:FR:NAF",
|
||||
"(old_)?ref:FR:prix-carburants",
|
||||
// contacts
|
||||
"contact_person", "phone(:.*)?", "phone_?[1-9]?", "emergency:phone", "emergency_telephone_code",
|
||||
"contact:(?!housenumber$|street$|place$|postcode$|city$|country$|pobox$|unit$).*",
|
||||
"mobile", "fax", "facebook", "instagram", "twitter", "youtube", "telegram", "tiktok", "email",
|
||||
"website_?[1-9]?(:.*)?", "app:.*", "ownership",
|
||||
"url", "url:official", "source_ref:url", "owner",
|
||||
// payments
|
||||
"payment(:.*)?", "payment_multi_fee", "currency(:.*)?", "cash_withdrawal(:.*)?", "fee",
|
||||
"charge", "charge_fee", "money_transfer", "donation:compensation", "paypoint",
|
||||
// generic shop/craft attributes
|
||||
"seasonal", "time", "opening_hours(:.*)?", "check_(in|out)", "wifi", "internet",
|
||||
"internet_access(:.*)?", "second_hand", "self_service", "automated", "license:.*",
|
||||
"bulk_purchase", ".*:covid19", "language:.*", "baby_feeding", "description(:.*)?",
|
||||
"description[0-9]", "min_age", "max_age", "supermarket(:.*)?", "social_facility(:.*)?",
|
||||
"functional", "trade", "wholesale", "sale", "smoking(:outside)?", "zero_waste", "origin",
|
||||
"attraction", "strapline", "dog", "showroom", "toilets?(:.*)?", "sanitary_dump_station",
|
||||
"changing_table(:.*)?", "blind", "company(:.*)?", "stroller", "walk-in",
|
||||
"webshop", "operational_status.*", "status", "drive_through", "surveillance(:.*)?",
|
||||
"outdoor_seating", "indoor_seating", "colour", "access_simple", "floor", "product_category",
|
||||
"guide", "source_url", "category", "kids_area", "kids_area:indoor", "resort", "since", "state",
|
||||
"temporary", "self_checkout", "audio_loop", "related_law(:.*)?", "official_status(:.*)?",
|
||||
// food and drink details
|
||||
"bar", "cafe", "coffee", "microroasting", "microbrewery", "brewery", "real_ale", "taproom",
|
||||
"training", "distillery", "drink(:.*)?", "cocktails", "alcohol", "wine([:_].*)?",
|
||||
"happy_hours", "diet:.*", "cuisine", "ethnic", "tasting", "breakfast", "lunch", "organic",
|
||||
"produced_on_site", "restaurant", "food", "pastry", "pastry_shop", "product", "produce",
|
||||
"chocolate", "fair_trade", "butcher", "reservation(:.*)?", "takeaway(:.*)?", "delivery(:.*)?",
|
||||
"caterer", "real_fire", "flour_fortified", "highchair", "fast_food", "pub", "snack",
|
||||
"confectionery", "drinking_water:refill",
|
||||
// related to repair shops/crafts
|
||||
"service(:.*)?", "motorcycle:.*", "repair", ".*:repair", "electronics_repair(:.*)?",
|
||||
"workshop",
|
||||
// shop=hairdresser, shop=clothes
|
||||
"unisex", "male", "female", "gender", "gender_simple", "lgbtq(:.*)?", "gay", "female:signed",
|
||||
"male:signed",
|
||||
// healthcare
|
||||
"healthcare(:.*)?", "healthcare_.*", "health", "health_.*", "speciality", "medical_.*",
|
||||
"emergency_ward", "facility(:.*)?", "activities", "healthcare_facility(:.*)?",
|
||||
"laboratory(:.*)?", "blood(:.*)?", "blood_components", "infection(:.*)?", "disease(:.*)?",
|
||||
"covid19(:.*)?", "COVID_.*", "CovidVaccineCenterId", "coronaquarantine", "hospital(:.*)?",
|
||||
"hospital_type_id", "emergency_room", "sample_collection(:.*)?", "bed_count", "capacity:beds",
|
||||
"part_time_beds", "personnel:count", "staff_count(:.*)?", "admin_staff", "doctors",
|
||||
"doctors_num", "nurses_num", "counselling_type", "testing_centres", "toilets_number",
|
||||
"urgent_care", "vaccination", "clinic", "hospital", "pharmacy", "alternative", "laboratory",
|
||||
"sample_collection", "provided_for(:.*)?", "social_facility_for", "ambulance", "ward",
|
||||
"HSE_(code|hgid|hgroup|region)", "collection_centre", "design", "AUTORIZATIE", "reg_id",
|
||||
"post_addr", "scope", "ESTADO", "NIVSOCIO", "NO", "EMP_EST", "COD_HAB", "CLA_PERS", "CLA_PRES",
|
||||
"snis_code:.*", "hfac_bed", "hfac_type", "nature", "moph_code", "IJSN:.*", "massgis:id",
|
||||
"OGD-Stmk:.*", "paho:.*", "panchayath", "pbf_contract", "pcode", "pe:minsa:.*", "who:.*",
|
||||
"pharmacy:category", "tactile_paving", "HF_(ID|TYPE|N_EN)", "RoadConn", "bin", "hiv(:.*)?",
|
||||
// accommodation & layout
|
||||
"rooms", "stars", "accommodation", "beds", "capacity(:persons)?", "laundry_service",
|
||||
"guest_house",
|
||||
// amenity=place_of_worship
|
||||
"deanery", "subject:(wikidata|wikipedia|wikimedia_commons)", "church", "church:type",
|
||||
// schools
|
||||
"capacity:(pupils|teachers)", "grades", "population:pupils(:.*)?",
|
||||
"school:(FR|gender|trust|type|type_idn|group:type)", "primary",
|
||||
// clubs
|
||||
"animal(_breeding|_training)?", "billiards(:.*)?", "board_game", "sport_1", "sport:boating",
|
||||
"boat:type", "canoe(_rental|:service)?", "kayak(_rental|:service)?",
|
||||
"sailboat(_rental|:service)?", "horse_riding", "rugby", "boules", "callsign", "card_games",
|
||||
"car_service", "catastro:ref", "chess(:.*)?", "children", "climbing(:.*)?", "club(:.*)?",
|
||||
"communication(:amateur_radio.*)", "community_centre:for", "dffr:network", "dormitory",
|
||||
"education_for:ages", "electrified", "esperanto", "events_venue", "family", "federation",
|
||||
"free_flying(:.*)?", "freemasonry(:.*)?", "free_refill", "gaelic_games(:.*)?", "membership",
|
||||
"military_service", "model_aerodrome(:.*)?", "mode_of_organisation(:.*)?", "snowmobile",
|
||||
"social_centre(:for)?", "source_dat", "tennis", "old_website", "organisation", "school_type",
|
||||
"scout(:type)?", "fraternity", "live_music", "lockable", "playground(:theme)?", "nudism",
|
||||
"music_genre", "length", "fire_station:type:FR", "cadet", "observatory:type", "tower:type",
|
||||
"zoo", "shooting", "commons", "groomer", "group_only", "hazard", "identity", "interaction",
|
||||
"logo", "maxheight", "provides", "regional", "scale", "site", "plots", "allotments",
|
||||
"local_food", "monitoring:pedestrian", "recording:automated", "yacht", "background_music",
|
||||
"url:spaceapi", "openfire", "fraternity(:.*)?",
|
||||
// misc specific attributes
|
||||
"clothes", "shoes", "tailor", "beauty", "tobacco", "carpenter", "furniture", "lottery",
|
||||
"sport", "dispensing", "tailor:.*", "gambling", "material", "raw_material", "stonemason",
|
||||
"studio", "scuba_diving(:.*)?", "polling_station", "collector", "books", "agrarian",
|
||||
"musical_instrument", "massage", "parts", "post_office(:.*)?", "religion", "denomination",
|
||||
"rental", ".*:rental", "tickets:.*", "public_transport", "goods_supply", "pet", "appliance",
|
||||
"artwork_type", "charity", "company", "crop", "dry_cleaning", "factory", "feature",
|
||||
"air_conditioning", "atm", "vending", "vending_machine", "recycling_type", "museum",
|
||||
"license_classes", "dance:.*", "isced:level", "school", "preschool", "university",
|
||||
"research_institution", "research", "member_of", "topic", "townhall:type", "parish", "police",
|
||||
"government", "thw:(lv|rb|ltg)", "office", "administration", "administrative", "association",
|
||||
"transport", "utility", "consulting", "Commercial", "commercial", "private", "taxi",
|
||||
"admin_level", "official_status", "target", "liaison", "diplomatic(:.*)?", "embassy",
|
||||
"consulate", "aeroway", "department", "faculty", "aerospace:product", "boundary", "population",
|
||||
"diocese", "depot", "cargo", "function", "game", "party", "political_party.*",
|
||||
"telecom(munication)?", "service_times", "kitchen:facilities", "it:(type|sales)",
|
||||
"cannabis:cbd", "bath:type", "bath:(open_air|sand_bath)", "animal_boarding", "animal_shelter",
|
||||
"mattress", "screen", "monitoring:weather", "public", "theatre", "culture", "library",
|
||||
"cooperative(:.*)?", "winery", "curtain", "lawyer(:.*)?", "local_authority(:.*)?", "equipment",
|
||||
"hackerspace",
|
||||
"camp_site", "camping", "bbq", "static_caravans", "emergency(:.*)?", "evacuation_cent(er|re)",
|
||||
"education", "engineering", "forestry", "foundation", "lawyer", "logistics", "military",
|
||||
"community_centre", "bank", "operational", "users_(PLWD|boy|elderly|female|girl|men)",
|
||||
"Comments?", "comments?", "entrance:(width|step_count|kerb:height)", "fenced", "motor_vehicle",
|
||||
"shelter",
|
||||
};
|
||||
@@ -668,7 +668,7 @@ void Editor::UploadChanges(string const & oauthToken, ChangesetTags tags, Finish
|
||||
{}
|
||||
|
||||
// Add tags to XMLFeature
|
||||
UpdateXMLFeatureTags(feature, journal);
|
||||
UpdateXMLFeatureTags(feature, journal, changeset);
|
||||
|
||||
// Upload XMLFeature to OSM
|
||||
LOG(LDEBUG, ("CREATE Feature (newEditor)", feature));
|
||||
@@ -686,7 +686,7 @@ void Editor::UploadChanges(string const & oauthToken, ChangesetTags tags, Finish
|
||||
XMLFeature feature = GetMatchingFeatureFromOSM(changeset, fti.m_object);
|
||||
|
||||
// Update tags of XMLFeature
|
||||
UpdateXMLFeatureTags(feature, journal);
|
||||
UpdateXMLFeatureTags(feature, journal, changeset);
|
||||
|
||||
// Upload XMLFeature to OSM
|
||||
LOG(LDEBUG, ("MODIFIED Feature (newEditor)", feature));
|
||||
@@ -1321,7 +1321,8 @@ bool Editor::IsFeatureUploadedImpl(FeaturesContainer const & features, MwmId con
|
||||
return info && info->m_uploadStatus == kUploaded;
|
||||
}
|
||||
|
||||
void Editor::UpdateXMLFeatureTags(editor::XMLFeature & feature, std::list<JournalEntry> const & journal)
|
||||
void Editor::UpdateXMLFeatureTags(editor::XMLFeature & feature, std::list<JournalEntry> const & journal,
|
||||
ChangesetWrapper & changeset)
|
||||
{
|
||||
for (JournalEntry const & entry : journal)
|
||||
{
|
||||
@@ -1335,6 +1336,13 @@ void Editor::UpdateXMLFeatureTags(editor::XMLFeature & feature, std::list<Journa
|
||||
}
|
||||
case JournalEntryType::ObjectCreated: break;
|
||||
case JournalEntryType::LegacyObject: ASSERT_FAIL(("Legacy Objects can not be edited with the new editor")); break;
|
||||
case JournalEntryType::BusinessReplacement:
|
||||
{
|
||||
BusinessReplacementData const & businessReplacementData = std::get<BusinessReplacementData>(entry.data);
|
||||
feature.OSMBusinessReplacement(businessReplacementData.old_type, businessReplacementData.new_type);
|
||||
changeset.AddChangesetTag("info:place_marked_as_disused", "yes");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "editor/changeset_wrapper.hpp"
|
||||
#include "editor/config_loader.hpp"
|
||||
#include "editor/editor_config.hpp"
|
||||
#include "editor/editor_notes.hpp"
|
||||
@@ -241,7 +242,8 @@ private:
|
||||
|
||||
static bool IsFeatureUploadedImpl(FeaturesContainer const & features, MwmId const & mwmId, uint32_t index);
|
||||
|
||||
void UpdateXMLFeatureTags(editor::XMLFeature & feature, std::list<JournalEntry> const & journal);
|
||||
static void UpdateXMLFeatureTags(editor::XMLFeature & feature, std::list<JournalEntry> const & journal,
|
||||
ChangesetWrapper & changeset);
|
||||
|
||||
/// Deleted, edited and created features.
|
||||
base::AtomicSharedPtr<FeaturesContainer> m_features;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "editor/xml_feature.hpp"
|
||||
#include "editor/keys_to_remove.hpp"
|
||||
|
||||
#include "indexer/classificator.hpp"
|
||||
#include "indexer/editable_map_object.hpp"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <boost/regex.hpp>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
@@ -502,6 +504,29 @@ osm::EditJournal XMLFeature::GetEditJournal() const
|
||||
entry.data = legacyObjData;
|
||||
break;
|
||||
}
|
||||
case osm::JournalEntryType::BusinessReplacement:
|
||||
{
|
||||
osm::BusinessReplacementData businessReplacementData;
|
||||
|
||||
// Old Feature Type
|
||||
std::string old_strType = getAttribute(xmlData, "old_type");
|
||||
if (old_strType.empty())
|
||||
MYTHROW(editor::InvalidJournalEntry, ("Old Feature type is empty"));
|
||||
businessReplacementData.old_type = classif().GetTypeByReadableObjectName(old_strType);
|
||||
if (businessReplacementData.old_type == IndexAndTypeMapping::INVALID_TYPE)
|
||||
MYTHROW(editor::InvalidJournalEntry, ("Invalid old Feature Type:", old_strType));
|
||||
|
||||
// New Feature Type
|
||||
std::string new_strType = getAttribute(xmlData, "new_type");
|
||||
if (new_strType.empty())
|
||||
MYTHROW(editor::InvalidJournalEntry, ("New Feature type is empty"));
|
||||
businessReplacementData.new_type = classif().GetTypeByReadableObjectName(new_strType);
|
||||
if (businessReplacementData.new_type == IndexAndTypeMapping::INVALID_TYPE)
|
||||
MYTHROW(editor::InvalidJournalEntry, ("Invalid new Feature Type:", new_strType));
|
||||
|
||||
entry.data = businessReplacementData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isHistory)
|
||||
journal.AddJournalHistoryEntry(entry);
|
||||
@@ -572,6 +597,14 @@ void XMLFeature::SetEditJournal(osm::EditJournal const & journal)
|
||||
xmlData.append_attribute("version") = legacyObjData.version.data();
|
||||
break;
|
||||
}
|
||||
case osm::JournalEntryType::BusinessReplacement:
|
||||
{
|
||||
osm::BusinessReplacementData const & businessReplacementData =
|
||||
std::get<osm::BusinessReplacementData>(entry.data);
|
||||
xmlData.append_attribute("old_type") = classif().GetReadableObjectName(businessReplacementData.old_type).data();
|
||||
xmlData.append_attribute("new_type") = classif().GetReadableObjectName(businessReplacementData.new_type).data();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -675,6 +708,52 @@ void XMLFeature::UpdateOSMTag(std::string_view key, std::string_view value)
|
||||
}
|
||||
}
|
||||
|
||||
void XMLFeature::OSMBusinessReplacement(uint32_t old_type, uint32_t new_type)
|
||||
{
|
||||
std::string name = GetTagValue("name");
|
||||
|
||||
// Remove OSM tags using the list from keys_to_remove.hpp
|
||||
static boost::regex const regex([]
|
||||
{
|
||||
std::string regexPattern;
|
||||
|
||||
for (auto const & key : kKeysToRemove)
|
||||
{
|
||||
if (!regexPattern.empty())
|
||||
regexPattern.append("|");
|
||||
regexPattern.append(key);
|
||||
}
|
||||
return regexPattern;
|
||||
}());
|
||||
|
||||
ForEachTag([this](std::string_view key, std::string_view /*value*/)
|
||||
{
|
||||
if (boost::regex_match(key.begin(), key.end(), regex))
|
||||
RemoveTag(key);
|
||||
});
|
||||
|
||||
if (classif().GetReadableObjectName(new_type) == "disusedbusiness")
|
||||
{
|
||||
// Mark as 'disused'
|
||||
string const strOldType = classif().GetReadableObjectName(old_type);
|
||||
strings::SimpleTokenizer iter(strOldType, "-");
|
||||
string_view const key = *iter;
|
||||
if (++iter)
|
||||
SetTagValue("disused:" + std::string(key), *iter);
|
||||
else
|
||||
SetTagValue("disused:" + std::string(key), "yes");
|
||||
|
||||
if (!name.empty())
|
||||
SetTagValue("old_name", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add new category tag
|
||||
ASSERT_FAIL("Only marking places as 'disused' is implemented yet. Wrong new_type: " +
|
||||
classif().GetReadableObjectName(new_type));
|
||||
}
|
||||
}
|
||||
|
||||
string XMLFeature::GetAttribute(string const & key) const
|
||||
{
|
||||
return GetRootNode().attribute(key.data()).value();
|
||||
|
||||
@@ -187,6 +187,8 @@ public:
|
||||
|
||||
/// Wrapper for SetTagValue and RemoveTag, avoids duplication for similar alternative osm tags
|
||||
void UpdateOSMTag(std::string_view key, std::string_view value);
|
||||
/// Replace an old business with a new business
|
||||
void OSMBusinessReplacement(uint32_t old_type, uint32_t new_type);
|
||||
|
||||
std::string GetAttribute(std::string const & key) const;
|
||||
void SetAttribute(std::string const & key, std::string const & value);
|
||||
|
||||
Reference in New Issue
Block a user