MCPcopy Create free account
hub / github.com/comaps/comaps / GetEditableProperties

Method GetEditableProperties

libs/editor/osm_editor.cpp:510–543  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510EditableProperties Editor::GetEditableProperties(FeatureType & feature) const
511{
512 auto const features = m_features.Get();
513
514 auto const & fid = feature.GetID();
515 auto const featureStatus = GetFeatureStatusImpl(*features, fid.m_mwmId, fid.m_index);
516
517 ASSERT(featureStatus != FeatureStatus::Obsolete, ("Edit mode should not be available on obsolete features"));
518
519 // TODO(mgsergio): Check if feature is in the area where editing is disabled in the config.
520 auto editableProperties = GetEditablePropertiesForTypes(feature::TypesHolder(feature));
521
522 // Disable opening hours editing if opening hours cannot be parsed.
523 if (featureStatus != FeatureStatus::Created)
524 {
525 auto const originalObjectPtr = GetOriginalMapObject(fid);
526 if (!originalObjectPtr)
527 {
528 LOG(LERROR, ("A feature with id", fid, "cannot be loaded."));
529 return {};
530 }
531
532 /// @todo Avoid temporary string when OpeningHours (boost::spirit) will allow string_view.
533 string const featureOpeningHours(originalObjectPtr->GetOpeningHours());
534 /// @note Empty string is parsed as a valid opening hours rule.
535 if (!osmoh::OpeningHours(featureOpeningHours).IsValid())
536 {
537 auto & meta = editableProperties.m_metadata;
538 meta.erase(remove(begin(meta), end(meta), feature::Metadata::FMD_OPEN_HOURS), end(meta));
539 }
540 }
541
542 return editableProperties;
543}
544
545EditableProperties Editor::GetEditablePropertiesForTypes(feature::TypesHolder const & types) const
546{

Callers 7

EditorDialogMethod · 0.45
OnSaveMethod · 0.45
FillEditableMapObjectFunction · 0.45
SaveTransactionTestMethod · 0.45
EditFeatureFunction · 0.45
GetEditableMapObjectMethod · 0.45

Calls 10

ASSERTFunction · 0.85
GetOpeningHoursMethod · 0.80
OpeningHoursClass · 0.70
TypesHolderClass · 0.50
beginFunction · 0.50
endFunction · 0.50
GetMethod · 0.45
GetIDMethod · 0.45
IsValidMethod · 0.45
eraseMethod · 0.45

Tested by 2

FillEditableMapObjectFunction · 0.36
SaveTransactionTestMethod · 0.36