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

Deal with edge case of zero length paths. #147

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

RadostW
Copy link

@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.

@@ -50,12 +50,12 @@ def parse_float(string: str) -> Optional[float]:

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.

@@ -174,6 +174,9 @@ def __init__(self, tags: dict[str, str], point: np.ndarray) -> None:

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.

@@ -531,7 +531,12 @@ def draw(self, svg: Drawing, is_border: bool) -> None:
filter_: Filter = self.get_filter(svg, is_border)

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.

@@ -104,8 +104,13 @@ def __init__(

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).

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