-
Notifications
You must be signed in to change notification settings - Fork 303
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
MapBox VectorTile: bug fixes using an official MapBox stream #2469
Open
ftoromanoff
wants to merge
19
commits into
iTowns:master
Choose a base branch
from
ftoromanoff:mapBoxVT
base: master
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.
+273
−110
Open
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
06804f1
feat(VectorTile): add support for relative url in style
ftoromanoff 5c62908
fix(VectorTile): fix {z}/{y}/{x}
ftoromanoff f903a1a
fix(MVTStyle): icon properties -> fix return of function when id incl…
ftoromanoff 328cc2c
feat(Source): add propertie 'warn' for avoiding multiple console.warn
ftoromanoff a96f21b
test(VectorTileSource): fix test
ftoromanoff d756acb
refactor(VectorTileParser): cleanup
ftoromanoff a881fac
fix(MVTLayers): add MVTLayer where MVTStyle.layer has 'ref' properties
ftoromanoff b77965b
fix(Style): take style.zoom into account for LabelLayer and Feature2T…
ftoromanoff 7f27ef8
fix(examples): fix linked with zoom properties well used
ftoromanoff c7a1c32
fix(MVTParser): supp use of layer.style.zoom in parser
ftoromanoff 6d568fa
fix(Style): Don't draw Polygon when fill.color is undefined
ftoromanoff 5f63ee2
fix(Style): Don't draw stroke when width is 0
ftoromanoff af2e0f1
fix(LabelLayer): gestion simplified of line and polygon Label
ftoromanoff 049dd6a
fix(MVTStyle): Doing recoloring only with sdf icons.
ftoromanoff efa1777
fix(Label): Multiple labels with same textContent
ftoromanoff 36bcd33
refactor(MVTParser): 1 feature per vtfeature
ftoromanoff 151e9af
fix(VectorTile): supp order in Style as it's only a Label properties …
ftoromanoff bb8f57d
example(MVT): add example with official MapBox style file
ftoromanoff 18b1d2c
fix(Style): dont draw icon when size is 0
ftoromanoff 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 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 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 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 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 |
---|---|---|
|
@@ -71,9 +71,10 @@ class VectorTilesSource extends TMSSource { | |
|
||
this.accessToken = source.accessToken; | ||
|
||
let styleUrl; | ||
if (source.style) { | ||
if (typeof source.style == 'string') { | ||
const styleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken); | ||
styleUrl = urlParser.normalizeStyleURL(source.style, this.accessToken); | ||
promise = Fetcher.json(styleUrl, this.networkOptions); | ||
} else { | ||
promise = Promise.resolve(source.style); | ||
|
@@ -84,8 +85,9 @@ class VectorTilesSource extends TMSSource { | |
|
||
this.whenReady = promise.then((style) => { | ||
this.jsonStyle = style; | ||
const baseurl = source.sprite || style.sprite; | ||
let baseurl = source.sprite || style.sprite; | ||
if (baseurl) { | ||
baseurl = new URL(baseurl, styleUrl).toString(); | ||
const spriteUrl = urlParser.normalizeSpriteURL(baseurl, '', '.json', this.accessToken); | ||
return Fetcher.json(spriteUrl, this.networkOptions).then((sprites) => { | ||
this.sprites = sprites; | ||
|
@@ -102,7 +104,7 @@ class VectorTilesSource extends TMSSource { | |
if (layer.type === 'background') { | ||
this.backgroundLayer = layer; | ||
} else if (ffilter(layer)) { | ||
const style = Style.setFromVectorTileLayer(layer, this.sprites, order, this.symbolToCircle); | ||
const style = Style.setFromVectorTileLayer(layer, this.sprites, order, this.symbolToCircle, this.warn); | ||
this.styles[layer.id] = style; | ||
|
||
if (!this.layers[layer['source-layer']]) { | ||
|
@@ -123,9 +125,11 @@ class VectorTilesSource extends TMSSource { | |
if (this.url == '.') { | ||
const TMSUrlList = Object.values(style.sources).map((sourceVT) => { | ||
if (sourceVT.url) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these default values are not needed anymore ? |
||
sourceVT.url = new URL(sourceVT.url, styleUrl).toString(); | ||
const urlSource = urlParser.normalizeSourceURL(sourceVT.url, this.accessToken); | ||
return Fetcher.json(urlSource, this.networkOptions).then((tileJSON) => { | ||
if (tileJSON.tiles[0]) { | ||
tileJSON.tiles[0] = decodeURIComponent(new URL(tileJSON.tiles[0], urlSource).toString()); | ||
return toTMSUrl(tileJSON.tiles[0]); | ||
} | ||
}); | ||
|
@@ -136,7 +140,7 @@ class VectorTilesSource extends TMSSource { | |
}); | ||
return Promise.all(TMSUrlList); | ||
} | ||
return (Promise.resolve([this.url])); | ||
return (Promise.resolve([toTMSUrl(this.url)])); | ||
}).then((TMSUrlList) => { | ||
this.urls = Array.from(new Set(TMSUrlList)); | ||
}); | ||
|
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.
Aggregating logs is a good idea and needed in itowns. I think we should not store aggregated logs in objects and pass them around as function parameters. An alternative implementation would be to implement a LogAggregator that stores logs, aggregates them and can log info, warn and errors. A global instance could be used by all itowns components then. If we do so, we need to be careful with memory usage and empty the log cache frequently. And if we don't want to implement it ourselves, I'm sure there are libraries available. However I think that's out of scope of this PR, so I'd be for removing this log aggregation for now and implement it differently later. @Desplandis what is your opinion on this?
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.
Yeah, we could have some kind of heap with a max size to aggregate those warnings. I think there should be some kind of library to do it. However, I agree that this is out of scope of this PR.