-
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
base: master
Are you sure you want to change the base?
Conversation
d9300ac
to
5581f1e
Compare
5581f1e
to
9fcfdee
Compare
9fcfdee
to
f1bd8aa
Compare
f1bd8aa
to
bc8515d
Compare
bc8515d
to
18b1d2c
Compare
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.
Thanks for the debug and the fixes :)
@@ -0,0 +1,98 @@ | |||
<html> | |||
<head> | |||
<title>Itowns - Globe</title> |
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.
Can you update the title please?
const source = new itowns.VectorTilesSource({ | ||
style: "mapbox://styles/mapbox/streets-v8", | ||
accessToken: | ||
"pk.eyJ1IjoiZ2VvdXJmbyIsImEiOiJjbHdyZWVrd2owOW1rMmlxdmx2Z3Fwb2JhIn0.sg5en26yZ6aSEg6CsfUByA", |
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.
is that your personal access token?
rel="stylesheet" | ||
type="text/css" | ||
href="https://www.itowns-project.org/itowns/examples/css/widgets.css" | ||
/> |
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.
we don't need widgets in this example
<script src="../dist/itowns.js"></script> | ||
<script src="../dist/debug.js"></script> | ||
<!-- Import iTowns Widgets plugin --> | ||
<script src="../dist/itowns_widgets.js"></script> |
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.
we don't need widgets in this example
@@ -108,6 +108,7 @@ class Source extends InformationsData { | |||
constructor(source) { | |||
super(source); | |||
this.isSource = true; | |||
this.warn = new Set(); | |||
|
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.
@@ -919,17 +958,16 @@ class Style { | |||
* @param {Boolean} canBeFilled - true if feature.type == FEATURE_TYPES.POLYGON. | |||
*/ | |||
applyToCanvasPolygon(txtrCtx, polygon, invCtxScale, canBeFilled) { | |||
const context = this.context; | |||
// draw line or edge of polygon | |||
if (this.stroke) { | |||
// TO DO add possibility of using a pattern (https://github.com/iTowns/itowns/issues/2210) |
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.
should we check for stroke properties too, like for fill ?
@@ -820,6 +826,8 @@ class Style { | |||
style.point.opacity = opacity; | |||
style.point.radius = readVectorProperty(layer.paint['circle-radius']); | |||
} else if (layer.type === 'symbol') { | |||
// if symbol we shouldn't draw stroke but defaut value is 1. | |||
style.stroke.width = 0.0; |
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.
no need for this comment I think, the code is clear enough
})) { | ||
label.horizonCullingPoint && GlobeLayer.horizonCulling(label.horizonCullingPoint) | ||
// Why do we might need this part ? | ||
// || // Check if content isn't present in visible labels |
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.
I think it was to avoid overlapping but I'm not sure we need it too so let's remove it completely in this case. We still have git if we need it later. @Desplandis WDYT?
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.
If we can't reproduce the overlapping and it seems to be the case here. I think we could totally remove this.
} else if (!collection.features.find(f => f.id === layer.id)) { | ||
feature = collection.newFeatureByReference(feature); | ||
feature.id = layer.id; | ||
feature.order = layer.order; |
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 seems like some kind of optimization, can you explain in more details why you remove it please?
@@ -464,8 +465,6 @@ function _addIcon(icon, domElement, opt) { | |||
* The first parameter of functions used to set `Style` properties is always an object containing | |||
* the properties of the features displayed with the current `Style` instance. | |||
* | |||
* @property {Number} order - Order of the features that will be associated to | |||
* the style. It can helps sorting and prioritizing features if needed. | |||
* @property {Object} fill - Polygons and fillings style. | |||
* @property {String|Function|THREE.Color} fill.color - Defines the main color of the filling. Can be | |||
* any [valid color |
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.
can you provide more details about why you remove it please?
Using the mapbox style file "mapbox://styles/mapbox/streets-v8" on mapLib and on itowns, I noticed the result as not at all comparable.
Thus I looked layers by layers to understand what were we doing wrong in itowns and tried to correct a maximum of bugs. The example using the mapbox stream has been added. (examples/vector_tile_2d_mapbox.html)
What this PR does: