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

Symbol for polygon not placed at center. #5048

Open
exotfboy opened this issue Nov 15, 2024 · 11 comments
Open

Symbol for polygon not placed at center. #5048

exotfboy opened this issue Nov 15, 2024 · 11 comments
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed

Comments

@exotfboy
Copy link

exotfboy commented Nov 15, 2024

Hi:

When adding symbols to polygons with symbol-placement set to point, it is expected that the symbol will be placed at the center of the polygon.

However, in some situations, this is not the case. Live Example.

As shown in the example, the symbol for A is correctly centered, while the symbol for B is not.

What's going on?

@HarelM
Copy link
Collaborator

HarelM commented Nov 15, 2024

I would consider this as an issue with the limitation of accuracy for geojson source.
Geojson source only build tiles to zoom 15 or something similar, so the accuracy at zoom 21 is very low, which I would assume what's causing this calculation issues.
But you are more than welcome to check my theory.
You can also try out making vector tiles with higher resolution to see if it helps.

@HarelM HarelM added bug Something isn't working PR is more than welcomed Extra attention is needed labels Nov 15, 2024
@exotfboy
Copy link
Author

1 I will have a try if possible.

2 Any fallback instead of vector tiles at the moment?

@HarelM
Copy link
Collaborator

HarelM commented Nov 15, 2024

Maybe addProtocol where you could return the relevant tiles you create "on the fly", just maybe...

@exotfboy
Copy link
Author

exotfboy commented Nov 16, 2024

@HarelM

Since I do not have the environment to create vector tiles from the server side. So I tried to generate vector tiles on the fly as you said, it does not change anything. Have a look at this.

@HarelM
Copy link
Collaborator

HarelM commented Nov 16, 2024

Thanks! But this still users geijson-vt which I think is where the bug is.
Try to use vt-pbf or something that can serialize a geojson object to a vector tile.
No sure it will help but world be interesting to see if it changes anything...

@exotfboy
Copy link
Author

Indeed the vt-pbf is used:

  const tile = tileIndex.getTile(z, x, y); //use geojson-vt create vector tile with json format
  if (tile == null) return { data: null };
  const buff = vtpbf.fromGeojsonVt({ json: tile }); //use vt-pbf to generate pbf format.

@HarelM
Copy link
Collaborator

HarelM commented Nov 16, 2024

I would advise to try and create a tile using a different method and then try to read it and see if you still have a problem.

@exotfboy
Copy link
Author

Finally I tried to upload my data to mapbox studio to generate vector tiles. And things does not change.

@HarelM
Copy link
Collaborator

HarelM commented Nov 17, 2024

Ok, thanks for taking the time to try this out, this rules that the problem is with the geojson conversation to MVT, and leaves text location precision I guess...

@exotfboy
Copy link
Author

I also tried to publish the geojson to vector tiles with geoserver locally, and got the same result. Also I do not notice any precision lose for the geometry. So I guess if this is caused by the symbol algorithm.

@HarelM
Copy link
Collaborator

HarelM commented Nov 17, 2024

This is my gut feeling as well. Feel free to drive into it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants