svgmapviewer-tools-osm 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.
- package/.vscode/settings.json +5 -0
- package/LICENSE +15 -0
- package/__pycache__/common.cpython-312.pyc +0 -0
- package/dist/geojsonToTs.js +15 -0
- package/eslint.config.js +58 -0
- package/oxlintrc.json +4 -0
- package/package.json +35 -0
- package/prettier.config.js +14 -0
- package/rslib.config.ts +22 -0
- package/rstest.config.ts +5 -0
- package/scripts/__pycache__/common.cpython-312.pyc +0 -0
- package/scripts/classifyGeometries.py +56 -0
- package/scripts/common.py +969 -0
- package/scripts/copy.sh +36 -0
- package/scripts/extractAreas.py +41 -0
- package/scripts/extractAreas.sh +20 -0
- package/scripts/extractLinesByIds.py +48 -0
- package/scripts/extractMultiLineStringsByIds.py +48 -0
- package/scripts/extractPointsByIds.py +42 -0
- package/scripts/extractPolygonsByIds.py +42 -0
- package/scripts/geojson2ts.py +79 -0
- package/scripts/getOsm.sh +62 -0
- package/scripts/initQgisPrj.py +44 -0
- package/scripts/makeAreas.py +21 -0
- package/scripts/makeAreas.sh +20 -0
- package/scripts/makeExtent.py +21 -0
- package/scripts/makeMeasures.py +25 -0
- package/scripts/makeOrigin.py +30 -0
- package/scripts/makeViewbox.py +22 -0
- package/scripts/osmconf.ini +122 -0
- package/scripts/pyqgis-Ubuntu.sh +36 -0
- package/scripts/pyqgis-macOS.sh +40 -0
- package/scripts/pyqgis.sh +34 -0
- package/scripts/readOsm.py +37 -0
- package/scripts/readOsm.sh +27 -0
- package/scripts/regen.sh +21 -0
- package/scripts/run-common.sh +3 -0
- package/scripts/tagAddresses.py +51 -0
- package/scripts/update.sh +53 -0
- package/src/geojsonToTs.ts +15 -0
- package/src/lib/geojson/geojson-print.test.ts +60 -0
- package/src/lib/geojson/geojson-print.ts +211 -0
- package/src/lib/geojson/geojson-schema.test.ts +42 -0
- package/src/lib/geojson/geojson-schema.ts +151 -0
- package/src/lib/geojson/geojson-types.ts +116 -0
- package/src/lib/osm.test.ts +17 -0
- package/src/lib/osm.ts +18 -0
- package/src/lib/print-utils.test.ts +12 -0
- package/src/lib/print-utils.ts +22 -0
- package/src/lib/print.ts +122 -0
- package/test/geojson.json +22 -0
- package/tsconfig.app.json +34 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node-browser.json +27 -0
- package/tsconfig.node.json +24 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Configuration file for OSM import
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
# put here the name of keys, or key=value, for ways that are assumed to be polygons if they are closed
|
|
6
|
+
# see http://wiki.openstreetmap.org/wiki/Map_Features
|
|
7
|
+
closed_ways_are_polygons=aeroway,amenity,boundary,building,craft,geological,historic,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism,highway=platform,public_transport=platform
|
|
8
|
+
|
|
9
|
+
# comment to avoid laundering of keys ( ':' turned into '_' )
|
|
10
|
+
attribute_name_laundering=yes
|
|
11
|
+
|
|
12
|
+
# uncomment to report all nodes, including the ones without any (significant) tag
|
|
13
|
+
#report_all_nodes=yes
|
|
14
|
+
|
|
15
|
+
# uncomment to report all ways, including the ones without any (significant) tag
|
|
16
|
+
#report_all_ways=yes
|
|
17
|
+
|
|
18
|
+
[points]
|
|
19
|
+
# common attributes
|
|
20
|
+
osm_id=yes
|
|
21
|
+
osm_version=no
|
|
22
|
+
osm_timestamp=no
|
|
23
|
+
osm_uid=no
|
|
24
|
+
osm_user=no
|
|
25
|
+
osm_changeset=no
|
|
26
|
+
|
|
27
|
+
# keys to report as OGR fields
|
|
28
|
+
attributes=name,barrier,highway,ref,address,is_in,place,man_made
|
|
29
|
+
# keys that, alone, are not significant enough to report a node as a OGR point
|
|
30
|
+
unsignificant=created_by,converted_by,source,time,ele,attribution
|
|
31
|
+
# keys that should NOT be reported in the "other_tags" field
|
|
32
|
+
ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
|
|
33
|
+
# uncomment to avoid creation of "other_tags" field
|
|
34
|
+
#other_tags=no
|
|
35
|
+
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
|
|
36
|
+
#all_tags=yes
|
|
37
|
+
|
|
38
|
+
[lines]
|
|
39
|
+
# common attributes
|
|
40
|
+
osm_id=yes
|
|
41
|
+
osm_version=no
|
|
42
|
+
osm_timestamp=no
|
|
43
|
+
osm_uid=no
|
|
44
|
+
osm_user=no
|
|
45
|
+
osm_changeset=no
|
|
46
|
+
|
|
47
|
+
# keys to report as OGR fields
|
|
48
|
+
attributes=name,highway,waterway,aerialway,barrier,man_made
|
|
49
|
+
|
|
50
|
+
# type of attribute 'foo' can be changed with something like
|
|
51
|
+
#foo_type=Integer/Real/String/DateTime
|
|
52
|
+
|
|
53
|
+
# keys that should NOT be reported in the "other_tags" field
|
|
54
|
+
ignore=created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
|
|
55
|
+
# uncomment to avoid creation of "other_tags" field
|
|
56
|
+
#other_tags=no
|
|
57
|
+
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
|
|
58
|
+
#all_tags=yes
|
|
59
|
+
|
|
60
|
+
#computed_attributes must appear before the keywords _type and _sql
|
|
61
|
+
computed_attributes=z_order
|
|
62
|
+
z_order_type=Integer
|
|
63
|
+
# Formula based on https://github.com/openstreetmap/osm2pgsql/blob/master/style.lua#L13
|
|
64
|
+
# [foo] is substituted by value of tag foo. When substitution is not wished, the [ character can be escaped with \[ in literals
|
|
65
|
+
# Note for GDAL developers: if we change the below formula, make sure to edit ogrosmlayer.cpp since it has a hardcoded optimization for this very precise formula
|
|
66
|
+
z_order_sql="SELECT (CASE [highway] WHEN 'minor' THEN 3 WHEN 'road' THEN 3 WHEN 'unclassified' THEN 3 WHEN 'residential' THEN 3 WHEN 'tertiary_link' THEN 4 WHEN 'tertiary' THEN 4 WHEN 'secondary_link' THEN 6 WHEN 'secondary' THEN 6 WHEN 'primary_link' THEN 7 WHEN 'primary' THEN 7 WHEN 'trunk_link' THEN 8 WHEN 'trunk' THEN 8 WHEN 'motorway_link' THEN 9 WHEN 'motorway' THEN 9 ELSE 0 END) + (CASE WHEN [bridge] IN ('yes', 'true', '1') THEN 10 ELSE 0 END) + (CASE WHEN [tunnel] IN ('yes', 'true', '1') THEN -10 ELSE 0 END) + (CASE WHEN [railway] IS NOT NULL THEN 5 ELSE 0 END) + (CASE WHEN [layer] IS NOT NULL THEN 10 * CAST([layer] AS INTEGER) ELSE 0 END)"
|
|
67
|
+
|
|
68
|
+
[multipolygons]
|
|
69
|
+
# common attributes
|
|
70
|
+
# note: for multipolygons, osm_id=yes instantiates a osm_id field for the id of relations
|
|
71
|
+
# and a osm_way_id field for the id of closed ways. Both fields are exclusively set.
|
|
72
|
+
osm_id=yes
|
|
73
|
+
osm_version=no
|
|
74
|
+
osm_timestamp=no
|
|
75
|
+
osm_uid=no
|
|
76
|
+
osm_user=no
|
|
77
|
+
osm_changeset=no
|
|
78
|
+
|
|
79
|
+
# keys to report as OGR fields
|
|
80
|
+
attributes=name,type,aeroway,amenity,admin_level,barrier,boundary,building,craft,geological,historic,land_area,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism
|
|
81
|
+
# keys that should NOT be reported in the "other_tags" field
|
|
82
|
+
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
|
|
83
|
+
# uncomment to avoid creation of "other_tags" field
|
|
84
|
+
#other_tags=no
|
|
85
|
+
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
|
|
86
|
+
#all_tags=yes
|
|
87
|
+
|
|
88
|
+
[multilinestrings]
|
|
89
|
+
# common attributes
|
|
90
|
+
osm_id=yes
|
|
91
|
+
osm_version=no
|
|
92
|
+
osm_timestamp=no
|
|
93
|
+
osm_uid=no
|
|
94
|
+
osm_user=no
|
|
95
|
+
osm_changeset=no
|
|
96
|
+
|
|
97
|
+
# keys to report as OGR fields
|
|
98
|
+
attributes=name,type
|
|
99
|
+
# keys that should NOT be reported in the "other_tags" field
|
|
100
|
+
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
|
|
101
|
+
# uncomment to avoid creation of "other_tags" field
|
|
102
|
+
#other_tags=no
|
|
103
|
+
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
|
|
104
|
+
#all_tags=yes
|
|
105
|
+
|
|
106
|
+
[other_relations]
|
|
107
|
+
# common attributes
|
|
108
|
+
osm_id=yes
|
|
109
|
+
osm_version=no
|
|
110
|
+
osm_timestamp=no
|
|
111
|
+
osm_uid=no
|
|
112
|
+
osm_user=no
|
|
113
|
+
osm_changeset=no
|
|
114
|
+
|
|
115
|
+
# keys to report as OGR fields
|
|
116
|
+
attributes=name,type
|
|
117
|
+
# keys that should NOT be reported in the "other_tags" field
|
|
118
|
+
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
|
|
119
|
+
# uncomment to avoid creation of "other_tags" field
|
|
120
|
+
#other_tags=no
|
|
121
|
+
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
|
|
122
|
+
#all_tags=yes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
#
|
|
3
|
+
# Usage: ./pyqgis.sh extractAreas.py Gumyoji 'name' '弘明寺'
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
pkgdir=
|
|
7
|
+
if [ -n "$NODE_PATH" ]; then
|
|
8
|
+
paths=$NODE_PATH
|
|
9
|
+
while :; do
|
|
10
|
+
d=${paths%%/node_modules:*}
|
|
11
|
+
paths=${paths#*:}
|
|
12
|
+
[ -e "$d"/package.json ] && pkgdir="$d" && break
|
|
13
|
+
[ "$d"/node_modules = "$paths" ] && echo >&2 'package directory not found!' && exit 1
|
|
14
|
+
done
|
|
15
|
+
else
|
|
16
|
+
pkgdir=$( cd $( dirname $0 ); cd ..; pwd )
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
####
|
|
20
|
+
|
|
21
|
+
tools="$pkgdir"/scripts
|
|
22
|
+
|
|
23
|
+
_exe="/usr/bin/python3"
|
|
24
|
+
|
|
25
|
+
_p="/usr/share/qgis/python"
|
|
26
|
+
_p1=${_p}
|
|
27
|
+
_p2=${_p}/plugins
|
|
28
|
+
_p3=${_p}/plugins/processing
|
|
29
|
+
PYTHONPATH="${_p1}:${_p2}:${_p3}"
|
|
30
|
+
|
|
31
|
+
dir=${0%/*}
|
|
32
|
+
|
|
33
|
+
exec env \
|
|
34
|
+
PYTHONPATH="${PYTHONPATH}" \
|
|
35
|
+
OSM_CONFIG_FILE="${dir}/osmconf.ini" \
|
|
36
|
+
${_exe} $@
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
|
|
3
|
+
pkgdir=
|
|
4
|
+
if [ -n "$NODE_PATH" ]; then
|
|
5
|
+
paths=$NODE_PATH
|
|
6
|
+
while :; do
|
|
7
|
+
d=${paths%%/node_modules:*}
|
|
8
|
+
paths=${paths#*:}
|
|
9
|
+
[ -e "$d"/package.json ] && pkgdir="$d" && break
|
|
10
|
+
[ "$d"/node_modules = "$paths" ] && echo >&2 'package directory not found!' && exit 1
|
|
11
|
+
done
|
|
12
|
+
else
|
|
13
|
+
pkgdir=$( cd $( dirname $0 ); cd ..; pwd )
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
####
|
|
17
|
+
|
|
18
|
+
tools="$pkgdir"/scripts
|
|
19
|
+
|
|
20
|
+
QGIS_PREFIX_PATH="/Applications/QGIS-LTR.app/Contents/MacOS"
|
|
21
|
+
|
|
22
|
+
_bin="${QGIS_PREFIX_PATH}/bin"
|
|
23
|
+
_exe="${_bin}/python3.9"
|
|
24
|
+
|
|
25
|
+
PATH="${_bin}:${PATH}"
|
|
26
|
+
|
|
27
|
+
_p="${QGIS_PREFIX_PATH}/../Resources/python"
|
|
28
|
+
_p1=${_p}
|
|
29
|
+
_p2=${_p}/plugins
|
|
30
|
+
_p3=${_p}/plugins/processing
|
|
31
|
+
PYTHONPATH="${_p1}:${_p2}:${_p3}"
|
|
32
|
+
|
|
33
|
+
GDAL_DATA="${python}/../gdal"
|
|
34
|
+
|
|
35
|
+
exec env -i \
|
|
36
|
+
PATH="${PATH}" \
|
|
37
|
+
QGIS_PREFIX_PATH="${QGIS_PREFIX_PATH}" \
|
|
38
|
+
PYTHONPATH="${PYTHONPATH}" \
|
|
39
|
+
GDAL_DATA="${GDAL_DATA}" \
|
|
40
|
+
${_exe} $@
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env sh
|
|
2
|
+
#
|
|
3
|
+
# Usage: ./pyqgis.sh extractAreas.py Gumyoji 'name' '弘明寺'
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
pkgdir=
|
|
7
|
+
if [ -n "$NODE_PATH" ]; then
|
|
8
|
+
paths=$NODE_PATH
|
|
9
|
+
while :; do
|
|
10
|
+
d=${paths%%/node_modules:*}
|
|
11
|
+
paths=${paths#*:}
|
|
12
|
+
[ -e "$d"/package.json ] && pkgdir="$d" && break
|
|
13
|
+
[ "$d"/node_modules = "$paths" ] && echo >&2 'package directory not found!' && exit 1
|
|
14
|
+
done
|
|
15
|
+
else
|
|
16
|
+
pkgdir=$( cd $( dirname $0 ); cd ..; pwd )
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
####
|
|
20
|
+
|
|
21
|
+
tools="$pkgdir"/scripts
|
|
22
|
+
|
|
23
|
+
_exe="/usr/bin/python3"
|
|
24
|
+
|
|
25
|
+
_p="/usr/share/qgis/python"
|
|
26
|
+
_p1=${_p}
|
|
27
|
+
_p2=${_p}/plugins
|
|
28
|
+
_p3=${_p}/plugins/processing
|
|
29
|
+
PYTHONPATH="${_p1}:${_p2}:${_p3}"
|
|
30
|
+
|
|
31
|
+
exec env \
|
|
32
|
+
PYTHONPATH="${PYTHONPATH}" \
|
|
33
|
+
OSM_CONFIG_FILE="${tools}/osmconf.ini" \
|
|
34
|
+
${_exe} $@
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import glob
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
import common
|
|
6
|
+
|
|
7
|
+
####
|
|
8
|
+
|
|
9
|
+
common.createPrj()
|
|
10
|
+
|
|
11
|
+
areas = common.getAreas()
|
|
12
|
+
internals = common.getInternals()
|
|
13
|
+
|
|
14
|
+
areasLayers = common.readOsmByAreas(areas)
|
|
15
|
+
internalsLayers = common.readOsmByAreas(internals)
|
|
16
|
+
|
|
17
|
+
layernames = [
|
|
18
|
+
x[0] for names in [common.osmLayerNames, common.extraLayerNames]
|
|
19
|
+
for x in names
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
for layername in layernames:
|
|
23
|
+
layers = internalsLayers if layername in { 'points', 'midpoints', 'centroids' } else areasLayers
|
|
24
|
+
layer = common.fixupVectorLayer(layers[layername])
|
|
25
|
+
gj = common.ctx.map_layerGJs[layername]
|
|
26
|
+
common.dumpGeoJSON(layer, gj)
|
|
27
|
+
|
|
28
|
+
####
|
|
29
|
+
|
|
30
|
+
internalsLayers = None
|
|
31
|
+
areasLayers = None
|
|
32
|
+
internals = None
|
|
33
|
+
areas = None
|
|
34
|
+
|
|
35
|
+
common.exit()
|
|
36
|
+
|
|
37
|
+
exit()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
pkgdir=
|
|
4
|
+
if [ -n "$NODE_PATH" ]; then
|
|
5
|
+
paths=$NODE_PATH
|
|
6
|
+
while :; do
|
|
7
|
+
d=${paths%%/node_modules:*}
|
|
8
|
+
paths=${paths#*:}
|
|
9
|
+
[ -e "$d"/package.json ] && pkgdir="$d" && break
|
|
10
|
+
[ "$d"/node_modules = "$paths" ] && echo >&2 'package directory not found!' && exit 1
|
|
11
|
+
done
|
|
12
|
+
else
|
|
13
|
+
pkgdir=$( cd $( dirname $0 ); cd ..; pwd )
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
. ${pkgdir}/scripts/run-common.sh
|
|
17
|
+
|
|
18
|
+
####
|
|
19
|
+
|
|
20
|
+
tools="$pkgdir"/scripts
|
|
21
|
+
|
|
22
|
+
${tools}/pyqgis.sh ${tools}/readOsm.py "$@"
|
|
23
|
+
|
|
24
|
+
(
|
|
25
|
+
cd src/data
|
|
26
|
+
$geojson2ts
|
|
27
|
+
)
|
package/scripts/regen.sh
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
pkgdir=
|
|
4
|
+
if [ -n "$NODE_PATH" ]; then
|
|
5
|
+
paths=$NODE_PATH
|
|
6
|
+
while :; do
|
|
7
|
+
d=${paths%%/node_modules:*}
|
|
8
|
+
paths=${paths#*:}
|
|
9
|
+
[ -e "$d"/package.json ] && pkgdir="$d" && break
|
|
10
|
+
[ "$d"/node_modules = "$paths" ] && echo >&2 'package directory not found!' && exit 1
|
|
11
|
+
done
|
|
12
|
+
else
|
|
13
|
+
pkgdir=$( cd $( dirname $0 ); cd ..; pwd )
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
####
|
|
17
|
+
|
|
18
|
+
tools="$pkgdir"/scripts
|
|
19
|
+
|
|
20
|
+
${tools}/getOsm.sh
|
|
21
|
+
${tools}/pyqgis.sh ${tools}/readOsm.py
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# XXX - Run this just before .ved is processed
|
|
2
|
+
# XXX - Change input to 'buildings.geojson'
|
|
3
|
+
# XXX - Output to 'buildings-tagged.geojson'
|
|
4
|
+
# XXX - Read 'buildings-tagged.geojson' from *.ved
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
prefix = sys.argv[1]
|
|
10
|
+
|
|
11
|
+
prjdir = './%s' % prefix
|
|
12
|
+
datdir = './%s' % prefix
|
|
13
|
+
prjdat = '%s/map.qgz' % prjdir
|
|
14
|
+
|
|
15
|
+
mapdat = '%s/%s-multipolygons.geojson' % (datdir, prefix)
|
|
16
|
+
|
|
17
|
+
addrTmplPrefix = 'A-1f'
|
|
18
|
+
|
|
19
|
+
####
|
|
20
|
+
|
|
21
|
+
import common
|
|
22
|
+
|
|
23
|
+
a1src = '%s/address1.geojson' % datdir
|
|
24
|
+
a2src = '%s/address2.geojson' % datdir
|
|
25
|
+
orgsrc = '%s/origin.geojson' % datdir
|
|
26
|
+
alldst = "%s/all.geojson" % datdir
|
|
27
|
+
|
|
28
|
+
common.openPrj(prjdat)
|
|
29
|
+
|
|
30
|
+
src = common.openVector(mapdat, "multipolygons")
|
|
31
|
+
a1 = common.openVector(a1src, "address1")
|
|
32
|
+
a2 = common.openVector(a2src, "address2")
|
|
33
|
+
buildings = common.filterPolygon(src, '"building" IS NOT NULL')
|
|
34
|
+
|
|
35
|
+
print('Applying address1...')
|
|
36
|
+
out = common.tagAddresses(a1, 'address1', buildings, 'memory:')
|
|
37
|
+
out = common.trimLayer(out)
|
|
38
|
+
print("tagAddress: address1: %d" % out.featureCount())
|
|
39
|
+
|
|
40
|
+
print('Applying address2...')
|
|
41
|
+
out = common.tagAddresses(a2, 'address2', out, 'memory:')
|
|
42
|
+
out = common.trimLayer(out)
|
|
43
|
+
print("tagAddress: address2: %d" % out.featureCount())
|
|
44
|
+
|
|
45
|
+
merged = out
|
|
46
|
+
origin = common.getOrigin(orgsrc)
|
|
47
|
+
common.fixupAttributes(addrTmplPrefix, merged, alldst, origin)
|
|
48
|
+
|
|
49
|
+
common.exit()
|
|
50
|
+
|
|
51
|
+
exit()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
pkgdir=
|
|
4
|
+
if [ -n "$NODE_PATH" ]; then
|
|
5
|
+
paths=$NODE_PATH
|
|
6
|
+
while :; do
|
|
7
|
+
d=${paths%%/node_modules:*}
|
|
8
|
+
paths=${paths#*:}
|
|
9
|
+
[ -e "$d"/package.json ] && pkgdir="$d" && break
|
|
10
|
+
[ "$d"/node_modules = "$paths" ] && echo >&2 'package directory not found!' && exit 1
|
|
11
|
+
done
|
|
12
|
+
else
|
|
13
|
+
pkgdir=$( cd $( dirname $0 ); cd ..; pwd )
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
####
|
|
17
|
+
|
|
18
|
+
tools="$pkgdir"/scripts
|
|
19
|
+
|
|
20
|
+
proc() {
|
|
21
|
+
rm src/*.*
|
|
22
|
+
cp ../${src}/src/*.* src
|
|
23
|
+
: cp ../${src}/vite.* .
|
|
24
|
+
: cp ../${src}/package.json .
|
|
25
|
+
: pnpm install
|
|
26
|
+
#: ../../tools/regen.sh
|
|
27
|
+
pnpm build
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
src=$1 # Expo2025
|
|
31
|
+
|
|
32
|
+
if [ ! -d ${src} ]; then
|
|
33
|
+
echo >&2 "${src} is not a directory"
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
if [ ! -e ${src}/map.osm ]; then
|
|
37
|
+
echo >&2 "${src}/map.osm does not exist?"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
dirs=$( ls -1 */map.osm )
|
|
42
|
+
|
|
43
|
+
for f in ${dirs}; do
|
|
44
|
+
d=${f%%/map.osm}
|
|
45
|
+
name=${d##*/}
|
|
46
|
+
if [ "$name" = "$src" ]; then
|
|
47
|
+
continue
|
|
48
|
+
fi
|
|
49
|
+
pushd $d >/dev/null
|
|
50
|
+
echo $name
|
|
51
|
+
proc
|
|
52
|
+
popd >/dev/null
|
|
53
|
+
done
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable functional/no-expression-statements */
|
|
2
|
+
import { NodeContext, NodeRuntime } from '@effect/platform-node'
|
|
3
|
+
import { Effect } from 'effect'
|
|
4
|
+
|
|
5
|
+
import { convNames, saveAllTs } from './lib/print'
|
|
6
|
+
|
|
7
|
+
// XXX - split other_tags
|
|
8
|
+
|
|
9
|
+
const NodeContextLive = NodeContext.layer
|
|
10
|
+
|
|
11
|
+
const program = Effect.gen(function* () {
|
|
12
|
+
return yield* convNames().pipe(Effect.zip(saveAllTs()))
|
|
13
|
+
}).pipe(Effect.provide(NodeContextLive))
|
|
14
|
+
|
|
15
|
+
NodeRuntime.runMain(program)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Doc } from '@effect/printer'
|
|
2
|
+
import { expect, test } from '@rstest/core'
|
|
3
|
+
import * as fs from 'node:fs'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
isTuple,
|
|
7
|
+
printGeoJSON,
|
|
8
|
+
printProperties,
|
|
9
|
+
truncNumber,
|
|
10
|
+
} from './geojson-print'
|
|
11
|
+
import { _Coordinates, _Properties } from './geojson-types'
|
|
12
|
+
|
|
13
|
+
test('printProperties', () => {
|
|
14
|
+
const p: _Properties = { a: 123, b: 'xyz', c: null }
|
|
15
|
+
const s = Doc.render(printProperties(p), { style: 'pretty' })
|
|
16
|
+
|
|
17
|
+
expect(s).toEqual(`properties: {
|
|
18
|
+
a: 123,
|
|
19
|
+
b: 'xyz',
|
|
20
|
+
c: null,
|
|
21
|
+
},`)
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
test('printGeoJSON', () => {
|
|
25
|
+
exampleGeoJsonFiles.forEach((p) => {
|
|
26
|
+
try {
|
|
27
|
+
const b = fs.readFileSync(p)
|
|
28
|
+
const o = JSON.parse(b.toString())
|
|
29
|
+
const doc = printGeoJSON(o)
|
|
30
|
+
const s = Doc.render(doc, { style: 'pretty' })
|
|
31
|
+
const ma = s.match(/^{/)
|
|
32
|
+
const mb = s.match(/}$/)
|
|
33
|
+
expect(ma !== null).toBe(true)
|
|
34
|
+
expect(mb !== null).toBe(true)
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.error(e)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('truncNumber', () => {
|
|
42
|
+
const n = truncNumber(1.1111111111)
|
|
43
|
+
expect(`${n}`).toBe(`1.111111`)
|
|
44
|
+
const i = truncNumber(123)
|
|
45
|
+
expect(`${i}`).toBe(`123`)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('isTuple', () => {
|
|
49
|
+
const os: readonly _Coordinates[] = [[1, 2]]
|
|
50
|
+
const xs: readonly _Coordinates[] = [
|
|
51
|
+
[
|
|
52
|
+
[1, 2],
|
|
53
|
+
[3, 4],
|
|
54
|
+
],
|
|
55
|
+
]
|
|
56
|
+
os.forEach((o) => expect(isTuple(o)).toBe(true))
|
|
57
|
+
xs.forEach((o) => expect(isTuple(o)).toBe(false))
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const exampleGeoJsonFiles = ['../example-osm/src/data/areas_extent.json']
|