diff --git a/roentgen/constructor.py b/roentgen/constructor.py index 01f69e0..d39e6f5 100644 --- a/roentgen/constructor.py +++ b/roentgen/constructor.py @@ -95,21 +95,21 @@ def glue(ways: list[OSMWay]) -> list[list[OSMNode]]: :param ways: ways to glue """ result: list[list[OSMNode]] = [] - to_process: set[list[OSMNode]] = set() + to_process: set[tuple[OSMNode]] = set() for way in ways: if way.is_cycle(): result.append(way.nodes) else: - to_process.add(way.nodes) + to_process.add(tuple(way.nodes)) while to_process: - nodes: list[OSMNode] = to_process.pop() + nodes: list[OSMNode] = list(to_process.pop()) glued: Optional[list[OSMNode]] = None - other_nodes: Optional[list[OSMNode]] = None + other_nodes: Optional[tuple[OSMNode]] = None for other_nodes in to_process: - glued = try_to_glue(nodes, other_nodes) + glued = try_to_glue(nodes, list(other_nodes)) if glued is not None: break @@ -118,7 +118,7 @@ def glue(ways: list[OSMWay]) -> list[list[OSMNode]]: if is_cycle(glued): result.append(glued) else: - to_process.add(glued) + to_process.add(tuple(glued)) else: result.append(nodes) diff --git a/roentgen/figure.py b/roentgen/figure.py index 2dd054d..6874444 100644 --- a/roentgen/figure.py +++ b/roentgen/figure.py @@ -34,9 +34,8 @@ class Figure(Tagged): inners: list[list[OSMNode]], outers: list[list[OSMNode]], ) -> None: - super().__init__() + super().__init__(tags) - self.tags: dict[str, str] = tags self.inners: list[list[OSMNode]] = list(map(make_clockwise, inners)) self.outers: list[list[OSMNode]] = list( map(make_counter_clockwise, outers) diff --git a/icons/LICENSE b/roentgen/icons/LICENSE similarity index 100% rename from icons/LICENSE rename to roentgen/icons/LICENSE diff --git a/icons/colors.svg b/roentgen/icons/colors.svg similarity index 100% rename from icons/colors.svg rename to roentgen/icons/colors.svg diff --git a/icons/config.json b/roentgen/icons/config.json similarity index 100% rename from icons/config.json rename to roentgen/icons/config.json diff --git a/icons/icons.svg b/roentgen/icons/icons.svg similarity index 100% rename from icons/icons.svg rename to roentgen/icons/icons.svg diff --git a/roentgen/osm_reader.py b/roentgen/osm_reader.py index 0a4b715..b821c1c 100644 --- a/roentgen/osm_reader.py +++ b/roentgen/osm_reader.py @@ -145,6 +145,9 @@ class OSMNode(Tagged): coordinates=np.array((structure["lat"], structure["lon"])), ) + def __hash__(self) -> int: + return self.id_ + @dataclass class OSMWay(Tagged): diff --git a/scheme/default.yml b/roentgen/scheme/default.yml similarity index 100% rename from scheme/default.yml rename to roentgen/scheme/default.yml diff --git a/roentgen/workspace.py b/roentgen/workspace.py index f4c597e..3a78086 100644 --- a/roentgen/workspace.py +++ b/roentgen/workspace.py @@ -6,6 +6,8 @@ from pathlib import Path __author__ = "Sergey Vartanov" __email__ = "me@enzet.ru" +HERE: Path = Path(__file__).parent + def check_and_create(directory: Path) -> Path: """Create directory if it doesn't exist and return it.""" @@ -21,12 +23,11 @@ class Workspace: # Project directories and files, that are the part of the repository. - SCHEME_PATH: Path = Path("scheme") + SCHEME_PATH: Path = HERE / Path("scheme") DEFAULT_SCHEME_PATH: Path = SCHEME_PATH / "default.yml" - ICONS_PATH: Path = Path("icons/icons.svg") - ICONS_CONFIG_PATH: Path = Path("icons/config.json") + ICONS_PATH: Path = HERE / Path("icons/icons.svg") + ICONS_CONFIG_PATH: Path = HERE / Path("icons/config.json") GITHUB_TEST_PATH: Path = Path(".github/workflows/test.yml") - DATA_PATH: Path = Path("data") # Generated directories and files. diff --git a/setup.py b/setup.py index fca09bb..54dd113 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name="roentgen-map", - version="0.1.1", + version="0.1.2", packages=["roentgen"], url="https://github.com/enzet/Roentgen", project_urls={ @@ -26,6 +26,14 @@ setup( entry_points={ "console_scripts": ["roentgen=roentgen.main:main"], }, + package_data={ + "roentgen": [ + "icons/icons.svg", + "icons/config.json", + "icons/LICENSE", + "scheme/default.yml", + ], + }, python_requires=">=3.9", install_requires=[ "CairoSVG>=2.5.0",