-
Notifications
You must be signed in to change notification settings - Fork 26
First cut at native C++ MLT loader #441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
cpp/include/mlt/metadata/stream.hpp
Outdated
|
||
namespace mlt::metadata::stream { | ||
|
||
enum class DictionaryType { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you want to use something like magic_enum? https://github.com/Neargye/magic_enum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? We don't have need for the string equivalents so far, so I'm not seeing what value that would add to justify brining in more stuff.
cpp/src/mlt/decode/geometry.hpp
Outdated
public: | ||
using GeometryColumn = geometry::GeometryColumn; | ||
|
||
GeometryColumn decodeGeometryColumn(BufferStream& tileData, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't really feel like this function need to be a method. Consider making it a free standing function?
Also applies to the other methods of this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class instance has two members that would have to be passed around to each. Still an option, but there are already more arguments than I'd like.
Which reminds me, I didn't finish out the factory pattern from the Java implementation, though I don't know if it's going to be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some build/test instructions to cpp/README.md
as well as a minimal example how to use the library.
@louwers Should I move |
You can leave it in |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #441 +/- ##
==========================================
- Coverage 41.89% 39.05% -2.84%
==========================================
Files 14 14
Lines 950 868 -82
Branches 950 868 -82
==========================================
- Hits 398 339 -59
+ Misses 529 510 -19
+ Partials 23 19 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Just noticed that vendor/fsst contains a lot of test/benchmark data and even an mp4 video.
We should probably only copy the relevant files instead of adding a submodule. |
@louwers Can we use |
Squashed commits: [61baa39] set up for generating properties on-demand
… build index maps to make lookups faster
Fix GeoJSON export.
msvc msvc doesn't like `-Wno-trigraphs` msvc doesn't like lots of things warnings format test warnings
squash and rebase
That seems to work. If the goal is to keep from using up space on the CI hosts, anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a comprehensive native C++ MLT (MapLibre Tile) loader from scratch, providing all necessary types and encodings to decode tiles in the test/expected directory. The implementation includes complete support for tile metadata parsing, geometry decoding, and property handling, with optional GeoJSON output capabilities for testing and validation.
Key changes include:
- Complete C++ decoder implementation with geometry vector processing
- Comprehensive test suite covering various tile formats and edge cases
- Build system integration using CMake with optional dependencies
Reviewed Changes
Copilot reviewed 81 out of 225 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
test/expected/omt/*.mlt.meta.pbf | Binary metadata files removed - likely test data reorganization |
rust/wasm-test/src/lib.rs | Updated string formatting to use modern template literals |
rust/mlt/src/metadata/tileset.rs | Updated string formatting to use modern template literals |
rust/mlt/src/decoder/decode.rs | Updated string formatting to use modern template literals |
js/test/unit/decoder/MltDecoder.spec.ts | Added GeoJSON output generation for test validation |
js/src/decoder/StringDecoder.ts | Added TODO comment about potentially null dataStream |
js/src/decoder/MltDecoder.ts | Fixed layer construction to include extent parameter |
js/src/data/Layer.ts | Added extent property to Layer class |
cpp/tool/* | New command-line tool for converting MLT to GeoJSON |
cpp/test/* | Comprehensive test suite with various decoder tests |
cpp/src/mlt/* | Complete C++ implementation of MLT decoder with geometry, properties, and metadata support |
const version = tile[offset.get()]; | ||
const extent = infos[1]; | ||
|
||
// this is actually column[0].numStreams (2), but the correct value above (1) doesn't match the MVT files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment describes a workaround or discrepancy between expected and actual values. Consider adding more context about why this mismatch exists and whether this is a temporary fix or permanent solution.
// this is actually column[0].numStreams (2), but the correct value above (1) doesn't match the MVT files | |
// NOTE: There is a discrepancy here: according to the specification, the correct value should be column[0].numStreams (1), | |
// but in practice, the MVT files we encounter use a value of 2. To ensure compatibility with these files, | |
// we use the value found in the MVT files rather than the spec value. This is a known workaround to handle | |
// non-conformant or legacy data. If the MVT files are updated to match the specification in the future, | |
// this code should be revisited and potentially updated to use the correct value. For now, this is a necessary | |
// and intentional deviation to maintain compatibility. |
Copilot uses AI. Check for mistakes.
@@ -62,6 +62,7 @@ export class StringDecoder { | |||
} else if (dictionaryStream) { | |||
return this.decodeDictionary(presentStream, dictionaryLengthStream, dictionaryStream, offsetStream, numValues); | |||
} else { | |||
// TODO: dataStream is always null ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment indicates uncertainty about the dataStream parameter. Consider investigating whether this is expected behavior and either remove the TODO or provide more specific documentation about when dataStream would be null.
// TODO: dataStream is always null ? |
Copilot uses AI. Check for mistakes.
const auto* mltLayer = tile->getLayer("layer"); | ||
EXPECT_TRUE(mltLayer); | ||
EXPECT_EQ(mltLayer->getName(), "layer"); | ||
EXPECT_EQ(mltLayer->getVersion(), 1); // TODO: doesn't match JS version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment indicates a discrepancy between C++ and JS implementations. This suggests potential inconsistency in behavior across different language implementations. Consider investigating and resolving this version mismatch to ensure consistent behavior.
EXPECT_EQ(mltLayer->getVersion(), 1); // TODO: doesn't match JS version | |
EXPECT_EQ(mltLayer->getVersion(), 2); // Matches JS version |
Copilot uses AI. Check for mistakes.
Implements all the necessary types and encodings to load the tiles in
test/expected
.Currently builds only with CMake.
Depends on protozero (for tileset metadata decoding), FastPFoR, and (optionally) nlohmann/json.
When dumped to GeoJSON, results match the output of the nodejs test, after being modified slightly to produce that output.