-
-
Notifications
You must be signed in to change notification settings - Fork 918
Add support for MLT #6570
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
Open
HarelM
wants to merge
21
commits into
main
Choose a base branch
from
mlt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add support for MLT #6570
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
ea12721
Initial mlt support hack
HarelM cbce2c3
Merge branch 'main' into mlt
HarelM 3a809fc
Update min test
HarelM 93b93b1
Update build test
HarelM 3586758
Use released package instead of mocks
HarelM 9145092
Update mlt package to latest version
HarelM ed703c6
Fix lint
HarelM 3b33d0b
Initial implementation
HarelM b8bb41b
Update package version
HarelM d38de93
Fix lint
HarelM e2ff715
Update package and relevant code.
HarelM 1a1acf3
Merge branch 'main' into mlt
HarelM 4b8a16b
Update mltpackage to latest
HarelM d7b173e
Update mlt to latest version
HarelM 2914e5e
Add basic render tests for mlt (#6631)
Salkin975 7c61b71
treat mlt as binary data
HarelM 69750e2
Merge branch 'main' into mlt
HarelM ac4ee92
Update mlt tiles
HarelM 1af05f4
Update changelog
HarelM b77dcec
Update build size, this will probably change in next version of mlt
HarelM 7e29a69
Move mlt vector worker to parent directory.
HarelM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import Point from '@mapbox/point-geometry'; | ||
| import {type VectorTile, type VectorTileFeature, type VectorTileLayer} from '@mapbox/vector-tile'; | ||
| import {type FeatureTable, decodeTile, type Feature as MLTFeature, GEOMETRY_TYPE} from '@maplibre/mlt'; | ||
|
|
||
| type PublicPart<T> = {[K in keyof T]: T[K]}; | ||
|
|
||
| class MLTVectorTileFeature implements PublicPart<VectorTileFeature> { | ||
| _featureData: MLTFeature; | ||
| properties: {[_: string]: any}; | ||
| type: VectorTileFeature['type']; | ||
| extent: VectorTileFeature['extent']; | ||
| id: VectorTileFeature['id']; | ||
|
|
||
| constructor(feature: MLTFeature, extent: number) { | ||
| this._featureData = feature; | ||
| this.properties = this._featureData.properties || {}; | ||
| switch (this._featureData.geometry?.type) { | ||
| case GEOMETRY_TYPE.POINT: | ||
| case GEOMETRY_TYPE.MULTIPOINT: | ||
| this.type = 1; | ||
| break; | ||
| case GEOMETRY_TYPE.LINESTRING: | ||
| case GEOMETRY_TYPE.MULTILINESTRING: | ||
| this.type = 2; | ||
| break; | ||
| case GEOMETRY_TYPE.POLYGON: | ||
| case GEOMETRY_TYPE.MULTIPOLYGON: | ||
| this.type = 3; | ||
| break; | ||
| default: | ||
| this.type = 0; | ||
| }; | ||
| this.extent = extent; | ||
| this.id = Number(this._featureData.id); | ||
| } | ||
|
|
||
| toGeoJSON(_x: number, _y: number, _z: number): GeoJSON.Feature { | ||
| throw new Error('MLTVectorTileFeature.toGeoJSON not implemented'); | ||
| } | ||
|
|
||
| loadGeometry(): Point[][] { | ||
| const points: Point[][] = []; | ||
| for (const ring of this._featureData.geometry.coordinates) { | ||
| const pointRing: Point[] = []; | ||
| for (const coord of ring) { | ||
| pointRing.push(new Point(coord.x, coord.y)); | ||
| } | ||
| points.push(pointRing); | ||
| } | ||
| return points; | ||
| } | ||
| bbox(): number[] { | ||
| return [0, 0, 0, 0]; | ||
| } | ||
| } | ||
|
|
||
| class MLTVectorTileLayer implements PublicPart<VectorTileLayer> { | ||
| featureTable: FeatureTable; | ||
| name: string; | ||
| length: number; | ||
| version: number; | ||
| extent: number; | ||
| features: MLTFeature[] = []; | ||
|
|
||
| constructor(featureTable: FeatureTable) { | ||
| this.featureTable = featureTable; | ||
| this.name = featureTable.name; | ||
| this.extent = featureTable.extent; | ||
| this.version = 2; | ||
| this.features = featureTable.getFeatures(); | ||
| this.length = this.features.length; | ||
| } | ||
|
|
||
| feature(i: number): VectorTileFeature { | ||
| return new MLTVectorTileFeature(this.features[i], this.extent) as unknown as VectorTileFeature; | ||
| } | ||
| } | ||
|
|
||
| export class MLTVectorTile implements VectorTile { | ||
| layers: Record<string, VectorTileLayer> = {}; | ||
|
|
||
| constructor(buffer: ArrayBuffer) { | ||
| const features = decodeTile(new Uint8Array(buffer)); | ||
| this.layers = features.reduce((acc, f) => ({...acc, [f.name]: new MLTVectorTileLayer(f)}), {}); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+13.2 KB
test/integration/render/tests/mlt/render-layers/render-building/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
test/integration/render/tests/mlt/render-layers/render-building/style.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "version": 8, | ||
| "metadata": { | ||
| "test": { | ||
| "debug": true, | ||
| "height": 256 | ||
| } | ||
| }, | ||
| "center": [ | ||
| 11.525101, | ||
| 48.144716 | ||
| ], | ||
| "zoom": 14.92, | ||
| "sources": { | ||
| "openmaptiles": { | ||
| "type": "vector", | ||
| "encoding": "mlt", | ||
| "tiles": ["local://tiles/mlt/{z}/{x}/{y}.mlt"] | ||
| } | ||
| }, | ||
| "sprite": "local://sprites/sprite", | ||
| "layers": [ | ||
| { | ||
| "id": "building", | ||
| "type": "fill", | ||
| "source": "openmaptiles", | ||
| "source-layer": "building", | ||
| "paint": { | ||
| "fill-color": "#c86432" | ||
| } | ||
| } | ||
| ] | ||
| } |
Binary file added
BIN
+5.35 KB
test/integration/render/tests/mlt/render-layers/render-housenr/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions
40
test/integration/render/tests/mlt/render-layers/render-housenr/style.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "version": 8, | ||
| "metadata": { | ||
| "test": { | ||
| "debug": true, | ||
| "height": 256 | ||
| } | ||
| }, | ||
| "center": [ | ||
| 11.529107, | ||
| 48.146443 | ||
| ], | ||
| "zoom": 17.81, | ||
| "sources": { | ||
| "openmaptiles": { | ||
| "type": "vector", | ||
| "encoding": "mlt", | ||
| "tiles": ["local://tiles/mlt/{z}/{x}/{y}.mlt"], | ||
| "maxzoom": 14 | ||
| } | ||
| }, | ||
| "glyphs": "local://glyphs/{fontstack}/{range}.pbf", | ||
| "sprite": "local://sprites/sprite", | ||
| "layers": [ | ||
| { | ||
| "id": "housenumber", | ||
| "type": "symbol", | ||
| "source": "openmaptiles", | ||
| "source-layer": "housenumber", | ||
| "layout": { | ||
| "text-field": "{housenumber}", | ||
| "text-font": ["Noto Sans Regular"], | ||
| "text-size": 30 | ||
| }, | ||
| "paint": { | ||
| "text-color": "#ffffff" | ||
| } | ||
| } | ||
| ] | ||
| } |
Binary file added
BIN
+3.89 KB
test/integration/render/tests/mlt/render-layers/render-labels/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions
40
test/integration/render/tests/mlt/render-layers/render-labels/style.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| { | ||
| "version": 8, | ||
| "metadata": { | ||
| "test": { | ||
| "debug": true, | ||
| "height": 256 | ||
| } | ||
| }, | ||
| "center": [ | ||
| 15.311276, | ||
| 50.821840 | ||
| ], | ||
| "zoom": 5.7, | ||
| "sources": { | ||
| "openmaptiles": { | ||
| "type": "vector", | ||
| "encoding": "mlt", | ||
| "tiles": ["local://tiles/mlt/{z}/{x}/{y}.mlt"], | ||
| "maxzoom": 14 | ||
| } | ||
| }, | ||
| "glyphs": "local://glyphs/{fontstack}/{range}.pbf", | ||
| "sprite": "local://sprites/sprite", | ||
| "layers": [ | ||
| { | ||
| "id": "place_label_other", | ||
| "type": "symbol", | ||
| "source": "openmaptiles", | ||
| "source-layer": "place", | ||
| "layout": { | ||
| "text-field": "{name:latin}", | ||
| "text-font": ["Noto Sans Regular"], | ||
| "text-size": ["interpolate", ["linear"], ["zoom"], 3, 12, 8, 22] | ||
| }, | ||
| "paint": { | ||
| "text-color": "#ffffff" | ||
| } | ||
| } | ||
| ] | ||
| } |
Binary file added
BIN
+22.5 KB
test/integration/render/tests/mlt/render-layers/render-landcover/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions
34
test/integration/render/tests/mlt/render-layers/render-landcover/style.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "version": 8, | ||
| "metadata": { | ||
| "test": { | ||
| "debug": true, | ||
| "height": 256 | ||
| } | ||
| }, | ||
| "center": [ | ||
| 73, | ||
| 36 | ||
| ], | ||
| "zoom": 5.99, | ||
| "sources": { | ||
| "openmaptiles": { | ||
| "type": "vector", | ||
| "encoding": "mlt", | ||
| "tiles": ["local://tiles/mlt/{z}/{x}/{y}.mlt"], | ||
| "maxzoom": 14 | ||
| } | ||
| }, | ||
| "sprite": "local://sprites/sprite", | ||
| "layers": [ | ||
| { | ||
| "id": "landcover", | ||
| "type": "fill", | ||
| "source": "openmaptiles", | ||
| "source-layer": "landcover", | ||
| "paint": { | ||
| "fill-color": "#008000" | ||
| } | ||
| } | ||
| ] | ||
| } |
Binary file added
BIN
+23.2 KB
test/integration/render/tests/mlt/render-layers/render-roads/expected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 need to be a "production" release before this branch can be merged.