-
Notifications
You must be signed in to change notification settings - Fork 49
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
[heatmap] Optionally use map as background #10
Comments
wow ... nice! |
Very nice. I already have some experience with static maps: https://github.com/flopp/go-staticmaps ;) |
Hello, |
@lowtower it would still be nice to have this feature. One could certainly use https://github.com/flopp/py-staticmaps to generate the background image. |
I have already had a look at py-staticmaps (which btw. is also mentioned at the osm staticmaps website). |
btw: |
@lowtower you're right, cairo is heavy - i already thought about making it an optional dependency of py-staticmaps (e.g. use it only if it's available). Anyway, I'm glad you're taking the initiative on this issue! |
@flopp |
@lowtower I'm about to add a PIL-based renderer - this is more lightweight than Cairo, but has no anti-aliasing |
@flopp I have a first working version of the background staticmap feature. |
@lowtower the results look nice! For a final version the background image should be embedded into the SVG (to have a single output file) I guess. |
Reminder to myself: |
Somehow, I feel like the cropping should be done in the py-staticmaps. |
Hm, py-staticmaps should create the desired image size - so that no cropping is necessary in GpxTrackPoster. |
Maybe, I understood something fundamentally wrong. |
The image size is as desired, but the boundaries get an additional border/margin. I ran the example draw_gpx.py. |
A different approach would be to take the map from py-staticmaps as is and scale the tracks afterwards. Pro:
Con:
Shall I rather continue with this approach? |
I think it woud be nice, because user can choose with map or not. |
That's true for both variants. |
WIP: First version of second variant (not pixel perfect yet): |
Hello,
Cheers, |
@lowtower that's cool |
@flopp @yihong0618 Cheers, |
@lowtower agree~ |
@lowtower Thanks for working on this! Just tried your current branch and it looks promising. Is there anything missing or is it nearly production ready? I see that your required changes for And is there a special reason why |
Hello @laufhannes, thanks for the reply and testing.
As far as I remember, I was not fully satisfied with my solution.
Cairo is available in pystaticmaps. I haven't and don't get cairo installed on my machine. Could possibly be made optional then.
I don't remember - I have to look into this. I am quite busy at the moment, but will look into it quite soon Cheers, |
Hello @laufhannes,
A very large pixel size results in large images and an increased time to fetch the tile.
I have added an option to chose the renderer in py-staticmaps, available are "pillow" (default) and "cairo". Cheers, |
That's right. |
I have made a correction in cairo output - should be working now. If You want to test it, You have to update the py-staticmaps library to latest source from github - as You said above, by now no new version has been pushed: Cheers, |
I was planning on doing a pr myself, but I realized that those providers are not free for commercial applications (I was interested in Stadia.AlidadeSmooth, Stadia.AlidadeSmoothDark, Jawg.Dark, Jawg.Light, CartoDB.Positron, CartoDB.PositronNoLabels, CartoDB.DarkMatter, see https://leaflet-extras.github.io/leaflet-providers/preview/). For our usecase we probably need to use a custom provider, that means we'd need to set a provider dynamically withing GpxTrackPoster. Not sure if that's possible with py-staticmaps. But now I know how to use a custom py-staticmaps fork.
Yes, that looks fine. Though, the only difference I see is the rendering of copyright notice, which looks much smoother with cairo. |
Hello @laufhannes,
The Carto Maps with labels could be added. Cheers, P.S.:
|
Depending on the heatmap's size, it may be nice to see at least some basic map in the background.
I have a first working solution with laufhannes@ebb0823 and laufhannes/staticmaplite@3758e11, but that's not perfect. The main part within this repo is to calculate lat/lng bounds of the visible part. Afterwards, a static map is requested, saved locally and inserted. (Without saving it locally, inkscape is not able to embed the image when converting to png)
The staticmaplite repo is written in php, but it should be possible to transform it into python. Using Google Maps Static may even be better (but requires an API key; in general free for non-commercial and low traffic apps), as it's possible to individually style the map. I created one first try for such a style at snazzy maps.
If using Google Maps, calculation of the required zoom level and cropping the image (or calculating the exact size) has to be done within this repo.
As this testing has been done in my local runalyze-environment, the example is decorated with our brandings ;)
And I guess this needs some additional padding within the draw area to not let tracks touch the border.
The text was updated successfully, but these errors were encountered: