This object is in archive! 

Support for custom custom HDPI online maps

Martin Ždila shared this idea 5 years ago
Completed

Hello,

We'd like to use HDPI tiles in Locus.

Our TMS comply with standard /{z}/{x}/{y}{r} where {r} can be omited or it can define tile scale like @3x. In that case tiles are 3x bigger. We still need to keep <tileSize>256</tileSize> even the real size is 768 and we need to turn on map scaling to 300% to see map texts and elements properly.

Isn't there a more straight approach to achieve that - without need to scale the map manually? Iteally there could also be some negotiation with TMS server to find out which scales does it support and then Locus could match device's DPI with that and provide scaling automatically. But I am afraid there is no standard for that.

Tile sample: http://tiles-ng.freemap.sk/15/18288/11266@3x

I've also attached custom map definitions.

Thanks in advance.

Files: fm.xml

Replies (6)

photo
1

Good day Martin,

really interesting. I was little worried that such map comes soon or later :).

What should be from your point of view correct app behaviour how to use and display such maps? As I think about it, best should be if map should have defined base scale that will be used for display. All maps currently have base scale defined to 100%. For your 3x maps, it should be set as 300%. Will it then work?

Current Locus Map does not support such "custom scaling". Anyway I'm for a few months working on new map core for whole application and with it will be possible to set custom scaling for every single map.

Let me know if there are any better approaches that I do not see, thanks.

photo
2

Hi Menion,

Actually I think Locus should pre-set global map scaling according to display density of the device.

Currently the default scaling is always 100% and it makes elements of all raster maps look very small, ofter unreadable, regardless of whether the map is HDPI or not.

So if I have HDPI device and I install Locus, I'd like to have it set to 300% for all raster maps. Then I would see non-HDPI maps little blurred, but elements would be readable. And I would see HDPI maps sharp and readable. Actually that's how web maps (eg. based on Leaflet) work - browsers upscale low resolution images (regular map tiles) so they are not small on HDPI displays.

Vector maps are now displayed correctly - Locus renders them according to display DPI. Actually when I am switching between vector and raster maps I always must adjust scaling back and forth.

photo
1

Hi Martin,

fine so you confirmed my solution, perfect.

What you wrote make sense and it is also one of main reasons, why I in September decided to rewrite app map core. The current system does not allow to set a different scale for raster maps and a different scale for vector maps, which is a serious problem. As you wrote, the vector maps look good with 100% scale because they automatically rescale based on DPI. With raster maps ... as you wrote.

I would like to publish a new map core into some alpha test probably during February. It will anyway still needs to add an additional parameter to the XML file. I'll mark this topic and let you know when the solution on Locus Map side is ready to test/use.

photo
1

Great, I am looking forward to test it :-)

photo
3

Good day Martin,

info about the version for test: https://forum.locusmap.eu/index.php?topic=6471.0 (so not yet published) anyway to close this topic in my TODO list, I'm writing here now.

In attachment is modified the configuration for your map. Key information:

  • {ts} in the url - internally called TileScale parameter. Needed to support custom scaling
  • "tileSize" - base tile value for 1x scale, so usually 256
  • "tileScale" parameter, needs
    • "dpi" - target DPI for which scale match best. App search for the highest best value so it tries to find tileScale.dpi >= real device DPI
    • "multi" - multiplier of base "tileSize" value
    • "replace" - value that replace {ts} parameter in url

Tested and seems to work as expected ;). Alpha version for test? In the worst case at the start of March.

Files: fm.xml
photo
1

Hi Menion,


I've finally got back into it but unfortunately the link provided in forum doesn't seem to work anymore.


BTW meanwhile we changed domain for our HDPI tiles and updated supported scales to 1, 2, and 3. Please see https://raw.githubusercontent.com/FreemapSlovakia/freemap-mapnik/master/freemap-locus.xml. You can include these definitions to built-in, merging it with existing (old) freemp maps.


Thanks.

photo
1

Zdravím Martine,

thanks for additional information. I've successfully added this very nice "New Outdoor" map into Locus Map. Only what I worry little about is, that this modification may need improvements in downloaded SQLite cache/offline map. Because till now, all maps were 256x256 and this change now. Locus Map than needs to know, how to handle this format. So it won't be included in the next app release.

Also, if you will want to modify anything in map settings directly in the app, please let me know. Thanks.

photo
1

Ahoj Menion,

I leave it up to you when you will include "full" support for HDPI maps in Locus :-). From user experience I only want to select "New Outdoor" from the map list and the app would then show the map of the suitable DPI (from the list of the supported) without manually adjusting zoom and also make available for offline download etc... :-)

photo
1

Ahoj Menion,

Could you please include map from https://github.com/FreemapSlovakia/freemap-mapnik/blob/master/freemap-locus.xml to our Freemap maps collection?

In the latest release it works great. And I finally don't need to change scaling when switching between raster maps, HDPI raster maps and vector maps. Thanks!

PS: Only thing I am missing now is to bind "Map shading" state to some maps because I prefer to have it enabled for our vector map only.

photo
1

Hello Martin,

the map was already added in previous Beta versions. I'll enable it to next release version.

Should be added into the list as another map or should it replace "Touristic" map?

I'll just have to somehow improve, how the app will work with these tiles. Because previously it was clear ... the map always had predefined tile size. Now, you may download/cache some tiles in a certain scale, then move download map file to another device with different resolution and ... Locus will have no idea how to handle this map.

photo
1

Thanks. Please name it "Outdoor". Currently it combines hiking, bicycle and ski trails.

Regarding handling exported maps, I think that target device should up/downscale tiles with ratio computed as current device scale / exported scale. Therefore export should also store `tileScales` and value of used `tileScale`. If exported tiles are eg. 3x and target device should use 2x then just scale them with 2/3 ratio. If exported tiles are 2x and imported to device with 3x then stale them with 3/2.

photo
1

Ahoj Menoin,

I've updated https://github.com/FreemapSlovakia/freemap-mapnik/blob/master/freemap-locus.xml to also include non-HDPI map to save bandwidth when downloading it over mobile network.

It would be nice if you could update it. Thanks!

photo
1
photo
1

Thanks, I've updated the file. You're right, I've used your example you provided at the beginning :-). I was only testing it on my Xiaomi Mi 4 and both files show me the same result (probably bacause both are resolved as @3x on my phone).

photo
1

BTW we've extended rendering also to Czech republic :-)

photo
1

Really? Hmm nice, I'll have to inform rest of team, good work :)

photo
1

...and I plan to extend it a little bit more in the following days (planning to include whole Hungary)

photo
1

Ahoj Menion,

Now we render also whole Hungary, Podkarpatská Rus and part of Austria. Check it out :-)

photo
1

Hello Martin,

nice. This apply for "Outdoor" map only or also for other currently available in Locus Map? Btw. does it still make sense to have "Turistic" and "Cycle" maps in Locus Map as well?

photo
1

This applies only to new outdoor.


I would keep "legacy" Turistic, Cycle and maybe also Ski as some people are probably still using it. Legacy maps also updates from OSM (cca daily). But maybe if you implement some statistics about which maps does Locus users use then you may find that we could get rid of it :-).


Also you could maybe add "Outdoor Low DPI map" for users who prefer saving network bandwidth when are in the wild. For this map only @1x tiles would be served.


Thanks!

photo
2

Thanks for the information.

I would rather stick with "less is better". If anyone needs offline maps, there are many options on how to get them.

Have a nice hot weekend :)

Menion

photo
2

Hi all,

Thanks for all the great work! I found this extremely useful. I have tried to create tileScales for MapBox providers and it works very nicely (v3.38.3).

Maybe we can update the Docs also while this feature is released.

https://docs.locusmap.eu/doku.php?id=manual:advanced:customization:online_maps

	<provider id="20015" type="0" visible="true" background="-1">
		<name>MapBox</name>
		<mode>Satellite Streets</mode>
		<usage>city,photo,road,aero</usage>
		<countries>World</countries>
		<url><![CDATA[https://api.mapbox.com/styles/v1/mapbox/satellite-streets-v10/tiles/256/{z}/{x}/{y}{ts}?access_token=pk.eyJ1IjoibGtobyIsImEiOiJjaWczZThzeWwxcnkwdjVtNWcwMzlxcmoyIn0.ez8paz8_sgg0X-2khGlUOw]]></url>;
		<zoomPart>{z}-8</zoomPart>
		<zoomMin>8</zoomMin>
		<zoomMax>28</zoomMax>
		<tileSize>256</tileSize>
		<tileScales>
			<tileScale dpi="0" multi="1" replace="" />
			<tileScale dpi="160" multi="2" replace="@2x" />
		</tileScales>
	</provider>

photo
1

Perfect, glad to hear it!

Only two small suggestions ...

  • remove your API key from published sample :)
  • app search for best DPI in reverse order. So devices with DPI higher or equal 160, get this 160. But DPI 160 is MDPI, standard value that is equal in Android world to rescale 1x. Rescale 2x is then used for DPI 320. This is also how new map core in recent Locus Map version works. So best should be set tileScale 2x for DPI 320. Then map tiles on HDPI devices will be perfectly sharp and medium devices won't download 512x512px tiles which is useless because tiles are then displayed as 256x256px. It's little complicated, but trust me, 2x for 320DPI is ideal :).

And we update manual soon.

Replies have been locked on this page!