tilezen / go-tilepacks

A Go-based tile downloader that saves to deduplicated mbtiles files.
MIT License
14 stars 3 forks source link

build/serve question #16

Closed thisisaaronland closed 3 years ago

thisisaaronland commented 3 years ago

I am trying to build an MBTiles database using the build tool:

$> go run -mod vendor cmd/build/main.go  -dsn sf.db -bounds '37.63983,-123.173825,37.929824,-122.28178' -zooms 0-16 -url-template 'https://tile.nextzen.org/tilezen/vector/v1/512/all/{z}/{x}/{y}.mvt?api_key=***'
2021/06/01 11:16:28 Created mbtiles output
2021/06/01 11:17:38 Saved 10k tiles (143.8 tiles per second)
2021/06/01 11:17:55 Job queue closed
2021/06/01 11:18:07 Finished making tile requests
2021/06/01 11:18:07 Saved 15080 tiles
2021/06/01 11:18:07 Finished processing tiles

And then serving it using the serve tool:

$> go run -mod vendor cmd/serve/main.go -input sf.db

But when I try to see the tiles in a web browser by visiting:

http://localhost:8080/preview.html#lat=37.6073&lng=-123.1311&z=13

I just see an empty map and a lot of 404 errors for the individual tiles requests. I feel like I am forgetting to do something obvious here but I am having trouble figuring out what...

nvkelso commented 3 years ago

Paging @iandees

iandees commented 3 years ago

I saw you edited out the --inverted-y option. Did you create the mbtiles with that? I'm guessing the serve option doesn't support it.

Can you post the mbtiles file? Does it contain the tiles you expect to be there?

thisisaaronland commented 3 years ago

Well, the 404 problem was a problem passing a lat,lon pair in the ocean. Passing a more-better lat,lon yields 200 responses but the preview.html page still doesn't render anything...

http://localhost:8080/preview.html#lat=37.7780&lng=-122.4316&z=15

No JS errors in the console, but still just a blank map.

Screen Shot 2021-06-01 at 18 42 40 Screen Shot 2021-06-01 at 18 42 55
iandees commented 3 years ago

I also don't see anything on the map, but the tiles definitely have data in them (as shown by qgis):

image

The preview.html is exactly the same modulo whitespace.

Curling a tile from Nextzen and comparing it to the same tile from the mbtiles shows that the mbtiles version is much smaller:

$ ls -l ~/Downloads/11-327-791-*
-rw-r--r--  1 iandees  staff  129854 Jun  2 09:36 /Users/iandees/Downloads/11-327-791-mbtiles.mvt
-rw-r--r--  1 iandees  staff  226216 Jun  2 09:33 /Users/iandees/Downloads/11-327-791-nextzen.mvt

The tile from mbtiles is compressed where the nextzen one comes as uncompressed:

$ file ~/Downloads/11-327-791-mbtiles.mvt
/Users/iandees/Downloads/11-327-791-mbtiles.mvt: gzip compressed data, last modified: Wed Jun  2 13:37:58 2021, max compression, original size modulo 2^32 226216
$ file ~/Downloads/11-327-791-nextzen.mvt
/Users/iandees/Downloads/11-327-791-nextzen.mvt: data
iandees commented 3 years ago

Found a bug in the code related to gzipping data that ends up in mbtiles. PR above fixes it. When you pull down the new code you'll have to re-generate your mbtiles.

thisisaaronland commented 3 years ago

I can confirm it all works as expected. Thanks!