svgmapviewer-tools-floors 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +15 -0
  2. package/inkscape/extensions/Attic/fix_guides.inx +17 -0
  3. package/inkscape/extensions/Attic/fix_guides.py +30 -0
  4. package/inkscape/extensions/Attic/fix_symbol_links.inx +17 -0
  5. package/inkscape/extensions/Attic/fix_symbol_links.py +71 -0
  6. package/inkscape/extensions/Attic/flatten_style.inx +17 -0
  7. package/inkscape/extensions/Attic/flatten_style.py +31 -0
  8. package/inkscape/extensions/Attic/load_markers.inx +17 -0
  9. package/inkscape/extensions/Attic/load_markers.py +117 -0
  10. package/inkscape/extensions/Attic/load_patterns.inx +17 -0
  11. package/inkscape/extensions/Attic/load_patterns.py +116 -0
  12. package/inkscape/extensions/Attic/load_symbols.inx +17 -0
  13. package/inkscape/extensions/Attic/load_symbols.py +164 -0
  14. package/inkscape/extensions/Attic/renumber_tree.inx +24 -0
  15. package/inkscape/extensions/Attic/renumber_tree.py +39 -0
  16. package/inkscape/extensions/Attic/repeat_path.inx +17 -0
  17. package/inkscape/extensions/Attic/repeat_path.py +58 -0
  18. package/inkscape/extensions/Attic/resolve_facility_links.inx +19 -0
  19. package/inkscape/extensions/Attic/resolve_facility_links.py +16 -0
  20. package/inkscape/extensions/Attic/sort_symbols.inx +17 -0
  21. package/inkscape/extensions/Attic/sort_symbols.py +48 -0
  22. package/inkscape/extensions/Attic/symbol_load.inx +17 -0
  23. package/inkscape/extensions/Attic/symbol_load.py +99 -0
  24. package/inkscape/extensions/Attic/tidy_tree.inx +22 -0
  25. package/inkscape/extensions/Attic/tidy_tree.py +178 -0
  26. package/inkscape/extensions/Attic/use_shop.inx +22 -0
  27. package/inkscape/extensions/Attic/use_shop.py +26 -0
  28. package/inkscape/extensions/README.md +34 -0
  29. package/inkscape/extensions/daijimaps/__init__.py +72 -0
  30. package/inkscape/extensions/daijimaps/address_tree.py +231 -0
  31. package/inkscape/extensions/daijimaps/common.py +49 -0
  32. package/inkscape/extensions/daijimaps/generate_addresses.py +41 -0
  33. package/inkscape/extensions/daijimaps/guards.py +47 -0
  34. package/inkscape/extensions/daijimaps/map_layer.py +47 -0
  35. package/inkscape/extensions/daijimaps/name.py +167 -0
  36. package/inkscape/extensions/daijimaps/renumber.py +38 -0
  37. package/inkscape/extensions/daijimaps/resolve_labels.py +65 -0
  38. package/inkscape/extensions/daijimaps/resolve_names.py +170 -0
  39. package/inkscape/extensions/daijimaps/save_addresses.py +274 -0
  40. package/inkscape/extensions/daijimaps/types.py +128 -0
  41. package/inkscape/extensions/daijimaps/visit_parents.py +37 -0
  42. package/inkscape/extensions/extract_labels.py +79 -0
  43. package/inkscape/extensions/fixup_floor_svg.py +28 -0
  44. package/inkscape/extensions/fixup_texts.inx +15 -0
  45. package/inkscape/extensions/fixup_texts.py +110 -0
  46. package/inkscape/extensions/fixup_tree.inx +15 -0
  47. package/inkscape/extensions/fixup_tree.py +17 -0
  48. package/inkscape/extensions/flatten_transform.inx +17 -0
  49. package/inkscape/extensions/flatten_transform.py +63 -0
  50. package/inkscape/extensions/import_labels.inx +20 -0
  51. package/inkscape/extensions/import_labels.py +52 -0
  52. package/inkscape/extensions/import_shops.inx +20 -0
  53. package/inkscape/extensions/import_shops.py +47 -0
  54. package/inkscape/extensions/install.sh +14 -0
  55. package/inkscape/extensions/load_shops.inx +20 -0
  56. package/inkscape/extensions/load_shops.py +86 -0
  57. package/inkscape/extensions/renumber_group.inx +15 -0
  58. package/inkscape/extensions/renumber_group.py +17 -0
  59. package/inkscape/extensions/resolve_labels.inx +20 -0
  60. package/inkscape/extensions/resolve_labels.py +142 -0
  61. package/inkscape/extensions/resolve_shops.inx +20 -0
  62. package/inkscape/extensions/resolve_shops.py +73 -0
  63. package/inkscape/extensions/unresolve_labels.inx +20 -0
  64. package/inkscape/extensions/unresolve_labels.py +53 -0
  65. package/inkscape/extensions/unresolve_shops.inx +20 -0
  66. package/inkscape/extensions/unresolve_shops.py +56 -0
  67. package/inkscape/templates/floors.svg +665 -0
  68. package/map-extract-floors.js +821 -0
  69. package/package.json +19 -0
  70. package/pyproject.toml +20 -0
  71. package/scripts/inkex-inkscape +14 -0
  72. package/scripts/inkex-python +14 -0
  73. package/scripts/inkex-setup +6 -0
  74. package/scripts/labels.sh +18 -0
  75. package/scripts/regen.py +77 -0
  76. package/scripts/regen.sh +24 -0
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "svgmapviewer-tools-floors",
3
+ "version": "0.0.1",
4
+ "bin": {
5
+ "svgmapviewer-tools-floors-inkex-inkscape": "./scripts/inkex-inkscape",
6
+ "svgmapviewer-tools-floors-inkex-python": "./scripts/inkex-python",
7
+ "svgmapviewer-tools-floors-labels": "./scripts/labels.sh",
8
+ "svgmapviewer-tools-floors-regen": "./scripts/regen.sh"
9
+ },
10
+ "type": "module",
11
+ "devDependencies": {
12
+ "html-react-parser": "^5.2.17"
13
+ },
14
+ "lint-staged": {
15
+ "*.{ts,tsx}": "eslint --fix",
16
+ "*": "oxfmt --write"
17
+ },
18
+ "scripts": {}
19
+ }
package/pyproject.toml ADDED
@@ -0,0 +1,20 @@
1
+ [project]
2
+ name = "svgmapviewer-tools-floors"
3
+ version = "0.1.0"
4
+ requires-python = ">=3.12"
5
+
6
+ dependencies = [
7
+ "cssselect>=1.3.0",
8
+ "lxml>=6.0.2",
9
+ "lxml-stubs>=0.5.1",
10
+ "numpy>=2.4.1",
11
+ "pyparsing>=3.3.2",
12
+ "pytest>=9.0.2",
13
+ "requests>=2.32.5",
14
+ "scribus>=0.1.3",
15
+ "tinycss2>=1.5.1",
16
+ "zstandard>=0.25.0",
17
+ ]
18
+
19
+ [tool.ruff]
20
+ exclude = ["inkex"]
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+
3
+ scriptsdir=$( dirname $0 )
4
+ pkgdir=$( dirname $scriptsdir )
5
+
6
+ ####
7
+
8
+ tools="$pkgdir"/scripts
9
+
10
+ export UV_PROJECT="$pkgdir"
11
+
12
+ . "$tools"/inkex-setup
13
+
14
+ env PYTHONPATH="${extensions}" uv run inkscape "$@"
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+
3
+ scriptsdir=$( dirname $0 )
4
+ pkgdir=$( dirname $scriptsdir )
5
+
6
+ ####
7
+
8
+ tools="$pkgdir"/scripts
9
+
10
+ export UV_PROJECT="$pkgdir"
11
+
12
+ . "$tools"/inkex-setup
13
+
14
+ env PYTHONPATH="${extensions}" uv run python "$@"
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ export inkscape_extensions=$( inkscape --system-data-directory )/extensions
4
+
5
+ export PYTHONPATH="$inkscape_extensions"
6
+
@@ -0,0 +1,18 @@
1
+ #!/bin/sh
2
+
3
+ scriptsdir=$( dirname $0 )
4
+ pkgdir=$( dirname $scriptsdir )
5
+
6
+ ####
7
+
8
+ tools="$pkgdir"/scripts
9
+
10
+ export UV_PROJECT="$pkgdir"
11
+
12
+ . "$tools"/inkex-setup
13
+
14
+ #extensions="$pkgdir"/inkscape/extensions
15
+ extensions=$( inkscape --user-data-directory)/extensions
16
+
17
+ uv sync
18
+ uv run python "$extensions"/extract_labels.py ./src/data/map.svg > ./src/data/floors-labels.json
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import json
4
+ import os
5
+ import subprocess
6
+
7
+ DATA_DIR = "./src/data"
8
+ ASSETS_DIR = "./src/assets"
9
+
10
+ MAP_SVG = f"{DATA_DIR}/map.svg"
11
+
12
+ FLOORS_JSON = f"{DATA_DIR}/floors.json"
13
+
14
+ floors = {}
15
+
16
+ ####
17
+
18
+ def xopenR(p):
19
+ return open(p, 'r', encoding="utf-8")
20
+
21
+ def xopenW(p):
22
+ return open(p, 'w', encoding="utf-8")
23
+
24
+ def xload(p):
25
+ with xopenR(p) as f:
26
+ return json.load(f)
27
+
28
+ def xdump(j, p):
29
+ with xopenW(p) as f:
30
+ json.dump(j, f, indent=2, ensure_ascii=False)
31
+
32
+ def split_floor_svg(floor: str, id: str) -> None:
33
+ subprocess.run(['inkscape', '-j', '-i', id, '-o', f"{ASSETS_DIR}/floor-{floor}.svg", MAP_SVG])
34
+
35
+ def fixup_floor_svg(floor: str) -> None:
36
+ # XXX
37
+ # XXX
38
+ # XXX
39
+ pass
40
+
41
+ ####
42
+
43
+ def collect_floors():
44
+ return xload(FLOORS_JSON)
45
+
46
+ def split_floors():
47
+ os.makedirs(ASSETS_DIR, exist_ok=True)
48
+ for k, v in dict(floors).items():
49
+ print(f"k={k} v={v}")
50
+ id = v['contentId']
51
+ split_floor_svg(k, id)
52
+ fixup_floor_svg(k)
53
+
54
+ def collect_addresses():
55
+ addresses = {}
56
+ for floor in dict(floors):
57
+ try:
58
+ addresses[floor] = xload(f"{DATA_DIR}/floors-addresses-{floor}.json")
59
+ except:
60
+ continue
61
+ xdump(addresses, f"{DATA_DIR}/floors-addresses.json")
62
+
63
+ def collect_names():
64
+ names = {}
65
+ for floor in dict(floors):
66
+ try:
67
+ names[floor] = xload(f"{DATA_DIR}/floors-names-{floor}.json")
68
+ except:
69
+ continue
70
+ xdump(names, f"{DATA_DIR}/floors-names.json")
71
+
72
+ ####
73
+
74
+ floors = collect_floors()
75
+ split_floors()
76
+ collect_addresses()
77
+ collect_names()
@@ -0,0 +1,24 @@
1
+ #!/bin/sh
2
+
3
+ scriptsdir=$( dirname $0 )
4
+ pkgdir=$( dirname $scriptsdir )
5
+
6
+ ####
7
+
8
+ tools="$pkgdir"/scripts
9
+
10
+ export UV_PROJECT="$pkgdir"
11
+
12
+ . "$tools"/inkex-setup
13
+
14
+ extensions="$pkgdir"/inkscape/extensions
15
+
16
+ uv sync
17
+ uv run python ${tools}/regen.py
18
+ for f in ./src/assets/floor-*.svg; do
19
+ echo "fixup $f..."
20
+ cp $f $f.orig
21
+ uv run python "$extensions"/fixup_floor_svg.py $f.orig >$f.tmp
22
+ uv run inkscape -l $f.tmp -o $f
23
+ done
24
+ "$tools"/labels.sh ./src/data/map.svg > ./src/data/floors-labels.json