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

Add options for ratio and tileType #44

Merged
merged 6 commits into from
Feb 20, 2024

Conversation

acalcutt
Copy link
Contributor

Goal

Adds cli options for 'pixel ratio' and 'tiletype' to allow changing the type of tiles generated from 'jpg', 'png', or 'webp'. It defaults to a ratio of 1 and tiletype of 'jpg', which were the old hardcoded defaults.

Screenshots

with ratio 1, tiletype webp
`node . --style self --stylelocation styles\http_pmtiles_local_spites_fonts.json --stylesources styles\data --bounds "-79,37,-78,38" -Z
image

with ratio 2, tiletype webp
node . --style self --stylelocation styles\http_pmtiles_local_spites_fonts.json --stylesources styles\data --bounds "-79,37,-78,38" -Z 11 -f wdb_11_r2_webp -r 2 -t webp
image

with ratio 1, tiletype png
node . --style self --stylelocation styles\http_pmtiles_local_spites_fonts.json --stylesources styles\data --bounds "-79,37,-78,38" -Z 11 -f wdb_11_r1_png -r 1 -t png
image

with ratio 2, tiletype png
image

with ratio 1, tiletype jpg
node . --style self --stylelocation styles\http_pmtiles_local_spites_fonts.json --stylesources styles\data --bounds "-79,37,-78,38" -Z 11 -f wdb_11_r1_jpg -r 1 -t jpg
image

with ratio 2, tiletype jpg
image

@wipfli
Copy link

wipfli commented Feb 19, 2024

Thanks for the png option. Looks like a good addition to me!

@acalcutt
Copy link
Contributor Author

acalcutt commented Feb 19, 2024

it seems size wise, webp could actually be the smallest sized images based on the screenshot above. I wonder what the compatibility of webp is these days

@acalcutt
Copy link
Contributor Author

This is example of the effect of using ratio when viewing the files in qgis. you can see the ratio 2 tiles are much sharper

ratio: 1
image

ratio: 2
image

@acalcutt acalcutt marked this pull request as ready for review February 19, 2024 20:16
raw: {
premultiplied: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

premultiplied was added in sharp 0.28.2 :-) lovell/sharp#1599 (comment)

So no need to Un-premultiply anymore

Copy link
Member

@rudokemper rudokemper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you! Ratio=2 looks great at high zoom levels with some styles with imagery tiles and OSM labels that I've been working with.

@rudokemper rudokemper merged commit 244ecfc into ConservationMetrics:main Feb 20, 2024
1 check failed
@wipfli
Copy link

wipfli commented Feb 20, 2024

Thanks for the quick review @rudokemper. Can you make an NPM release with this new feature?

@rudokemper
Copy link
Member

Sure thing, done.

@acalcutt
Copy link
Contributor Author

acalcutt commented Feb 20, 2024

Just an FYI since I didn't note it.

You can have a ratio higher than 2, it just increases your tile image size the more you raise it. Tileserver GL accepts a max ratio of 3 by default, but can go all the way up to a ratio of 9 depending on your options.

@rudokemper
Copy link
Member

Interesting, I wonder what kind of use case could benefit from such a high ratio.

Speaking of which, I'd be super curious to learn more about how ya'll are using the tool @acalcutt @wipfli!

@acalcutt
Copy link
Contributor Author

acalcutt commented Feb 20, 2024

I don't really have a use yet, but I have wanted to make a rendered mbtiles in the past for some atv trail ideas I have had. sometimes on trails the cell signal is low, so using web based maps isn't ideal. I'd love eventually to make a maplibre-native android app with local tiles that can be used offline.

In the past I have tried to make tiles using Qtiles, like
https://techidiots.net/notes/mapbox-gl-tileserver-gl/create-a-esri-satellite-mbtiles-base-map-with-qgis-and-qtiles
which i remember was a huge pain

On the maplibre-native side, I know I have seen request for something like this in
maplibre/maplibre-native#2070

Really, mostly I was bored over the weekend and saw something I could contribute here. hope to see more progress on this. Now I am trying to figure out how to speed it up at higher zoom levels. I was trying a few suggestions from google code AI which were good starts, but so far nothing successful. I am trying generate a full planet zoom 14, but it is looking like that would take a month...haha
image

@rudokemper
Copy link
Member

rudokemper commented Feb 20, 2024

Super cool, thanks for sharing! Our use case is Indigenous users in an offline context who need maps for data collection or visualization, but I figured the tool could be helpful for a lot of different use cases. So it's affirming to read about other interests, and contribute something back to the broader Maplibre community that everyone can use.

(On an somewhat related note, over at Terrastories we're super grateful for the recent love you and others have given Tileserver-GL, and in particular support for arm architecture has been great for deploying the tool on low energy devices!)

@acalcutt
Copy link
Contributor Author

acalcutt commented Feb 20, 2024

Interesting, I wonder what kind of use case could benefit from such a high ratio.

Speaking of which, I'd be super curious to learn more about how ya'll are using the tool @acalcutt @wipfli!

I'd imagine at minimum it helps make overzooming look sharper. So if you made a low max zoom tile (like say zoom 9) and you were zoomed into zoom 14, a ratio 1 tile would probably be very blury, but a ratio 5 tile may still look decent, since it is basically the size it should be for that zoom level.

@acalcutt
Copy link
Contributor Author

acalcutt commented Feb 20, 2024

Glad my work on maplibre-native node and tileserver-gl is helpful to others :-). I have probably spent way to much time on getting that working

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

Successfully merging this pull request may close these issues.

3 participants