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 21 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 force-pushed the mapBoxVT branch 2 times, most recently from 5581f1e to 9fcfdee Compare November 26, 2024 16:57
@ftoromanoff ftoromanoff marked this pull request as ready for review November 27, 2024 08:48
@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
@ftoromanoff ftoromanoff requested a review from jailln November 27, 2024 10:01
@ftoromanoff ftoromanoff force-pushed the mapBoxVT branch 2 times, most recently from bc8515d to 18b1d2c Compare November 27, 2024 14:18
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 :)

examples/vector_tile_raster_2d_mapbox.html Outdated Show resolved Hide resolved
examples/vector_tile_raster_2d_mapbox.html Outdated Show resolved Hide resolved
examples/vector_tile_raster_2d_mapbox.html Outdated Show resolved Hide resolved
examples/vector_tile_raster_2d_mapbox.html Outdated Show resolved Hide resolved
@@ -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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ftoromanoff can you remove this part from this PR then please ? You can open an issue on this matter if you want to keep track of it

src/Core/Style.js Show resolved Hide resolved
src/Core/Style.js Show resolved Hide resolved
})) {
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for now, it seems that it is not needed on what I tested and I asked @mgermerie why he used it in the first place.

} 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?

Copy link
Contributor Author

@ftoromanoff ftoromanoff Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it to simplified. It is also linked to a trouble to link a specifique feature.style to it's properties.

With this optimization I got these error:
image
linked with

itowns/src/Core/Style.js

Lines 903 to 914 in 18cc3ee

style.icon.cropValues = function _(p) {
const id = iconImg.replace(/\{(.+?)\}/g, (a, b) => (p[b] || '')).trim();
if (sprites[id] === undefined) {
const warning = `WARNING: "${id}" not found in sprite file`;
if (!warn.has(warning)) {
warn.add(warning);
console.warn(warning);
}
sprites[id] = cropValueDefault;// or return cropValueDefault;
}
return sprites[id];
};

The properties of the current featreu doesn't seems to be the right one when the function is called...

That I don't get when each feature as it's own existence. It might probalby be solved other wise to avoid the probable border effect induce by newFeatureByReference...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit weird that you get this warning since we look for features with the same id that would already have been parsed.
If we remove this code I'm not sure we need to features collection at all since from my understanding it is to avoid creating multiple times the same feature in memory. It would be interresting to check if it is common that same features are in different pbf and therefore what if this optimization is really needed. It seems a bit unrelated to this PR though so what I propose is to:

src/Core/Style.js Show resolved Hide resolved
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