enzet / map-machine

Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
MIT License
503 stars 31 forks source link

Don't render random tag values with `--labels main` #122

Closed BudgieInWA closed 2 years ago

BudgieInWA commented 2 years ago

I want to be able to render a map with only labels for feature names (or equivalent). When I use --labels main, I also get unwanted random tag values (from the is_writable list): usually survey:date dates all over the place.

I was able to fix it with these lines at https://github.com/enzet/map-machine/blob/1f4fb66c85720476b7a30138b0da51a10d6a48e8/map_machine/scheme.py#L609

  def construct_text(
          self, tags: Tags, processed: set[str], label_mode: LabelMode
      ) -> list[Label]:
          """Construct labels for not processed tags."""
          texts: list[Label] = self.text_constructor.construct_text(
              tags, processed, label_mode
          )

+         if label_mode == LabelMode.MAIN:
+             return texts

          for tag in tags:
              if self.is_writable(tag, tags[tag]) and tag not in processed:
                  texts.append(
                      Label(
                          tags[tag],
                          self.get_color("text_color"),
                          self.get_color("text_outline_color"),
                      )
                  )
          return texts
enzet commented 2 years ago

Yes, you're right.

Patch looks good for me. Do you want to create pull request or should I fix it myself?

BudgieInWA commented 2 years ago

You can do it yourself however is easiest. :)

enzet commented 2 years ago

Hello, @BudgieInWA. I think I've fixed this issue, but will continue with the #67.

Can I close this?