-
Notifications
You must be signed in to change notification settings - Fork 20
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
Improve bounds management #22
Comments
That's a valid point. I will look into it. |
Thank you very much. As I said, if you think that you won't have the time to do it, maybe you can guide me (with some links on how the math works to get the zoom, and how we could get the new output dimensions for instance) |
I haven't looked into the code in detail, just read through the text of pull request #19, but I suspect that it tried to solve the same issue. |
Thanks for your comment, it seems that indeed, it tries to solve the same issue, however it's done only for non-svg outputs, it's done by cropping the image using the min and max X and Y of the rendered objects, which (I think) won't work with SVGs |
Hello @flopp and @qlereboursBS, as far as I understand the code:
|
Hello @flopp and @qlereboursBS, I have coded a different approach for svg:
You can check it out at my branch https://github.com/lowtower/py-staticmaps/tree/feature/tighten_to_bounds Drawbacks up to now:
Questions:
I'll have a look at cairo and pillow as well if this is of interest |
I'm also interested in the "precision" of the bounds for cairo output in particular. |
Hello @netvandal, I am afraid, I don't get Your point. In my example above, the map image is "tightened" to the given boundary - plus the "extra" boundaries for the marker object. BTW: the afore mentioned branch in my fork doesn't exist any more, but the feature is included in the main branch, not "master". Cheers, |
Description
Currently, if you generate a SVG based on bounds, it will contain more than just the bounds you gave, because we have to specify output width and height, and also because zoom level are integers.
It would be awesome be able to let the program choose the output size based on the given bounds (or have a minWidth, minHeight instead).
Current behavior:
The code:
Output file looks like this:
SVG file available here:
https://mega.nz/file/wtdARJwJ#4bXTgySf9vcmBBCnliu3blbkRoLW2hTIEcipWPbs4tg
When given bounds are:
Expected behavior
I think that we should be able to call the
render_svg
method with minWidth and minHeight arguments which would let the program choose a better zoom level, to perfectly fit the bounds.Here is how it could work:
I would be ok to work on it, I already tried to do a first version but the mathematics used in the
context._determine_zoom
function are complicated, I don't know the formulas and I'm not sure to understand the variables.I know that I can return
return self._clamp_zoom(zoom)
instead ofreturn self._clamp_zoom(zoom - 1)
but I don't know how to determine the output size.The text was updated successfully, but these errors were encountered: