enzet / map-machine

Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
MIT License
510 stars 33 forks source link

Command to automatically render all tiles within bounding box (possibly polygon), at all specified zoom levels #69

Closed swedneck closed 2 years ago

swedneck commented 3 years ago

This would make it trivial to deploy maps, which is sorely needed for the OSM ecosystem. One concern is that this could lead to excessive API usage, so maybe it should require an input file?

enzet commented 3 years ago

Great suggestion, thank you! This is definitely worth being implemented.

enzet commented 3 years ago

Hey, @swedneck! Could you please take a look at the progress? Does this fix the issue?

Quick example

  1. Create a minimal amount of tiles that cover specified boundary box for zoom levels 16, 17, 18, and 19:
map-machine tile -b 2.364,48.854,2.367,48.857 -s 16-19
  1. Run tile server on 127.0.0.1:8080:
map-machine server
  1. Use JS code for Leaflet:
var map = L.map('mapid').setView([48.8555, 2.3655], 18);

L.tileLayer('http://127.0.0.1:8080/tiles/{z}/{x}/{y}', {
    maxZoom: 19,
    attribution: 'Map data © ' +
        '<a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> ' +
        'contributors, imagery &copy; ' +
        '<a href="https:/github.com/enzet/Roentgen">Röntgen</a>',
    id: 'roentgen',
    tileSize: 256,
    zoomOffset: 0
}).addTo(map);
swedneck commented 3 years ago

Looks about perfect, the only minor niggle i can see is that -s is unintuitive for zoom levels, could -z be used?

Also, can the server command accept a port flag?

enzet commented 3 years ago

Thank you! Yeah, -s is a shortcut for --scale. Since in OSM terminology it's zoom level, I will rename it to -z and --zoom respectively. Port option was also on my todo-list. I'll create issues.

Tile generation is still slow, partially because of SVG to PNG rasterization. And there are presumably a lot of bugs.