-
-
Notifications
You must be signed in to change notification settings - Fork 893
Description
What is the bug?
My EPSG:3006 WMTS layer works in 7.0.2, but stopped working after I switched to the master branch. On closer inspection, the reason was that flutter_map is requesting the wrong x,y,z tiles for a given lat,long position.
I've not completely isolated #1948 as the cause, but I think it's the most likely thing in the commit log, and there is an assumption about the modulus that is not generally true.
How can we reproduce it?
Most non-WebMercator grids should trigger this, but here is one.
// OSM based, uses somewhat strange bounds. No access restrictions or fees in GetCapabilities as of 2024-10-15
FlutterMap(
options: MapOptions(
initialCameraFit: CameraFit.bounds(
bounds: LatLngBounds(
LatLng(61.285991891313344, 17.006922572652666),
LatLng(61.279648385340494, 17.018309853620366)),
),
crs: Proj4Crs.fromFactory(
code: 'EPSG:3006',
proj4Projection: proj4.Projection.add(
'EPSG:3006',
'+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs',
),
origins: [
Point(-58122915.354077406, 19995929.885879364),
],
resolutions: const <double>[
4096,
2048,
1024,
512,
256,
128,
64,
32,
16,
8,
4,
2,
1,
0.5,
0.25,
0.125
],
)),
children: [
TileLayer(
tileBuilder: coordinateDebugTileBuilder,
urlTemplate:
'https://maps.trafikinfo.trafikverket.se/MapService/wmts.axd/BakgrundskartaNorden.gpkg?layer=Background&style=default&tilematrixset=Default.256.3006&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image%2Fpng&TileMatrix={z}&TileCol={x}&TileRow={y}')
],
)
Do you have a potential solution?
I don't uderstand all the code in #1948 , but I believe the problem originates in
final modulo = 1 << coordinates.z;
| final modulo = 1 << coordinates.z; |
I don't think the code currently handles cases where
- the grid is not square
- has more than one tile for z = 0
- or the projection does not cover the world
In general, I think you need a flag on the CRS to know whether unbounded scroll applies. Or only enable it for WebMercator for now.
Platforms
All
Severity
Obtrusive: Prevents normal functioning but causes no errors in the console