Move data files; fix way combination.

This commit is contained in:
Sergey Vartanov 2021-09-03 03:37:51 +03:00
parent c53b257aaf
commit 173a553877
10 changed files with 24 additions and 13 deletions

View file

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

View file

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

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Before After
Before After

View file

@ -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):

View file

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

View file

@ -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",