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 Digitransit vector map source #683

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tpikonen
Copy link

Add DIGITRANSIT_KEY API key. Replace the API key placeholder in url_suffix (not needed here, but why not) and style_json values in the map definition.

The vector map definitions fetched from api.digitransit.fi patch the API key given in the digitransit-subscription-key request parameter given to it to the tile URLs, so we cannot use url_suffix, because this then appends the API key twice.

A somehow working solution is to use style_json in the map source with the JSON fetched from https://raw.githubusercontent.com/HSLdevcom/hsl-map-style/master/style.json and edited to add the API key parameter only to the base vector map URL (also edited to remove some other vector sources).

Since this is an ugly hack, I'm not at all sure if this should be merged, especially since the amount of users this is likely to have is small. But, if you disagree, I can mark this as ready.

@rinigus
Copy link
Owner

rinigus commented Sep 16, 2024

It is a touch ugly hack, indeed. What if we

That way we will be able to update the style without releases (for example if some URL changes internally).

process_style was met for adding language support, but adding keys there make sense as well.

Is it better? Or kinda hacky as well :)

@tpikonen
Copy link
Author

Is it better? Or kinda hacky as well :)

That's certainly better than the current state of this PR.

I tried implementing this, but apparently MapboxGL / Maplibre loads all the resources from the style before their URLs can be modified in process_style python function, so a simple implementation did not work.

This could be worked around here by loading the URL contents in python, modifying it and the setting the style as a string to map.styleJson, but maybe there's an easier way?

@rinigus
Copy link
Owner

rinigus commented Sep 17, 2024

I tried implementing this, but apparently MapboxGL / Maplibre loads all the resources from the style before their URLs can be modified in process_style python function, so a simple implementation did not work.

I was expecting that it would still get to process_style, but maybe an error is triggered before. I wonder if we need to make some separate option for map style to be fetched from URL via python before applying the style. it just has to be done via bg call - have to check if it runs already accordingly in the code or has to be set to do so in QML when new style is loaded

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