Skip to content

Commit dcc92de

Browse files
committed
Refactor the project to support Röntgen 0.10.0.
- Remove icon files and methods, use Röntgen instead. - Replace complex icons with simple ones in `default.yml` scheme. - Remove Röntgen documentation.
1 parent ae967eb commit dcc92de

34 files changed

Lines changed: 574 additions & 34140 deletions

‎README.md‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ will automatically download OSM data and render PNG tiles that cover the specifi
4040

4141
The central feature of the project is the Röntgen icon set. It is a set of monochrome 14 × 14 px pixel-aligned icons specially created for the Map Machine project. Unlike the Map Machine source code, which is under the MIT license, all icons are under the [CC BY](https://creativecommons.org/licenses/by/4.0/) license. So, with the appropriate credit the icon set can be used outside the project. Some icons can be used as emoji symbols.
4242

43-
All icons tend to support a common design style, which is heavily inspired by [Maki](https://github.com/mapbox/maki), [Osmic](https://github.com/gmgeo/osmic), and [Temaki](https://github.com/ideditor/temaki).
44-
45-
![Icons](doc/grid.svg)
46-
47-
Feel free to request new icons via issues for whatever you want to see on the map. No matter how frequently the tag is used in OpenStreetMap since the final goal is to cover all tags. However, commonly used tags have priority, other things being equal.
48-
49-
Generate an icon grid and sets of individual icons with `map-machine icons`. It will update the `doc/grid.svg` file, and create SVG files in the `out/icons_by_id` directory where files are named using shape identifiers (e.g. `power_tower_portal_2_level.svg`) and in the `icons_by_name` directory where files are named using shape names (e.g. `Röntgen portal two-level transmission tower.svg`). Files from the last directory are used in the OpenStreetMap wiki (e.g. [`File:Röntgen_portal_two-level_transmission_tower.svg`](https://wiki.openstreetmap.org/wiki/File:R%C3%B6ntgen_portal_two-level_transmission_tower.svg)).
50-
5143
## Map features
5244

5345
### Extra icons

‎doc/grid.svg‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎doc/moi/readme.moi‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ will automatically download OSM data and render PNG tiles that cover the specifi
3333

3434
The central feature of the project is the Röntgen icon set. It is a set of monochrome 14 × 14 px pixel-aligned icons specially created for the Map Machine project. Unlike the Map Machine source code, which is under the MIT license, all icons are under the \ref {https://creativecommons.org/licenses/by/4.0/} {CC BY} license. So, with the appropriate credit the icon set can be used outside the project. Some icons can be used as emoji symbols.
3535

36-
All icons tend to support a common design style, which is heavily inspired by \ref {https://github.com/mapbox/maki} {Maki}, \ref {https://github.com/gmgeo/osmic} {Osmic}, and \ref {https://github.com/ideditor/temaki} {Temaki}.
37-
38-
\image {doc/grid.svg} {Icons}
39-
40-
Feel free to request new icons via issues for whatever you want to see on the map. No matter how frequently the tag is used in OpenStreetMap since the final goal is to cover all tags. However, commonly used tags have priority, other things being equal.
41-
42-
Generate an icon grid and sets of individual icons with \m {\command {icons}}. It will update the \m {doc/grid.svg} file, and create SVG files in the \m {out/icons_by_id} directory where files are named using shape identifiers (e.g. \m {power_tower_portal_2_level.svg}) and in the \m {icons_by_name} directory where files are named using shape names (e.g. \m {Röntgen portal two-level transmission tower.svg}). Files from the last directory are used in the OpenStreetMap wiki (e.g. \ref {https://wiki.openstreetmap.org/wiki/File:R%C3%B6ntgen_portal_two-level_transmission_tower.svg} {\m {File:Röntgen_portal_two-level_transmission_tower.svg}}).
43-
4436
\2 {Map features} {map-features}
4537

4638
\3 {Extra icons} {extra-icons}

‎map_machine/constructor.py‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
import numpy as np
1111
from colour import Color
12+
from roentgen import IconSpecification
13+
from roentgen.icon import ShapeSpecification
1214

1315
from map_machine.color import get_gradient_color
1416
from map_machine.feature.building import BUILDING_SCALE, Building
@@ -26,14 +28,7 @@
2628
Tags,
2729
parse_levels,
2830
)
29-
from map_machine.pictogram.icon import (
30-
DEFAULT_SMALL_SHAPE_ID,
31-
Icon,
32-
IconSet,
33-
Shape,
34-
ShapeExtractor,
35-
ShapeSpecification,
36-
)
31+
from map_machine.pictogram.icon import IconSet
3732
from map_machine.pictogram.point import Point
3833
from map_machine.scheme import LineStyle, RoadMatcher, Scheme
3934
from map_machine.text import Label, TextConstructor
@@ -59,6 +54,8 @@
5954
Color("#FFC300"),
6055
Color("#DAF7A6"),
6156
]
57+
DEFAULT_SHAPE_ID: str = "default"
58+
DEFAULT_SMALL_SHAPE_ID: str = "default_small"
6259

6360

6461
def line_center(
@@ -162,13 +159,11 @@ def __init__(
162159
self,
163160
osm_data: OSMData,
164161
flinger: Flinger,
165-
extractor: ShapeExtractor,
166162
configuration: MapConfiguration,
167163
) -> None:
168164
self.osm_data: OSMData = osm_data
169165
self.flinger: Flinger = flinger
170166
self.scheme: Scheme = configuration.scheme
171-
self.extractor: ShapeExtractor = extractor
172167
self.configuration: MapConfiguration = configuration
173168
self.text_constructor: TextConstructor = TextConstructor(self.scheme)
174169

@@ -319,7 +314,7 @@ def construct_line(
319314
priority: int
320315
icon_set: IconSet | None
321316
icon_set, priority = self.configuration.get_icon(
322-
self.extractor, line.tags, processed
317+
line.tags, processed
323318
)
324319
if icon_set is not None:
325320
labels: list[Label] = self.text_constructor.construct_text(
@@ -365,9 +360,7 @@ def add_point_for_line(
365360
processed: set[str] = set()
366361
priority: int
367362
icon_set: IconSet | None
368-
icon_set, priority = self.configuration.get_icon(
369-
self.extractor, line.tags, processed
370-
)
363+
icon_set, priority = self.configuration.get_icon(line.tags, processed)
371364
if icon_set is not None:
372365
labels: list[Label] = self.text_constructor.construct_text(
373366
line.tags, processed, self.configuration.label_mode
@@ -476,11 +469,14 @@ def construct_node(self, node: OSMNode) -> None:
476469
if self.configuration.drawing_mode == DrawingMode.TIME:
477470
color = get_time_color(node.timestamp, self.osm_data.time)
478471

479-
dot: Shape = self.extractor.get_shape(DEFAULT_SMALL_SHAPE_ID)
480472
icon_set = IconSet(
481-
Icon([ShapeSpecification(dot, color)]),
473+
IconSpecification(
474+
"", [ShapeSpecification(DEFAULT_SHAPE_ID, color=color)], ""
475+
),
482476
[],
483-
Icon([ShapeSpecification(dot, color)]),
477+
IconSpecification(
478+
"", [ShapeSpecification(DEFAULT_SHAPE_ID, color=color)], ""
479+
),
484480
set(),
485481
)
486482
point = Point(
@@ -506,9 +502,7 @@ def construct_node(self, node: OSMNode) -> None:
506502
color = Color("#CCCCCC")
507503
if self.configuration.drawing_mode == DrawingMode.BLACK:
508504
color = Color("#444444")
509-
icon_set, priority = self.configuration.get_icon(
510-
self.extractor, tags, processed
511-
)
505+
icon_set, priority = self.configuration.get_icon(tags, processed)
512506
if icon_set is not None:
513507
icon_set.main_icon.recolor(color)
514508
point = Point(
@@ -522,9 +516,7 @@ def construct_node(self, node: OSMNode) -> None:
522516
self.points.append(point)
523517
return
524518

525-
icon_set, priority = self.configuration.get_icon(
526-
self.extractor, tags, processed
527-
)
519+
icon_set, priority = self.configuration.get_icon(tags, processed)
528520
if icon_set is None:
529521
return
530522

‎map_machine/doc/doc_collections.py‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@
99

1010
import numpy as np
1111
import svgwrite
12+
from roentgen import get_roentgen
1213
from svgwrite import Drawing
1314

1415
from map_machine.map_configuration import MapConfiguration
15-
from map_machine.pictogram.icon import IconSet, ShapeExtractor
1616
from map_machine.scheme import Scheme
1717
from map_machine.workspace import Workspace
1818

1919
if TYPE_CHECKING:
20+
from roentgen import Roentgen
2021
from svgwrite.shapes import Line, Rect
2122
from svgwrite.text import Text
2223

2324
from map_machine.osm.osm_reader import Tags
25+
from map_machine.pictogram.icon import IconSet
26+
27+
roentgen: Roentgen = get_roentgen()
2428

2529
WORKSPACE: Workspace = Workspace(Path("temp"))
2630

2731
SCHEME: Scheme = Scheme.from_file(WORKSPACE.DEFAULT_SCHEME_PATH)
28-
EXTRACTOR: ShapeExtractor = ShapeExtractor(
29-
WORKSPACE.ICONS_PATH, WORKSPACE.ICONS_CONFIG_PATH
30-
)
3132
MONOSPACE_FONTS: list[str] = [
3233
"JetBrains Mono",
3334
"Fira Code",
@@ -140,7 +141,7 @@ def draw_table(self) -> None:
140141
current_tags |= {self.collection.column_key: column_value}
141142
processed: set[str] = set()
142143
icon, _ = MapConfiguration(SCHEME).get_icon(
143-
EXTRACTOR, current_tags, processed
144+
current_tags, processed
144145
)
145146
if not icon:
146147
continue
@@ -251,7 +252,9 @@ def draw_icon(self, position: np.ndarray, icon: IconSet) -> None:
251252
if not self.collection.column_values:
252253
self.collection.column_values = [""]
253254
point: np.ndarray = np.array(self.start_point) + position * self.step
254-
icon.main_icon.draw(self.svg, point, scale=self.icon_size / 16.0)
255+
icon.main_icon.draw(
256+
self.svg, roentgen.get_shapes(), point, scale=self.icon_size / 16.0
257+
)
255258

256259
def draw_text(
257260
self,

‎map_machine/doc/icons.py‎

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,31 @@
33
from __future__ import annotations
44

55
from pathlib import Path
6-
from typing import TYPE_CHECKING, Callable
6+
from typing import Callable
77

88
from colour import Color
9+
from roentgen import Roentgen, get_roentgen
10+
from roentgen.icon import IconSpecification, Shape, ShapeSpecification
911

10-
from map_machine.pictogram.icon import (
11-
Icon,
12-
Shape,
13-
ShapeExtractor,
14-
ShapeSpecification,
15-
)
1612
from map_machine.pictogram.icon_collection import IconCollection
17-
from map_machine.workspace import workspace
18-
19-
if TYPE_CHECKING:
20-
from collections.abc import Iterable
2113

2214
SKIP: bool = True
2315
BLACK: Color = Color("black")
2416

2517

18+
roentgen: Roentgen = get_roentgen()
19+
20+
2621
def draw_special_grid(
27-
all_shapes: Iterable[Shape],
22+
all_shapes: dict[str, Shape],
2823
function: Callable[[Shape], bool],
2924
path: Path,
3025
color: Color | None = None,
3126
) -> None:
3227
"""Draw special icon grid to illustrate map feature."""
33-
icons: list[Icon] = [
34-
Icon([ShapeSpecification(shape, BLACK)])
35-
for shape in all_shapes
28+
icons: list[IconSpecification] = [
29+
IconSpecification("", [ShapeSpecification(shape_id)], "")
30+
for shape_id, shape in all_shapes.items()
3631
if function(shape)
3732
]
3833
icons.sort()
@@ -46,10 +41,7 @@ def draw_special_grid(
4641

4742
def draw_special_grids() -> None:
4843
"""Draw special icon grids."""
49-
extractor: ShapeExtractor = ShapeExtractor(
50-
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
51-
)
52-
all_shapes: Iterable[Shape] = extractor.shapes.values()
44+
all_shapes: dict[str, Shape] = roentgen.get_shapes().shapes
5345

5446
draw_special_grid(
5547
all_shapes,

‎map_machine/doc/preview.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from map_machine.mapper import Map
2323
from map_machine.osm.osm_getter import get_osm
2424
from map_machine.osm.osm_reader import OSMData
25-
from map_machine.pictogram.icon import ShapeExtractor
2625
from map_machine.scheme import Scheme
2726
from map_machine.workspace import workspace
2827

@@ -32,9 +31,6 @@
3231
cache.mkdir(exist_ok=True)
3332

3433
SCHEME: Scheme = Scheme.from_file(workspace.DEFAULT_SCHEME_PATH)
35-
EXTRACTOR: ShapeExtractor = ShapeExtractor(
36-
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
37-
)
3834

3935
REMOVED: bool = True
4036

@@ -54,9 +50,7 @@ def draw(
5450
flinger: MercatorFlinger = MercatorFlinger(
5551
bounding_box, configuration.zoom_level, osm_data.equator_length
5652
)
57-
constructor: Constructor = Constructor(
58-
osm_data, flinger, EXTRACTOR, configuration
59-
)
53+
constructor: Constructor = Constructor(osm_data, flinger, configuration)
6054
constructor.construct()
6155

6256
svg: svgwrite.Drawing = svgwrite.Drawing(

‎map_machine/doc/wiki.py‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
from typing import TYPE_CHECKING
88

99
from map_machine.map_configuration import MapConfiguration
10-
from map_machine.pictogram.icon import Icon, ShapeExtractor
1110
from map_machine.scheme import Scheme
1211
from map_machine.workspace import Workspace
1312

1413
if TYPE_CHECKING:
14+
from roentgen.icon import IconSpecification
15+
1516
from map_machine.doc.doc_collections import Collection
1617

1718
WORKSPACE: Workspace = Workspace(Path("temp"))
1819

1920
SCHEME: Scheme = Scheme.from_file(WORKSPACE.DEFAULT_SCHEME_PATH)
20-
EXTRACTOR: ShapeExtractor = ShapeExtractor(
21-
WORKSPACE.ICONS_PATH, WORKSPACE.ICONS_CONFIG_PATH
22-
)
2321

2422
HEADER_PATTERN: re.Pattern = re.compile("==?=?.*==?=?")
2523
HEADER_2_PATTERN: re.Pattern = re.compile("== .* ==")
@@ -41,9 +39,9 @@ def __init__(self, collection: Collection, page_name: str) -> None:
4139
self.collection: Collection = collection
4240
self.page_name: str = page_name
4341

44-
def generate_wiki_table(self) -> tuple[str, list[Icon]]:
42+
def generate_wiki_table(self) -> tuple[str, list[IconSpecification]]:
4543
"""Generate Röntgen icon table for the OpenStreetMap wiki page."""
46-
icons: list[Icon] = []
44+
icons: list[IconSpecification] = []
4745
text: str = '{| class="wikitable"\n'
4846

4947
if self.collection.column_key is not None:
@@ -66,9 +64,7 @@ def generate_wiki_table(self) -> tuple[str, list[Icon]]:
6664
text += "\n"
6765
icon, _ = MapConfiguration(
6866
SCHEME, ignore_level_matching=True
69-
).get_icon(
70-
EXTRACTOR, current_tags | self.collection.tags, set()
71-
)
67+
).get_icon(current_tags | self.collection.tags, set())
7268
if icon:
7369
icons.append(icon.main_icon)
7470
text += (
@@ -109,9 +105,7 @@ def generate_wiki_table(self) -> tuple[str, list[Icon]]:
109105
}
110106
if column_value and self.collection.column_key:
111107
current_tags |= {self.collection.column_key: column_value}
112-
icon, _ = MapConfiguration(SCHEME).get_icon(
113-
EXTRACTOR, current_tags, set()
114-
)
108+
icon, _ = MapConfiguration(SCHEME).get_icon(current_tags, set())
115109
if icon:
116110
text += (
117111
"| [[Image:Röntgen "
@@ -127,22 +121,22 @@ def generate_wiki_table(self) -> tuple[str, list[Icon]]:
127121
def generate_new_text(
128122
old_text: str,
129123
table: WikiTable,
130-
) -> tuple[str | None, list[Icon]]:
124+
) -> tuple[str | None, list[IconSpecification]]:
131125
"""Generate Röntgen icon table for the OpenStreetMap wiki page.
132126
133127
:param old_text: previous wiki page text
134128
:param table: wiki table generator
135129
:return: new wiki page text
136130
"""
137131
wiki_text: str
138-
icons: list[Icon] = []
132+
icons: list[IconSpecification] = []
139133

140134
if table.collection.row_key or table.collection.row_tags:
141135
wiki_text, icons = table.generate_wiki_table()
142136
else:
143137
processed: set[str] = set()
144138
icon, _ = MapConfiguration(SCHEME).get_icon(
145-
EXTRACTOR, table.collection.tags, processed
139+
table.collection.tags, processed
146140
)
147141
if icon and not icon.main_icon.is_default():
148142
wiki_text = (

‎map_machine/element/grid.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
OSMWay,
2020
Tags,
2121
)
22-
from map_machine.pictogram.icon import ShapeExtractor
2322
from map_machine.scheme import Scheme
2423
from map_machine.workspace import Workspace
2524

@@ -28,9 +27,6 @@
2827
workspace: Workspace = Workspace(Path("temp"))
2928

3029
SCHEME: Scheme = Scheme.from_file(workspace.DEFAULT_SCHEME_PATH)
31-
SHAPE_EXTRACTOR: ShapeExtractor = ShapeExtractor(
32-
workspace.ICONS_PATH, workspace.ICONS_CONFIG_PATH
33-
)
3430
DEFAULT_ZOOM: float = 18.0
3531

3632

@@ -113,7 +109,7 @@ def draw(self, output_path: Path) -> None:
113109
)
114110
svg: Drawing = Drawing(output_path.name, size)
115111
constructor: Constructor = Constructor(
116-
self.osm_data, flinger, SHAPE_EXTRACTOR, configuration
112+
self.osm_data, flinger, configuration
117113
)
118114
constructor.construct()
119115
map_: Map = Map(flinger, svg, configuration)

0 commit comments

Comments
 (0)