sakitam-fdd / wind-layer

:flags: :rocket: wind-layer | a openlayers && maptalks && amap && bmap && leaflet && mapbox-gl && maplibre-gl extension like windy.com for weather visualization

Home Page:https://sakitam-fdd.github.io/wind-layer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wind layer bounds decrease as zoom increases

crawld opened this issue · comments

commented

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.

@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

commented

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.

commented

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?

@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.

commented

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.

@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

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

@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