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

Feature request: provide support for PMTiles format files? #212

Open
anders86755 opened this issue May 2, 2024 · 10 comments
Open

Feature request: provide support for PMTiles format files? #212

anders86755 opened this issue May 2, 2024 · 10 comments

Comments

@anders86755
Copy link

About PMTiles format : https://github.com/protomaps/PMTiles

The current initialization of demSource is as follows:

const demSource = new mlcontour.DemSource({
        url: 'https://demotiles.maplibre.org/terrain-tiles/{z}/{x}/{y}.png',
        encoding: 'mapbox',
        maxzoom: 12,
        worker: true
    });

If support for pmtiles format could be implemented, for example:

const demSource = new mlcontour.DemSource({
        url: 'pmtiles://https://xxx.xxx.com/xxx.pmtiles',
        encoding: 'mapbox',
        maxzoom: 12,
        worker: true
    });

The pmtiles format is very promising. It would be great if your plug-in could support this format.

Anyway,Thanks for this great plugin :)

@Patukas
Copy link

Patukas commented May 2, 2024

Same case here.

I am using pmtiles for dem source.

I am interested in use maplibre-contour.

Thanks.

@msbarry
Copy link
Contributor

msbarry commented May 2, 2024

Yep! This is a known limitation of the plugin. I'm working to move this functionality into maplibre so you don't need this plugin anymore: maplibre/maplibre-style-spec#583. Then you'll be able to use the pmtiles plugin for dem tiles that power a built-in contour source you can render line and label layers from.

@HarelM
Copy link
Contributor

HarelM commented Nov 30, 2024

While this may take longer than expected, maybe it will be simpler to allow overriding the fetch method in non-worker case as a temporary solution? or add the ability to load a script to the worker in worker mode?
Let me know if I can help out here in any way as I'm also interested in something similar to this feature request.

@acalcutt
Copy link

I spent some time yesterday to see if I could add in the pmtiles npm plugin into maplibre-contour and modify its fetchTile to use pmtiles.getZxy(). I am testing with this branch and you can see the changes I have made so far at main...acalcutt:maplibre-contour:pmtiles_test

I think I have it at least reading the tiles, because when testing on https://wifidb.net/demo/pmtiles/contour/ I can see it is loading the hillshade , which is coming from the tiles: [demSource.sharedDemProtocolUrl] , which is reading the pmtiles file through maplibre-countour (there is no separate pmtiles plugin on that page).

However right now I haven't been able to get the contour part of this working. I can see from the console.log's I added that it is trying to load them. it is getting neighbor tiles, but the isolines seem to be blank at the end. I am wondering if maybe this relates to not specifying a tile type when i convert the pmtiles array buffer to blob....but I am not really sure.
image

I am honestly not the best with typscript or promises so I have been asking google ai a lot of questions just to get this far, so if anyone has any ideas to get get this working I am up for suggestions. The PMtiles support is somewhat based on the work i did in tileserver-gl at https://github.com/maptiler/tileserver-gl/blob/master/src/pmtiles_adapter.js

@acalcutt
Copy link

acalcutt commented Dec 13, 2024

Actually it looks like I did get it working. It was failing because my source was 'terrarium' but I had it set to 'mapbox' in the DemSource

https://wifidb.net/demo/pmtiles/contour/
image

@gvkhna
Copy link

gvkhna commented Dec 13, 2024

How are you generating the pmtiles, is it based on the open contour dataset?

@acalcutt
Copy link

acalcutt commented Dec 13, 2024

How are you generating the pmtiles, is it based on the open contour dataset?

That particular file is made from GEBCO bathymetry data from https://www.gebco.net/data_and_products/gridded_bathymetry_data/

I made it using this code from my repo at https://github.com/acalcutt/GEBCO_to_MBTiles , mainly this code the uses gdal and rio-rgbify to make a terrairum file with a custom version of rio-rgbify https://github.com/acalcutt/GEBCO_to_MBTiles/blob/main/create_terrarium.sh (for terrarium)
or
https://github.com/acalcutt/GEBCO_to_MBTiles/blob/main/create_terrainrgb.sh (for terrainrgb)

I also have code to do the same from the JAXA dataset at
https://github.com/acalcutt/jaxa_AW3D30_to_MBTiles

Both processes make mbtiles files, which i then converted with the pmtiles tool https://github.com/protomaps/PMTiles?tab=readme-ov-file#creating-pmtiles

The GEBCO file is 11GB. I used it in this example mainly because I already had it in that location

@acalcutt
Copy link

One nice thing about maplibre-cuntour is that even though the dem only goes to zoom 8, you are still able to use higer zoom levels on your lines and still get nice crisp looking lines at high zoom levels

@gvkhna
Copy link

gvkhna commented Dec 13, 2024

Unrelated but I wanted to ask what specific advantages of PMTiles are you all looking for, for this purpose. Is it simplicity of one file. I'm encountering the issues related to the browser is not caching range requests at all, but it does cache the png tiles fine which helps reduce network traffic. So i'm just trying to understand what benefits the PMTiles format would provide in this use case, besides perhaps performance?

@HarelM
Copy link
Contributor

HarelM commented Dec 18, 2024

I've created the following PR: #359 to allow both replacing the fetch tile and decode image method for local dem manager, which will allow running this plugin in node environment for example.

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

6 participants