Skip to content
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
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

ftoromanoff
Copy link
Contributor

@ftoromanoff ftoromanoff commented Nov 26, 2024

Using the mapbox style file "mapbox://styles/mapbox/streets-v8" on mapLib and on itowns, I noticed the result as not at all comparable.
image
image

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:

  • new feature:
    • support relative urls in style file (ArcGIS style file)
    • add a warn properties in source to add warnings and send them only ones
  • itowns bug fix:
    • Mapbox stream
      • enter url in {z}/{y}/{x} instead of ${z}/${y}/${x}
      • wrong selection of metadata when "{id}" in sprite
      • gestion of MVT layer using the 'ref' properties
      • gestion of line and polygon Label (simplified -> we use the first point of the geometry and sending a warning)
      • good gestion of the layer.order properties
    • Style
      • take into account the zoom in style when displaying layer
      • no display of polygon when fill.color is undefined
      • no display of line when stroke.width is 0
      • no recoloring of icon when icon.color is white (to avoid a lightning of the icon)
      • allow multiple label with same text (for contour lines)
      • no display of icon if size is 0

@ftoromanoff ftoromanoff changed the title MapBox VectorTile: bug fixes using an official MapBox flux MapBox VectorTile: bug fixes using an official MapBox stream Nov 27, 2024
Copy link
Contributor

@jailln jailln left a 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>
Copy link
Contributor

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",
Copy link
Contributor

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"
/>
Copy link
Contributor

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>
Copy link
Contributor

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();

Copy link
Contributor

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?

Copy link
Contributor

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)
Copy link
Contributor

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;
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

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;
Copy link
Contributor

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
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants