enzet / map-machine

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

Custom schemes #140

Open mfbehrens opened 2 years ago

mfbehrens commented 2 years ago

Hello, is there a specific reason why there is no parameter to set a scheme path. I would suggest to use --scheme <path>. Default path would be the default scheme. Any problems with that?

enzet commented 2 years ago

No problems at all, I should definitely add this option.

The scheme format however is still under development and not documented. If you want to create custom scheme, please feel free to ask questions.

mfbehrens commented 2 years ago

Definitively, do not really understand it. Just tried an empty scheme and I failed. I only added the color definition from the default scheme in what made the program work. However, there are still a lot of objects on the map. Shouldn't an empty scheme result in an empty map?

enzet commented 2 years ago

I only added the color definition from the default scheme in what made the program work.

This is indeed a bug. Totally empty scheme file should work. I'll fix it.

Shouldn't an empty scheme result in an empty map?

Hmm... Looks like very legal assumption.

Honestly, I never thought about such a use case. Map Machine just tries to render everything no matter how and this behavior isn't manageable through scheme file.

mfbehrens commented 2 years ago

Still throws an error message :(


(.env) C:\Users\mfbeh\Documents\Github\map-machine>map-machine render -b=8.4214801253,49.0197665932,8.4230425121,49.0205831971 -z=21 --scheme=map_machine/scheme/empty.yml
Traceback (most recent call last):
  File "C:\Users\mfbeh\Documents\Github\map-machine\.env\Scripts\map-machine-script.py", line 33, in <module>
    sys.exit(load_entry_point('map-machine', 'console_scripts', 'map-machine')())
  File "c:\users\mfbeh\documents\github\map-machine\map_machine\main.py", line 44, in main
    mapper.render_map(arguments)
  File "c:\users\mfbeh\documents\github\map-machine\map_machine\mapper.py", line 270, in render_map
    scheme: Scheme = Scheme.from_file(scheme_path)
  File "c:\users\mfbeh\documents\github\map-machine\map_machine\scheme.py", line 375, in from_file
    return cls(content)
  File "c:\users\mfbeh\documents\github\map-machine\map_machine\scheme.py", line 319, in __init__
    if "node_icons" in content:
TypeError: argument of type 'NoneType' is not iterable```
enzet commented 2 years ago

Hm, seems like YAML failed to load the file. Could you please dump the content of map_machine/scheme/empty.yml?

Update: oh, I see, it is just totally empty, which is presumably a valid YAML file. I'll check this.