-
-
Notifications
You must be signed in to change notification settings - Fork 39
Description
Expected
Grid.ToNative() should return the top-left point of the given tile:
grid, _ := slippy.NewGrid(3857)
tile := slippy.NewTile(5, 0, 0)
point, _ := grid.ToNative(tile)
fmt.Println(point) // [-2.003750834e+07 2.003750834e+07]Grid.FromNative() should return the tile corresponding to a top-left point:
grid, _ := slippy.NewGrid(3857)
tile, _ := grid.FromNative(5, geom.Point{-2.003750834e7, 2.003750834e7})
fmt.Println(tile) // &{5 0 0}FromNative() and ToNative() should be able to reverse each other predictably. That is, FromNative(ToNative(x)) == x.
Problem
The above does not hold for all coordinates. In the following example, 5,3,5 becomes 5,3,4:
grid, _ := NewGrid(3857)
tile1 := NewTile(5, 3, 5)
point, _ := grid.ToNative(tile1)
tile2, _ := grid.FromNative(5, point)
fmt.Println(tile2) // &{5 3 4}x=3 and y=5 seems to be buggy at multiple zooms (try 6,3,5, 7,3,5, and 8,3,5)
Impact
Whatever is causing this problem seems to make slippy.RangeFamilyAt() unpredictable as well, as it relies on ToNative() and FromNative(). When updating Tegola to use the latest geom (go-spatial/tegola#952), I couldn't get RangeFamilyAt() to work and had to copy in the old version which does not make use of these functions.
Note: it's entirely possible this is related to me using an M1 Mac. I see slightly smaller floats generated on a regular basis, so maybe someone could try this on amd64?