KMB import fix #6006
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#6006
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "kmb-import-fix"
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?
The main problem with updated KMB format that version ID is not changed. KMB file is generated with version
V8
while internal changes are incompatible withV8
. Introduced new versionV8MM
for new KMB files format.KBM v8MM files don't have compilations. I removed compilations from the code. Tracks data has extra 3 bytes with unknown purpose. Also timestamp is now stored as milliseconds instead of seconds.
Updated unit tests.
Changes in
kml_to_kmb
toolkml_to_kmb
now accepts optional version parameter. It can generate not only files in V9 (latest) format but with V8.This was needed to generate test data in V8 format.
Fixes #5718
Is it possible to create a subtype for version81 and incorporate all fixes there?
So the HasCompilationsSection() should be enough, no?
Why comment here? Let's keep as-is.
So the HasCompilationsSection() should be enough, no?
Why comment here? Let's keep as-is.
Not only compilations section is disabled but also Bookmark and Category fields list should be updated. If I enable back "compilations" field parsing would fail.
LGTM with minor comments.
Is it really needed?
@ -0,0 +18,4 @@
explicit SerializerKmlV8(FileData & data) : SerializerKml(data) {};
template <typename Sink>
void Serialize(Sink & sink)
This method is cop-n-paste of
SerializerKml::Serialize(sink)
.The only differences are that it writes version 0x08 as first byte and it calls
SerializerKmlV8::SerializeBookmarks()
instead ofSerializerKml::SerializeBookmarks()
.Is there a better way? Should I introduce virtual methods
SerializerKml::SerializeVersion()
andSerializerKml::SerializeBookmarks()
?Fixed
Compiler shows warning:
all paths through this function will call itself
because typesTimestamp
andTimestampMillis
could be converted to one another. Is there any way to force useDebugPrint(Timestamp)
function frombase/internal/message.hpp
?Fixed
Fixed.
We need default constructor to initialize
std::vector<BookmarkDataV8> m_bookmarksData;
field in FileDataV8@ -0,0 +18,4 @@
explicit SerializerKmlV8(FileData & data) : SerializerKml(data) {};
template <typename Sink>
void Serialize(Sink & sink)
That's ok.
Appeared that V8MM format doesn't have
m_type
field. Because of that we hadm_visibility = false
. Using defaultm_type
for all V8MM.@ -1873,3 +1874,3 @@
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Gpx);
When you import KMB file it is converted to KML first in
GetKMLPath(...)
function and then KML is imported.In such case
filePath = "some_file.kmb
andfileSavePath = "some_file.kmb2.kml"
. Because we parsefileSavePath
we should get extension correctly here.In my cases there was a problem with
fileSavePath
parsing. And temp files were not cleaned up.@ -1873,3 +1874,3 @@
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Gpx);
It would be even better to see these comments in the code instead of the PR ;-)
Let's mention it in the code.
Both if and else branches have this line. Put it before the if.
What kind of problem did you have with parsing? Should it be fixed/handled properly?
nit: remove unnecessary newline
nit: remove unnecessary newline
namespace kml::binary
nit: Have dots at the end of sentences.
@ -1873,3 +1874,3 @@
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Gpx);
Reviewed this part of code because
ext
is always"kml"
.If input KML/KMZ file has invalid format we get
kmlData == nullptr
.Removed this field completly. Added comment.
Fixed.
Fixed.
Fixed
Fixed.
@ -1873,3 +1874,3 @@
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Gpx);
Did you add a comment in the code? Btw, why is it always kml there?
@ -1873,2 +1873,3 @@
if (ext == kKmlExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
Are you 100% sure that this code should be removed? Did you test it with other file types? Is it guaranteed that this code is called only for kml/kmz files?
@ -1873,2 +1873,3 @@
if (ext == kKmlExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
I tested with KML, KMZ, KMB, and GPX files.
Found an issue with GPX and fixed. Current implementation imports all formats successfully.
One questionable part: KMB is first converted to temp KML and then KML is converted to final KML. Maybe we can skip temporary step.
Nice to have: unit tests 🙂
@ -1873,2 +1873,3 @@
if (ext == kKmlExtension)
kmlData = LoadKmlFile(fileSavePath, KmlFileType::Text);
else if (ext == ".gpx")
else if (ext == kGpxExtension)
Converting kml to kml doesn't look necessary ) Is it easy to fix?
@ -358,6 +376,7 @@ std::string GetKMLPath(std::string const & filePath)
}
else if (fileExt == kKmzExtension)
{
// Extract KML file from KMZ archive and save to temp KML with unique name.
Why is this copying necessary?
collection
has typestd::vector<std::pair<std::string, std::unique_ptr<kml::FileData>>>
I converted
std::optional<kml::FileData>
tostd::unique_ptr<kml::FileData>
here.Should we change
collection
type?Good question, likely yes, if the collection is not moved often. Moving unique_ptr is cheaper than moving FileData.
Otherwise:
Your suggested code doesn't work. Compilation error:
error: no matching constructor for initialization of 'kml::FileData'
Replaced with:
std::make_unique<kml::FileData>(std::move(kmlData.value()))
So you what was the reason to modify existing code with optional?
And then writing "nice":
@ -19,0 +20,4 @@
public:
TimestampMillis() = default;
explicit TimestampMillis(Timestamp const & ts) : Timestamp{ts} {}
TimestampMillis & operator=(Timestamp const & ts)
I suspect it is not needed.
@ -1525,1 +1525,4 @@
};
// kBinKmlV8 contains the same bookmarks and tracks as kBinKmlV7
std::vector<uint8_t> const kBinKmlV8 = {
Is it possible to push an ordinary file into the repository instead of this?
Neither external variable nor !kmlData checks are necessary.
@strump let's make a follow-up issue with KML tasks/improvements mentioned in this PR.