Editor refactoring #9242
Labels
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
3 participants
Due date
No due date set.
Dependencies
No dependencies set.
Reference: organicmaps/organicmaps-tmp#9242
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "editor_refactoring"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
fixes #9129, fixes #8102, fixes #2298, fixes #6260, fixes #6292, fixes #9126, fixes #6939, fixes #9508, fixes #9311
This PR supersedes #9138 and adds a Journal to explicitly store which changes were submitted by the user. See #9129 for why his information is needed when uploading to OSM.
Approach
Edits are logged in the Journal. A log contains info like e.g.
Tag "website" changed from "www.organicmaps.app" to "organicmaps.app"
orObjectCreated, Type amenity-bench, Location ...
. When uploading, only the Journal entries are used do update the OSM object. After a successful upload, the Journal is cleared.Saving and restoring the Journal after an app restart is implemented now.
For the transition phase to the new editing logic the old uploading code is still functional. The old code is used when the object was modified in a previous OM version.
Todo
Bugs fixed
Testing
Tested with the OSM dev API, but only on Android.
Transition
The PR only affects new edits. Old edits from previous OM versions that were not uploaded yet use the old uploading code.
New features I keep in mind to not block anything
Follow up issues (Issues not addressed in this PR)
Will finish review later.
Please:
@ -151,2 +151,3 @@
{
g_editableMapObject.SetInternet(hasWifi ? feature::Internet::Wlan : feature::Internet::Unknown);
if (hasWifi != (g_editableMapObject.GetInternet() == feature::Internet::Wlan))
g_editableMapObject.SetInternet(hasWifi ? feature::Internet::Wlan : feature::Internet::Unknown);
Incapsulate this logic in EditableMapObject::SetInternet ?
name.starts_with("name:")
Put the ASSERT here? Is it a possible case?
Is this block the same as some lines above? ("Add tags to XMLFeature"). Take out a function?
@ -717,0 +808,4 @@
XMLFeature const osmFeatureCopy = osmFeature;
osmFeature.ApplyPatch(feature);
// Check to avoid uploading duplicates into OSM.
if (osmFeature == osmFeatureCopy)
Should support this legacy in case when we have the old edits.xml after updating the app?
@ -813,3 +944,3 @@
if (status == FeatureStatus::Created)
{
editor::FromXML(xml, fti.m_object);
if (loadFromJournal)
No need braces here.
std::move(journal)
Call time(nullptr) once here?
@ -412,0 +495,4 @@
entry.data = legacyObjData;
break;
}
}
What will happen if xml file is broken, say any XXX.value() does not exist? Should we have any generic error processing here? Like catch an exception and continue/skip the whole entry?
@ -412,0 +574,4 @@
auto xmlJournalHistory = GetRootNode().append_child("journalHistory");
insertEditJournalList(xmlJournalHistory, journal.GetJournalHistory());
value.empty()
GetReadableObjectName(type)
I suspect that we have more 3-arity types besides amenity-recycling-xxx
Add ASSERT/CHECK(!(++iter), ("Add an exception:", strType))
Braces are not needed here
Here is how I'd prefer to see this code:
JournalEntry entry
std::move(entry)
JournalEntry entry
std::move(entry)
@ -0,0 +35,4 @@
void EditJournal::MarkAsCreated(uint32_t type, feature::GeomType geomType, m2::PointD mercator)
{
ASSERT(m_journal.empty(), ("Only empty journals can be marked as created"));
LOG(LDEBUG, ("Object of type ", classif().GetReadableObjectName(type), " created"));
@ -0,0 +109,4 @@
return "ObjectCreated";
case osm::JournalEntryType::LegacyObject:
return "LegacyObject";
}
UNREACHABLE();
Please, use "m_" notation at least here.
EditJournal && editJournal
std::move(editJournal)
No need braces here
Ok, so check
langCode != StringUtf8Multilang:: UnsupportedLanguageCode
@ -0,0 +109,4 @@
return "ObjectCreated";
case osm::JournalEntryType::LegacyObject:
return "LegacyObject";
}
Is UNREACHABLE() necessary? All three JournalEntryType enum values are handled here, so the compiler can figure out by itself that the end is unreachable.
@ -717,0 +808,4 @@
XMLFeature const osmFeatureCopy = osmFeature;
osmFeature.ApplyPatch(feature);
// Check to avoid uploading duplicates into OSM.
if (osmFeature == osmFeatureCopy)
Yes, the old editor upload code is used for all POIs that were edited before the EditJournal was introduced because these POIs don't have a full journal history of the changes.
My plan is to remove the old editor code about three months after this PR is merged.
@ -151,2 +151,3 @@
{
g_editableMapObject.SetInternet(hasWifi ? feature::Internet::Wlan : feature::Internet::Unknown);
if (hasWifi != (g_editableMapObject.GetInternet() == feature::Internet::Wlan))
g_editableMapObject.SetInternet(hasWifi ? feature::Internet::Wlan : feature::Internet::Unknown);
That's not a good idea, because iOS uses all
Internet
values and not just Wifitrue
/false
.(This is a fix for the Android only bug #9508)
@ -412,0 +495,4 @@
entry.data = legacyObjData;
break;
}
}
pugixml shouldn't throw exceptions. It's very fault tolerant, so e.g. calling
.attribute("key").value()
on an empty xml node doesn't crash, but just returns "".The current
GetEditJournal()
assumes that the xml is correct. Should I add checks and use MYTHROW in case read in values are invalid like it is done in other parts of thexml_feature
class?Added ASSERT_FAIL for that case
Moved it to a new function
👍 Added an assertion
@ -412,0 +495,4 @@
entry.data = legacyObjData;
break;
}
}
I added checks to make sure only correct values are read from the xml file. (exceptions are thrown when the xml contains an invalid value)
@ -151,2 +151,3 @@
{
g_editableMapObject.SetInternet(hasWifi ? feature::Internet::Wlan : feature::Internet::Unknown);
if (hasWifi != (g_editableMapObject.GetInternet() == feature::Internet::Wlan))
g_editableMapObject.SetInternet(hasWifi ? feature::Internet::Wlan : feature::Internet::Unknown);
ok
Please, all braces { here and below from the new line.
std::move(key)
std::move(osmLangName)
std::string_view value = ...
std::string_view old_value = ...
m_journal.AddTagChange(ToString(type), std::string(old_value), std::string(value));
(std::vector<std::string> & cuisinesPtr, std::string_view s)
Thanks! That makes the code way cleaner than with the
goto
Take out into a separate function to avoid copy-paste-check ?
It's not really worth it because I want to remove the decision logic for old/new editor in a few months anyway. This code is only needed for the transition period.
I did permanent testing of this PR for 2 months. Merge, and everyone interested can check it in Beta.