Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion] Possibility to also serve retina tiles #154

Closed
Naahuel opened this issue Oct 6, 2020 · 9 comments
Closed

[suggestion] Possibility to also serve retina tiles #154

Naahuel opened this issue Oct 6, 2020 · 9 comments

Comments

@Naahuel
Copy link

Naahuel commented Oct 6, 2020

Following up on #33 and thanks to @MaRaSu 's suggestion, I added this line in the Dockerfile:

RUN bash -c 'echo -e "[map_retina]\nURI=/tile@2x/\nTILEDIR=/var/lib/mod_tile\nXML=/home/renderer/src/openstreetmap-carto/mapnik.xml\nHOST=localhost\nMAXZOOM=19\nSCALE=2.0\nTILESIZE=512\n" >> /usr/local/etc/renderd.conf'

Which essentially adds this entry to renderd.conf:

[map_retina]
URI=/tile@2x/
TILEDIR=/var/lib/mod_tile
XML=/home/renderer/src/openstreetmap-carto/mapnik.xml
HOST=localhost
MAXZOOM=19
SCALE=2.0
TILESIZE=512

And now I can get tiles at the usual URL but also at http://localhost:8080/tile@2x/{z}/{x}/{y}.png
It seems like the preferred URL template seems to be http://localhost:8080/tile/{z}/{x}/{y}@2x.png but every kind of map you integrate it on allows you to use any URL template you want so I don't see this as a problem.

That RUN line is a bit ugly but I guess it works, I'm not very good at this. If this is something that interests you maybe you can optimize it.

@Istador
Copy link
Contributor

Istador commented Oct 7, 2020

That RUN line is a bit ugly but I guess it works, I'm not very good at this. If this is something that interests you maybe you can optimize it.

You could extend from the image with your own separate Dockerfile like:

FROM overv/openstreetmap-tile-server:1.4.0

RUN bash -c 'echo -e "[map_retina]\nURI=/tile@2x/\nTILEDIR=/var/lib/mod_tile\nXML=/home/renderer/src/openstreetmap-carto/mapnik.xml\nHOST=localhost\nMAXZOOM=19\nSCALE=2.0\nTILESIZE=512\n" >> /usr/local/etc/renderd.conf'

And then use your own extended image everywhere instead of building the base image again.

(There's a way to have real line breaks inside of the RUN command with other quotes, so that it's not so ugly. I don't remember the specific syntax for it right now.)


Or, you could copy the contents of /usr/local/etc/renderd.conf and put it into a file on your host system, change the file to your liking and then overload the file with a volume mount:

docker run \
    [...] \
    -v ./myrenderd.conf:/usr/local/etc/renderd.conf \
    [...]

@MaRaSu
Copy link

MaRaSu commented Oct 7, 2020

Some tips (learned the hard way) for creating & using retina tiles this way:

  • Mapnik with scale 2.0 setting mostly works logically, however some of the patterns fills (e.g. with png's) including those for ways do not scale in a logical way - so good to check & compare carefully your map style normal vs. retina tiles rendering results
  • Enabling use of retina tiles in Leafletjs is in the end simple, yet it's useful to search for the discussion in Github issues where various options are discussed in details to fully understand how it works. It's a bit too easy to accidentally disable retina tiles usage or enable Leafletjs to simulate retina-tiles by loading 4 times normal amount of tiles (instead of using actual retina tiles).

@Naahuel
Copy link
Author

Naahuel commented Oct 7, 2020

Thank you @Istador, I'm quite a noob with docker and you way of extending the image is actually much cleaner!

@MaRaSu that's very interesting! thanks! I've integrated these tiles on the web (using leaflet) and on mobile (using React Native's <MapView />). On mobile the difference is HUGE. The regular tiles look just awful. So far, I only had trouble on iOS (right where I want it to work lol) where the tiles are not aligned properly and the map looks broken. I think it's just a map configuration thing and maybe not a tile thing. We'll see.

Given @Istador 's suggestion, maybe you can close this issue if you want! I thought I'd help a tiny bit with what worked for me and surely other people will need as well.

@gsontheimer
Copy link

You could extend from the image with your own separate Dockerfile ... <<

I tried to figure out how to do this, but new to Docker, as I am, did not succeed so far. Can you help me further?

@gsontheimer
Copy link

Following up on #33 and thanks to @MaRaSu 's suggestion, I added this line in the Dockerfile:

RUN bash -c 'echo -e "[map_retina]\nURI=/tile@2x/\nTILEDIR=/var/lib/mod_tile\nXML=/home/renderer/src/openstreetmap-carto/mapnik.xml\nHOST=localhost\nMAXZOOM=19\nSCALE=2.0\nTILESIZE=512\n" >> /usr/local/etc/renderd.conf'

Which essentially adds this entry to renderd.conf:

[map_retina]
URI=/tile@2x/
TILEDIR=/var/lib/mod_tile
XML=/home/renderer/src/openstreetmap-carto/mapnik.xml
HOST=localhost
MAXZOOM=19
SCALE=2.0
TILESIZE=512

And now I can get tiles at the usual URL but also at http://localhost:8080/tile@2x/{z}/{x}/{y}.png It seems like the preferred URL template seems to be http://localhost:8080/tile/{z}/{x}/{y}@2x.png but every kind of map you integrate it on allows you to use any URL template you want so I don't see this as a problem.

That RUN line is a bit ugly but I guess it works, I'm not very good at this. If this is something that interests you maybe you can optimize it.

Could you please check the directories with the latest build? The scripts seems broken. Thank you!!

@gsontheimer
Copy link

gsontheimer commented Jul 7, 2023

You could extend from the image with your own separate Dockerfile like:

FROM overv/openstreetmap-tile-server:1.4.0

RUN bash -c 'echo -e "[map_retina]\nURI=/tile@2x/\nTILEDIR=/var/lib/mod_tile\nXML=/home/renderer/src/openstreetmap-carto/mapnik.xml\nHOST=localhost\nMAXZOOM=19\nSCALE=2.0\nTILESIZE=512\n" >> /usr/local/etc/renderd.conf'

And then use your own extended image everywhere instead of building the base image again.

I managed to locate renderd.conf with your help at its new location. But Retina tiles still do not work with your latest build. What is wrong with this:

FROM overv/openstreetmap-tile-server:latest

RUN bash -c 'echo -e "[map_retina]\nURI=/tile@2x/\nTILEDIR=/var/cache/renderd/tiles\nXML=/home/renderer/src/openstreetmap-carto/mapnik.xml\nHOST=localhost\nMAXZOOM=19\nSCALE=2.0\nTILESIZE=512\n" >> /etc/renderd.conf'

?? :-|

@gsontheimer
Copy link

@Naahuel or @Istador or anyone else: I have spend so many hours now - a year ago the retina tiles still worked, but with the latest build and the Dockerfile mentioned above the tiles at http://localhost:8080/tile@2x/{z}/{x}/{y}.png just look identically to the ones at http://localhost:8090/tile/{z}/{x}/{y}.png

If anyone knows how to fix this, I would be most grateful.

Something must have changed in the latest build of overv/openstreetmap-tile-server, so that adding the above commands to renderd.conf no longer works.

@Istador
Copy link
Contributor

Istador commented Jul 23, 2023

Works fine for me.

Dockerfile:

FROM overv/openstreetmap-tile-server:2.3.0

RUN bash -c 'echo -e "[map_retina]\nURI=/tile@2x/\nTILEDIR=/data/tiles\nXML=/data/style/mapnik.xml\nHOST=localhost\nMAXZOOM=20\nSCALE=2.0\nTILESIZE=512\n" >> /etc/renderd.conf'

Commands:

docker build . -t osm-local
docker run --rm  -v osm-data:/data/database/           osm-local import
docker run --rm  -v osm-data:/data/database/ -p 80:80  osm-local run
curl -o 1x.png http://localhost/tile/0/0/0.png
curl -o 2x.png http://localhost/tile@2x/0/0/0.png

1x
2x


The changes between v2.3.0 and master (latest) shouldn't make a difference v2.3.0...master except when trying to use a different style.

@gsontheimer
Copy link

:-)

Thank you so much - got it to work again! No idea, why it did not work before. I started from scratch with your Dockerfile.

Is there any pointer anywhere to how to use different styles, i.e. instead of the openstreetmap-carto style, i.e. where can I find appropriate files (one lua script, one style, one mml, and one one SQL)??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants