Skip to content

Conversation

@etnbrd
Copy link

@etnbrd etnbrd commented Jan 12, 2023

This PR introduces a new parameter ratio to allow drawing rectangular maps.

figsize = tuple(35.1, 49.6)
fig, ax = plt.subplots(figsize=figsize)
plot(
  "Paris",
  ax=ax,
  radius=1000,
  ratio=figsize[0]/figsize[1],
  credit=False,
  layers=layers, # defined elsewhere
  style=style, # defined elsewhere
  preset=None, # needed to avoid overriding the default preset into the provided style and layers
)

image

The ratio part is pretty straightforward, it just updates the perimeter boundary creation to use the introduced ratio parameter.

However, some other parts of the code were written under the assumption that the ratio is 1, these parts needed to be updated as well. The background generation now uses pad and dilate:

  • pad scales the perimeter boundary of a certain amount to generate the background.
  • dilate add a certain amount to the perimeter boundary to generate the background.

In case of a ratio different of 1, using only pad, the margin added to the background are not homogeneous between vertical and horizontal sides. Whereas dilate adds the same amount of margin on all sides.
The default value for pad is set at 1 in the code, but at 1.1 in the presets, to keep the existing behavior.

This PR also reintroduces the dilate parameter in the layers to allow printing some layers outside of others. In the example above, streets and water layers have a dilate value of 100.

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.

1 participant