Skip to content

Deal with edge case of zero length paths.#147

Merged
enzet merged 3 commits intoenzet:mainfrom
RadostW:main
Nov 17, 2025
Merged

Deal with edge case of zero length paths.#147
enzet merged 3 commits intoenzet:mainfrom
RadostW:main

Conversation

@RadostW
Copy link
Contributor

@RadostW RadostW commented Jan 6, 2023

When cropping larger OSM datasets sometimes paths with zero nodes are formed.
Such paths break path -> svg code.

Checking for len < 2 resolves this problem.

Copy link
Owner

@enzet enzet left a comment

Choose a reason for hiding this comment

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

Hello, @RadostW,

I am really sorry for not responding so much time. I had a rough time doing pet projects.

Thank you for your contribution! It means a lot! If you are still interesting in the project, could you please take a look at the review.

def parse_levels(string: str) -> list[float]:
"""Parse string representation of level sequence value."""
# TODO: add `-` parsing
# TODO: add `-` parsing
Copy link
Owner

Choose a reason for hiding this comment

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

Running black -l 80 map_machine will fix this.

if address:
texts.append(self.label(", ".join(address)))

# if name:
Copy link
Owner

Choose a reason for hiding this comment

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

Feel free to remove this part.


def draw(self, svg: Drawing, scheme) -> None:
"""Draw gradient sector."""

Copy link
Owner

Choose a reason for hiding this comment

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

If sectors are drawn incorrectly, we should disable them with the option.


style: dict[str, Union[int, float, str]] = self.get_style(is_border)
path_commands: str = self.line.get_path(self.placement_offset)

Copy link
Owner

Choose a reason for hiding this comment

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

We can do

if (path_commands := self.line.get_path(self.placement_offset) == None:
    return

and the same for other tmp_d variables.


def draw(self, svg: Drawing, flinger: Flinger) -> None:
"""Draw simple building shape."""

Copy link
Owner

Choose a reason for hiding this comment

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

There is a comment below about tmp_ variables. We can nicely avoid them.

@enzet
Copy link
Owner

enzet commented Jul 5, 2023

Checks had failed mostly because of style issues. The project uses Black style formatter. To apply Black style, one have to simply run

black -l 80 map_machine

with the Black installed (pip install black).

@enzet enzet merged commit ef3b49d into enzet:main Nov 17, 2025
2 checks passed
@enzet
Copy link
Owner

enzet commented Nov 17, 2025

@RadostW Thank you for the PR. I'm really sorry for pushing into your fork's main.

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