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

Minimal pmtiles http support #370

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

acalcutt
Copy link

@acalcutt acalcutt commented Jan 2, 2025

This adds minimal pmtiles support to the web plugin as requested in #212 . It is a lite version of the changes I made in https://github.com/acalcutt/maplibre-contour-pmtiles/ without the local pmtiles support.

-Changes-
Adds support for pmtiles:// urls, so these are valid urls now

https://url/of/dem/source/{z}/{x}/{y}.png
pmtiles://https://url/of/dem/source.pmtiles

In #359 support was added to add a GetTile function, but this function only was passing url, which made it hard to use for things that needed the zxy values, since you had to split them out of the url. I have modified this a bit some it now passes

(
    z: number,
    x: number,
    y: number,
    demUrlPattern: string,
    abortController: AbortController,
    pmtiles?: PMTiles | null,
  )

Tests have keen updated to use the new "cacheKey" value instead of url. The GetTile mock function also had to be changed since different values are now passed.

Copy link
Contributor

@msbarry msbarry left a comment

Choose a reason for hiding this comment

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

Hey - sorry I missed this when you first put it out! I think it would be great to have working pmtiles support in this repo, but I don't want it to increase the bundle size for web users that don't need it. Would it be feasible to make this a separate entrypoint you can import to get pmtiles support?

Also is this intended to be used from a web browser or node/server environment? If it's the latter we're fine, but if it's the former we should probably also make the change that lets you use a tile fetching function when using a web worker.

@acalcutt
Copy link
Author

acalcutt commented Jan 21, 2025

This is intended to allow http:// pmtiles use with the web plugin, though it would also allow http pmtiles locally with node.

It also expands the GetTile function to pass xyz values so local pmtiles support can be added without having to add a function make a function to scrape xyz from the url, like I had to do in contour_generatror

@acalcutt
Copy link
Author

acalcutt commented Jan 21, 2025

I was trying to get the current solution to work without changes here
https://stackblitz.com/edit/web-platform-nacc3caw?file=index.html

but if I remember right, DemSource did not yet support a custom GetTiles yet. Also, if i switched it to LocalDemManager, then the demSource.setupMaplibre(maplibregl) was not available.

It probably could work if Demsource did let you replace GetTiles also... The other question I had was passing the pmtiles object, but I think as long as it gets defined before the GetTiles function it might work.

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.

2 participants