From a98c7823d7f0873a209fad3b2faf6593425e6487 Mon Sep 17 00:00:00 2001 From: sfomuseumbot Date: Tue, 3 Sep 2024 15:14:31 -0700 Subject: [PATCH] always invert the Y coordinate at the server level - this will break tools using client-side {-y} values --- tile/parser.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tile/parser.go b/tile/parser.go index 5130bbb..d292dcd 100644 --- a/tile/parser.go +++ b/tile/parser.go @@ -85,7 +85,13 @@ func (p *SimpleTileParser) Parse(path string) (*TileRequest, error) { x, _ := strconv.ParseUint(match[3], 10, 32) y, _ := strconv.ParseUint(match[4], 10, 32) - tile := maptile.New(uint32(x), uint32(y), maptile.Zoom(z)) + // Just always invert the y coordinate because MBTiles + // https://gist.github.com/tmcw/4954720 + // https://stackoverflow.com/questions/46822094/incorrect-coordinates-in-mbtiles-generated-with-tippecanoe + + inverted_y := (1 << z) - 1 - y + + tile := maptile.New(uint32(x), uint32(inverted_y), maptile.Zoom(z)) tile_req := &TileRequest{ Tile: tile,