mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-09 22:04:43 +00:00
Revert "[editor] Automatically create/update check_date"
This reverts commit ed1e4fdd87.
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include "indexer/feature_meta.hpp"
|
||||
#include "indexer/feature_source.hpp"
|
||||
#include "indexer/mwm_set.hpp"
|
||||
#include "indexer/ftypes_matcher.hpp"
|
||||
|
||||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
@@ -24,8 +23,6 @@
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include <iomanip>
|
||||
|
||||
#include <pugixml.hpp>
|
||||
#include <utility>
|
||||
@@ -129,15 +126,6 @@ bool IsObsolete(editor::XMLFeature const & xml, FeatureID const & fid)
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string GetCurrentDate()
|
||||
{
|
||||
auto const t = std::time(nullptr);
|
||||
auto const tm = *std::localtime(&t);
|
||||
std::ostringstream oss;
|
||||
oss << std::put_time(&tm, "%Y-%m-%d");
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
Editor::Editor() : m_configLoader(m_config), m_notes(editor::Notes::MakeNotes())
|
||||
{
|
||||
SetDefaultStorage();
|
||||
@@ -423,59 +411,6 @@ Editor::SaveResult Editor::SaveEditedFeature(EditableMapObject const & emo)
|
||||
|
||||
// Reset upload status so already uploaded features can be uploaded again after modification.
|
||||
fti.m_uploadStatus = {};
|
||||
|
||||
// Auto-fill check_date and check_date:opening_hours
|
||||
if (ftypes::IsCheckDateChecker::Instance()(fti.m_object.GetTypes()))
|
||||
{
|
||||
std::string const currentDate = GetCurrentDate();
|
||||
|
||||
// Helper to update metadata AND manually log to journal (bypassing LogDiffInJournal crash)
|
||||
auto updateMetadataWithJournal = [&](feature::Metadata::EType type, std::string const & newVal) {
|
||||
std::string const key = feature::ToString(type);
|
||||
std::string const oldVal(fti.m_object.GetMetadata(type));
|
||||
|
||||
if (oldVal == newVal) return;
|
||||
|
||||
// Update object metadata
|
||||
fti.m_object.SetMetadata(type, newVal);
|
||||
|
||||
// Update journal manually
|
||||
const_cast<EditJournal&>(fti.m_object.GetJournal()).AddTagChange(key, oldVal, newVal);
|
||||
};
|
||||
|
||||
// Always update check_date
|
||||
updateMetadataWithJournal(feature::Metadata::FMD_CHECK_DATE, currentDate);
|
||||
|
||||
// Update check_date:opening_hours if needed
|
||||
std::string const newOH(fti.m_object.GetMetadata(feature::Metadata::FMD_OPEN_HOURS));
|
||||
if (!newOH.empty())
|
||||
{
|
||||
bool updateOHDate = false;
|
||||
if (IsCreatedFeature(fid))
|
||||
{
|
||||
updateOHDate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto const originalObjectPtr = GetOriginalMapObject(fid);
|
||||
if (originalObjectPtr)
|
||||
{
|
||||
std::string const oldOH(originalObjectPtr->GetMetadata(feature::Metadata::FMD_OPEN_HOURS));
|
||||
if (newOH != oldOH)
|
||||
updateOHDate = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
updateOHDate = true; // Fallback
|
||||
}
|
||||
}
|
||||
|
||||
if (updateOHDate)
|
||||
{
|
||||
updateMetadataWithJournal(feature::Metadata::FMD_CHECK_DATE_OPEN_HOURS, currentDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto editableFeatures = make_shared<FeaturesContainer>(*features);
|
||||
(*editableFeatures)[fid.m_mwmId][fid.m_index] = std::move(fti);
|
||||
|
||||
Reference in New Issue
Block a user