XYZ Tile Cache Primer

October 2, 2020 · View on GitHub

XYZ Logo

XYZ Build Status XYZ Go Report Card

About

This tool, given the URL to an XYZ tile caching proxy, will procedurally generate and execute requests for every tile at every zoom level up to the maximum zoom level specified. Concurrency is optional and configurable. Headers for authentication or user agent spoofing can be specified using command line flags.

Usage

The design of XYZ is as simple as possible. It will not have a rich feature set primarily because the scope of the problem it solves isn't very wide. Here is a brief overview on how to use the tool in its entirety:

Flags

  --url    Templated cache URL to prime. Ex: tile.company.com/{x}/{y}/{z}.png
  --zoom   Max zoom depth to prime to. Usually in the range of 0-18 but can go deeper.
  --cc     Maximum request concurrency. Defaults to 4 simultaneous requests.
             Take care not to exceed the rate limits of your tile provider!
  --header Add headers to all requests. Usage `--header name:value`.
  --help   Shows this help menu.

Examples

  xyz --url tile.company.com/{x}/{y}/{z}.png
  xyz --url tile.company.com/{x}/{y}/{z}.png --zoom 8
  xyz --url tile.company.com/{x}/{y}/{z}.png --zoom 8 --cc 16
  xyz --url tile.company.com/{x}/{y}/{z}.png --header X-Auth-Token:8675309abcd

Roadmap

  • Improve HTTP request performance (#3)
  • Shrink HTTP response memory footprint (#4)
  • Improve concurrency model (#5)

Releases

To get a copy of XYZ, either visit the releases page or clone the repo and compile it yourself.

The current Go version requirement to build is 1.14+

Map Tiles Overview

Splitting the world into square tiles is a simple way to distribute geographic information and metadata to devices. From raster data representing illustrated or generated cartography to vector data representing infrastructure and other arbitrary geometries, tiles optimize the time and space necessary to gather pieces of grographic information. This allows us to quickly illustrate a geographic region and its associated attributes.

Zoom Level

The zoom parameter is an integer between 0 (zoomed out) and 18 (zoomed in). 18 is normally the maximum, but some tile servers might go beyond that. A tile at a given zoom level will split into four equally sized tiles at the next zoom level.

Level# TilesTile width (° of longitudes)m / pixel (on Equator)~ Scale(on screen)Examples of areas to represent
01360156,4121:500mwhole world
1418078,2061:250m
2169039,1031:150msubcontinental area
3644519,5511:70mlargest country
425622.59,7761:35m
51,02411.254,8881:15mlarge African country
64,0965.6252,4441:10mlarge European country
716,3842.8131,2221:4msmall country, US state
865,5361.406610.9841:2m
9262,1440.703305.4921:1mwide area, large metropolitan area
101,048,5760.352152.7461:500kmetropolitan area
114,194,3040.17676.3731:250kcity
1216,777,2160.08838.1871:150ktown, or city district
1367,108,8640.04419.0931:70kvillage, or suburb
14268,435,4560.0229.5471:35k
151,073,741,8240.0114.7731:15ksmall road
164,294,967,2960.0052.3871:8000street
1717,179,869,1840.0031.1931:4000block, park, addresses
1868,719,476,7360.0010.5961:2000some buildings, trees
19274,877,906,9440.00050.2981:1000local highway and crossing details
201,099,511,627,7760.000250.1491:500A mid-sized building
  • The "# Tiles" column indicates the number of tiles needed to show the entire world at the given zoom level. This is useful when calculating storage requirements for pre-generated tiles.
  • The "° Tile width" column gives the map width in degrees of longitude, for a square tile drawn at that zoom level.
  • Values listed in the column "m / pixels" gives the number of meters per pixel at that zoom level. These values for "m / pixel" are calculated with an Earth radius of 6372.7982 km and hold at the Equator; for other latitudes the values must be multiplied by the cosine (approximately assuming a perfect spheric shape of the geoid) of the latitude.

Ref: https://wiki.openstreetmap.org/wiki/Zoom_levels