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

wind layer bounds decrease as zoom increases #185

Open
crawld opened this issue Aug 29, 2023 · 8 comments
Open

wind layer bounds decrease as zoom increases #185

crawld opened this issue Aug 29, 2023 · 8 comments

Comments

@crawld
Copy link

crawld commented Aug 29, 2023

I'm using wind-layer with mapbox-gl to draw a wind field over a small area. At low zoom levels, it looks correct, but when I increase the zoom, the layer is not drawn at the bottom.

This image shows the layer over the correct area, and is covering the black polygon:
image

But once I zoom in, the layer no longer covers the area. Here the layer does not cover the bottom of the black polygon:
image

The layer seems to shrink the more I zoom in.

@sakitam-fdd
Copy link
Owner

@crawld It would be a good idea to provide an example, in fact the example in the example file has had some other processing done to avoid example rendering problems when zooming in on the map,See https://blog.sakitam.com/wind-layer/guide/#windcore-%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E for details on the velocityScale parameter

https://codepen.io/sakitam-fdd/pen/GRpeeGG?editors=1010

@crawld
Copy link
Author

crawld commented Aug 30, 2023

Here's how I create wind-layer:

this._windLayer = new WindLayer('wind', [
                {
                    "header": {
                        "parameterCategory": 1,
                        "parameterNumber": 2,
                        "dx": dx,
                        "dy": dy,
                        "nx": 1,
                        "ny": 1,
                        "la1": bounds[3],
                        "la2": bounds[1],
                        "lo1": bounds[0],
                        "lo2": bounds[2],
                    },
                    "data": [
                        wind_u,
                    ]
                },
                {
                    "header": {
                        "parameterCategory": 1,
                        "parameterNumber": 3,
                        "dx": dx,
                        "dy": dy,
                        "nx": 1,
                        "ny": 1,
                        "la1": bounds[3],
                        "la2": bounds[1],
                        "lo1": bounds[0],
                        "lo2": bounds[2]
                    },
                    "data": [
                        wind_v,
                    ]
                }
            ],
            {
                windOptions: {
                    frameRate: 16,
                    maxAge: 60,
                    globalAlpha: 0.9,
                    velocityScale: () => {
                        const zoom = parseInt(this._map.getZoom());
                        return this._velocityScales[zoom] || 1 / 40;
                    },
                    paths: 200,
                },
            });

There is only a single value in the u/v data since I want a constant wind direction and speed over the domain.

@crawld
Copy link
Author

crawld commented Aug 31, 2023

I'm using mapbox-gl 2.8.0. When I switch to 1.8.0 (used by @sakitam-gis/mapbox-wind) the problem does not occur. Have you tested with mapbox-gl 2.x?

@sakitam-fdd
Copy link
Owner

@crawld I haven't tested mapbox-gl 2.x in detail, but I'm guessing that you want the particle velocity to be moving at a constant rate, so you should configure velocityScale to be a fixed value (since constant velocity * time per unit = geographic distance traveled is fixed in the normal case, then the map will see the particles moving faster when zoomed in), configured as a function This is for demonstration purposes, as the movement of the example will be linear at a large level.

@crawld
Copy link
Author

crawld commented Sep 1, 2023

Thanks @sakitam-fdd. The particle velocity is not important at different zoom levels for my use case. It's much more important that particles are drawn over the area for all zoom levels.

@sakitam-fdd
Copy link
Owner

@crawld Can you easily attach a minimal example? it seems to look fine when I test it under 2.15.0 https://codepen.io/sakitam-fdd/pen/gOZMEXb

@crawld
Copy link
Author

crawld commented Feb 29, 2024

Did this get fixed? I found it only seem to occur when 3d terrain was enabled.

@sakitam-fdd
Copy link
Owner

sakitam-fdd commented Feb 29, 2024

@crawld Very sorry, currently all layers in Mapbox cannot be used with terrain or non Mercator projections;Before the mapbox official release of more APIs, all implementations were very difficult

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

No branches or pull requests

2 participants