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
package/scripts/copy.sh
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
orig=$1
|
|
21
|
+
shift
|
|
22
|
+
dirs=$@
|
|
23
|
+
|
|
24
|
+
for d in ${dirs}; do
|
|
25
|
+
cd ${orig}
|
|
26
|
+
mkdir -p ../${d}/src/data
|
|
27
|
+
cp *.html *.json *.ts ../${d}
|
|
28
|
+
cp src/*.* ../${d}/src
|
|
29
|
+
cd $OLDPWD
|
|
30
|
+
cd ${d}
|
|
31
|
+
pnpm install
|
|
32
|
+
${tools}/getOsm.sh
|
|
33
|
+
${tools}/makeAreas.sh
|
|
34
|
+
${tools}/readOsm.sh
|
|
35
|
+
cd $OLDPWD
|
|
36
|
+
done
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
3
|
+
import os.path
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
args = sys.argv
|
|
8
|
+
args.pop(0)
|
|
9
|
+
|
|
10
|
+
import common
|
|
11
|
+
|
|
12
|
+
common.openPrj()
|
|
13
|
+
|
|
14
|
+
####
|
|
15
|
+
|
|
16
|
+
mapLayers = common.readOsmAll()
|
|
17
|
+
s = mapLayers['multipolygons']
|
|
18
|
+
|
|
19
|
+
olayers = []
|
|
20
|
+
while len(args) > 0:
|
|
21
|
+
field = args[0]
|
|
22
|
+
pattern = args[1]
|
|
23
|
+
args.pop(0)
|
|
24
|
+
args.pop(0)
|
|
25
|
+
|
|
26
|
+
l = common.extractFields(s, "polygon", field, pattern)
|
|
27
|
+
olayers.append(l)
|
|
28
|
+
|
|
29
|
+
l = common.mergeVectorLayers(olayers, 'memory:')
|
|
30
|
+
common.dumpGeoJSON(l, common.ctx.areasGJ)
|
|
31
|
+
|
|
32
|
+
####
|
|
33
|
+
|
|
34
|
+
l = None
|
|
35
|
+
olayers = None
|
|
36
|
+
s = None
|
|
37
|
+
mapLayers = None
|
|
38
|
+
|
|
39
|
+
common.exit()
|
|
40
|
+
|
|
41
|
+
exit()
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
exec ${tools}/pyqgis.sh ${tools}/extractAreas.py "$@"
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#! /Applications/QGIS3.14.app/Contents/MacOS/bin/python
|
|
2
|
+
|
|
3
|
+
import pathlib
|
|
4
|
+
import os
|
|
5
|
+
import os.path
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
prefix = sys.argv[1]
|
|
11
|
+
field = sys.argv[2]
|
|
12
|
+
args = sys.argv
|
|
13
|
+
args.pop(0)
|
|
14
|
+
args.pop(0)
|
|
15
|
+
args.pop(0)
|
|
16
|
+
|
|
17
|
+
patterns = list(map(lambda x: '^%s$' % x, args))
|
|
18
|
+
pattern = '|'.join(patterns)
|
|
19
|
+
# pattern = '^123$|^456$'
|
|
20
|
+
|
|
21
|
+
nums = list(map(lambda x: '\'%s\'' % x, args))
|
|
22
|
+
exp = '"%s" IN (%s)' % (field, ', '.join(nums))
|
|
23
|
+
#exp = '"osm_id" = \'200164093\'' # (%s)' % (', '.join(nums))
|
|
24
|
+
#exp = '"osm_id" IS NOT NULL'
|
|
25
|
+
#exp = '"osm_id" = \'200164093\''
|
|
26
|
+
print('exp', exp)
|
|
27
|
+
|
|
28
|
+
docdir = '/Users/uebayasi/Documents'
|
|
29
|
+
prjdir = '%s/Sources/DaijiMaps/QGIS' % docdir
|
|
30
|
+
datdir = '%s/Sources/DaijiMaps/daijimaps-data/%s' % (docdir, prefix)
|
|
31
|
+
prjdat = '%s/%s.qgz' % (prjdir, prefix)
|
|
32
|
+
|
|
33
|
+
areasGJ = '%s/areas.geojson' % datdir
|
|
34
|
+
|
|
35
|
+
####
|
|
36
|
+
|
|
37
|
+
import common
|
|
38
|
+
|
|
39
|
+
srcGJ = '%s/%s-%s.geojson' % (datdir, 'init', 'lines')
|
|
40
|
+
s = common.openVector(srcGJ, 'init-lines')
|
|
41
|
+
#d = common.extractFields(s, "MultiLineString", field, pattern)
|
|
42
|
+
d = common.filterMultiLineString(s, exp)
|
|
43
|
+
#d = common.mergeVectorLayers([d], 'memory:')
|
|
44
|
+
common.dumpGeoJSON(d, '%s/tmp-lines.geojson' % datdir)
|
|
45
|
+
|
|
46
|
+
common.exit()
|
|
47
|
+
|
|
48
|
+
exit()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#! /Applications/QGIS3.14.app/Contents/MacOS/bin/python
|
|
2
|
+
|
|
3
|
+
import pathlib
|
|
4
|
+
import os
|
|
5
|
+
import os.path
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
prefix = sys.argv[1]
|
|
11
|
+
field = sys.argv[2]
|
|
12
|
+
args = sys.argv
|
|
13
|
+
args.pop(0)
|
|
14
|
+
args.pop(0)
|
|
15
|
+
args.pop(0)
|
|
16
|
+
|
|
17
|
+
patterns = list(map(lambda x: '^%s$' % x, args))
|
|
18
|
+
pattern = '|'.join(patterns)
|
|
19
|
+
# pattern = '^123$|^456$'
|
|
20
|
+
|
|
21
|
+
nums = list(map(lambda x: '\'%s\'' % x, args))
|
|
22
|
+
exp = '"osm_id" IN (%s)' % (', '.join(nums))
|
|
23
|
+
#exp = '"osm_id" = \'200164093\'' # (%s)' % (', '.join(nums))
|
|
24
|
+
#exp = '"osm_id" IS NOT NULL'
|
|
25
|
+
#exp = '"osm_id" = \'200164093\''
|
|
26
|
+
print('exp', exp)
|
|
27
|
+
|
|
28
|
+
docdir = '/Users/uebayasi/Documents'
|
|
29
|
+
prjdir = '%s/Sources/DaijiMaps/QGIS' % docdir
|
|
30
|
+
datdir = '%s/Sources/DaijiMaps/daijimaps-data/%s' % (docdir, prefix)
|
|
31
|
+
prjdat = '%s/%s.qgz' % (prjdir, prefix)
|
|
32
|
+
|
|
33
|
+
areasGJ = '%s/areas.geojson' % datdir
|
|
34
|
+
|
|
35
|
+
####
|
|
36
|
+
|
|
37
|
+
import common
|
|
38
|
+
|
|
39
|
+
srcGJ = '%s/%s-%s.geojson' % (datdir, 'init', 'multilinestrings')
|
|
40
|
+
s = common.openVector(srcGJ, 'init-lines')
|
|
41
|
+
#d = common.extractFields(s, "MultiLineString", field, pattern)
|
|
42
|
+
d = common.filterMultiLineString(s, exp)
|
|
43
|
+
#d = common.mergeVectorLayers([d], 'memory:')
|
|
44
|
+
common.dumpGeoJSON(d, '%s/tmp-multilinestrings.geojson' % datdir)
|
|
45
|
+
|
|
46
|
+
common.exit()
|
|
47
|
+
|
|
48
|
+
exit()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#! /Applications/QGIS3.14.app/Contents/MacOS/bin/python
|
|
2
|
+
|
|
3
|
+
import pathlib
|
|
4
|
+
import os
|
|
5
|
+
import os.path
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
prefix = sys.argv[1]
|
|
11
|
+
field = sys.argv[2]
|
|
12
|
+
args = sys.argv
|
|
13
|
+
args.pop(0)
|
|
14
|
+
args.pop(0)
|
|
15
|
+
args.pop(0)
|
|
16
|
+
|
|
17
|
+
patterns = list(map(lambda x: '^%s$' % x, args))
|
|
18
|
+
pattern = '|'.join(patterns)
|
|
19
|
+
# pattern = '^123$|^456$'
|
|
20
|
+
|
|
21
|
+
docdir = '/Users/uebayasi/Documents'
|
|
22
|
+
prjdir = '%s/Sources/DaijiMaps/QGIS' % docdir
|
|
23
|
+
datdir = '%s/Sources/DaijiMaps/daijimaps-data/%s' % (docdir, prefix)
|
|
24
|
+
prjdat = '%s/%s.qgz' % (prjdir, prefix)
|
|
25
|
+
|
|
26
|
+
areasGJ = '%s/areas.geojson' % datdir
|
|
27
|
+
|
|
28
|
+
####
|
|
29
|
+
|
|
30
|
+
import common
|
|
31
|
+
|
|
32
|
+
srcGJ = '%s/%s-%s.geojson' % (datdir, 'init', 'points')
|
|
33
|
+
s = common.openVector(srcGJ, 'init-points')
|
|
34
|
+
d = common.extractFields(s, "Point", field, pattern)
|
|
35
|
+
#d = common.mergeVectorLayers([d], 'memory:')
|
|
36
|
+
common.dumpGeoJSON(d, '%s/tmp-points.geojson' % datdir)
|
|
37
|
+
|
|
38
|
+
# origin: bottom-right -> top-left -> x2
|
|
39
|
+
|
|
40
|
+
common.exit()
|
|
41
|
+
|
|
42
|
+
exit()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#! /Applications/QGIS3.14.app/Contents/MacOS/bin/python
|
|
2
|
+
|
|
3
|
+
import pathlib
|
|
4
|
+
import os
|
|
5
|
+
import os.path
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
prefix = sys.argv[1]
|
|
11
|
+
field = sys.argv[2]
|
|
12
|
+
args = sys.argv
|
|
13
|
+
args.pop(0)
|
|
14
|
+
args.pop(0)
|
|
15
|
+
args.pop(0)
|
|
16
|
+
|
|
17
|
+
patterns = list(map(lambda x: '^%s$' % x, args))
|
|
18
|
+
pattern = '|'.join(patterns)
|
|
19
|
+
# pattern = '^123$|^456$'
|
|
20
|
+
|
|
21
|
+
docdir = '/Users/uebayasi/Documents'
|
|
22
|
+
prjdir = '%s/Sources/DaijiMaps/QGIS' % docdir
|
|
23
|
+
datdir = '%s/Sources/DaijiMaps/daijimaps-data/%s' % (docdir, prefix)
|
|
24
|
+
prjdat = '%s/%s.qgz' % (prjdir, prefix)
|
|
25
|
+
|
|
26
|
+
areasGJ = '%s/areas.geojson' % datdir
|
|
27
|
+
|
|
28
|
+
####
|
|
29
|
+
|
|
30
|
+
import common
|
|
31
|
+
|
|
32
|
+
srcGJ = '%s/%s-%s.geojson' % (datdir, 'init', 'multipolygons')
|
|
33
|
+
s = common.openVector(srcGJ, 'init-multipolygons')
|
|
34
|
+
d = common.extractFields(s, "Polygon", field, pattern)
|
|
35
|
+
#d = common.mergeVectorLayers([d], 'memory:')
|
|
36
|
+
common.dumpGeoJSON(d, '%s/tmp-polygons.geojson' % datdir)
|
|
37
|
+
|
|
38
|
+
# origin: bottom-right -> top-left -> x2
|
|
39
|
+
|
|
40
|
+
common.exit()
|
|
41
|
+
|
|
42
|
+
exit()
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#! /usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# XXX node ts
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import re
|
|
9
|
+
|
|
10
|
+
type_pat = re.compile('^(.*)<(.*)>$')
|
|
11
|
+
|
|
12
|
+
geojsons = {
|
|
13
|
+
'areas': 'MultiPolygonGeoJSON',
|
|
14
|
+
'internals': 'MultiPolygonGeoJSON',
|
|
15
|
+
'origin': 'PointGeoJSON',
|
|
16
|
+
'measures': 'LineGeoJSON<MeasureProperties>',
|
|
17
|
+
'viewbox': 'LineGeoJSON',
|
|
18
|
+
|
|
19
|
+
'map-points': 'OsmPointGeoJSON',
|
|
20
|
+
'map-lines': 'OsmLineGeoJSON',
|
|
21
|
+
'map-multilinestrings': 'OsmMultiLineStringGeoJSON',
|
|
22
|
+
'map-multipolygons': 'OsmMultiPolygonGeoJSON',
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
def printObjectAsTs(o, ofile):
|
|
26
|
+
if type(o) == str:
|
|
27
|
+
ofile.write('"%s"\n' % o.replace('"', '\\"'))
|
|
28
|
+
elif type(o) == int:
|
|
29
|
+
ofile.write('%d\n' % o)
|
|
30
|
+
elif type(o) == float:
|
|
31
|
+
ofile.write('%f\n' % o)
|
|
32
|
+
elif type(o) == type(None):
|
|
33
|
+
ofile.write('null\n')
|
|
34
|
+
elif type(o) == list:
|
|
35
|
+
ofile.write('[\n')
|
|
36
|
+
for (e) in o:
|
|
37
|
+
printObjectAsTs(e, ofile)
|
|
38
|
+
ofile.write(',\n')
|
|
39
|
+
ofile.write(']\n')
|
|
40
|
+
elif type(o) == dict:
|
|
41
|
+
ofile.write('{\n')
|
|
42
|
+
for k in o:
|
|
43
|
+
ofile.write('%s: ' % k)
|
|
44
|
+
printObjectAsTs(o[k], ofile)
|
|
45
|
+
ofile.write(',\n')
|
|
46
|
+
ofile.write('}\n')
|
|
47
|
+
|
|
48
|
+
for _geojson in geojsons:
|
|
49
|
+
_name = _geojson.replace('map-', '')
|
|
50
|
+
_type = geojsons[_geojson]
|
|
51
|
+
try:
|
|
52
|
+
with open('%s.json' % _geojson, 'r') as file:
|
|
53
|
+
data = json.load(file)
|
|
54
|
+
with open('%s.ts' % _geojson, 'w') as ofile:
|
|
55
|
+
res = type_pat.match(_type)
|
|
56
|
+
if res is None:
|
|
57
|
+
ofile.write('import { type %s } from "svgmapviewer/geo"\n' % _type)
|
|
58
|
+
else:
|
|
59
|
+
ofile.write('import { type %s, type %s } from "svgmapviewer/geo"\n' % (res.group(1), res.group(2)))
|
|
60
|
+
ofile.write('\n')
|
|
61
|
+
ofile.write('export const %s: %s = \n' % (_name, _type))
|
|
62
|
+
printObjectAsTs(data, ofile)
|
|
63
|
+
ofile.write('\n')
|
|
64
|
+
ofile.write('export default %s\n' % _name)
|
|
65
|
+
|
|
66
|
+
except FileNotFound:
|
|
67
|
+
print("%s.json not found" % _name)
|
|
68
|
+
|
|
69
|
+
# write all.ts
|
|
70
|
+
with open('all.ts', 'w') as ofile:
|
|
71
|
+
for _geojson in geojsons:
|
|
72
|
+
_name = _geojson.replace('map-', '')
|
|
73
|
+
ofile.write('import %s from "./%s"\n' % (_name, _geojson))
|
|
74
|
+
ofile.write('\n')
|
|
75
|
+
ofile.write('export const mapData = {\n')
|
|
76
|
+
for _geojson in geojsons:
|
|
77
|
+
_name = _geojson.replace('map-', '')
|
|
78
|
+
ofile.write('%s,\n' % (_name))
|
|
79
|
+
ofile.write('}\n')
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# XXX rewrite this in python
|
|
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
|
+
# Take bbox and get map.osm
|
|
21
|
+
getByBounds() {
|
|
22
|
+
osm=$1; shift
|
|
23
|
+
# left, bottom, right, top
|
|
24
|
+
bbox=$( echo $@ | sed -e 's,^ ,,; s, *$,,; s/ /,/g' )
|
|
25
|
+
url="https://api.openstreetmap.org/api/0.6/map?bbox=${bbox}"
|
|
26
|
+
wget -O ${osm}.tmp "$url" || curl -o ${osm}.tmp "$url" || exit 1
|
|
27
|
+
# XXX fixup-map-osm-exe ${osm}.tmp ${osm}
|
|
28
|
+
cp ${osm}.tmp ${osm}
|
|
29
|
+
rm -f ${osm}.tmp
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Take map.osm, parse its <bounds>, and get the bbox
|
|
33
|
+
getByFile() {
|
|
34
|
+
osm=$1
|
|
35
|
+
eval $(
|
|
36
|
+
sed -ne '/^ *<bounds / {
|
|
37
|
+
# <bounds minlat="-36.8650000" minlon="174.7183000" maxlat="-36.8601000" maxlon="174.7242000"/>
|
|
38
|
+
s,^ *<bounds ,,
|
|
39
|
+
s,/>$,,
|
|
40
|
+
p
|
|
41
|
+
# minlat="-36.8650000" minlon="174.7183000" maxlat="-36.8601000" maxlon="174.7242000"
|
|
42
|
+
}' <$osm
|
|
43
|
+
)
|
|
44
|
+
# left, bottom, right, top
|
|
45
|
+
getByBounds $osm $minlon $minlat $maxlon $maxlat
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if [ $# -eq 0 ]; then
|
|
49
|
+
osms=$( echo map*.osm )
|
|
50
|
+
case $osms in
|
|
51
|
+
*\**)
|
|
52
|
+
echo 'map*.osm not found!' >&2
|
|
53
|
+
exit 1
|
|
54
|
+
;;
|
|
55
|
+
esac
|
|
56
|
+
set -- $osms
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
while [ $# -gt 0 ]; do
|
|
60
|
+
getByFile $1
|
|
61
|
+
shift
|
|
62
|
+
done
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import glob
|
|
2
|
+
import pathlib
|
|
3
|
+
import os
|
|
4
|
+
import os.path
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
import common
|
|
8
|
+
|
|
9
|
+
####
|
|
10
|
+
|
|
11
|
+
common.createPrj()
|
|
12
|
+
|
|
13
|
+
def osm2gj(osm, layername):
|
|
14
|
+
name = common.path2name(osm)
|
|
15
|
+
return '%s/tmp-%s-%s.geojson' % (common.ctx.prjdir, name, layername)
|
|
16
|
+
|
|
17
|
+
print('Expanding .osm layers...', file = sys.stderr)
|
|
18
|
+
for osm in common.osmFiles:
|
|
19
|
+
name = common.path2name(osm)
|
|
20
|
+
for (layername, _) in common.osmLayerNames:
|
|
21
|
+
outGJ = osm2gj(osm, layername)
|
|
22
|
+
print('Expanding %s:%s...' % (osm, layername), file = sys.stderr)
|
|
23
|
+
common.expandOsm(osm, layername, name, outGJ)
|
|
24
|
+
|
|
25
|
+
print('Merging .geojson...', file = sys.stderr)
|
|
26
|
+
rects = {}
|
|
27
|
+
for (layername, typ) in common.osmLayerNames:
|
|
28
|
+
olayers = list(map(lambda osm: osm2gj(osm, layername), common.osmFiles))
|
|
29
|
+
out = common.mergeVectors(olayers, layername)
|
|
30
|
+
rects[layername] = common.getBoundingBox(out)
|
|
31
|
+
mapdat = '%s/%s-%s.geojson' % (common.ctx.prjdir, 'map', layername)
|
|
32
|
+
common.dumpGeoJSON(out, mapdat)
|
|
33
|
+
|
|
34
|
+
#rect = rects['multipolygons']
|
|
35
|
+
#common.createEmptyPolygonGeoJSON(areasGJ, rect)
|
|
36
|
+
#common.createEmptyPolygonGeoJSON(a1GJ, rect)
|
|
37
|
+
#common.createEmptyPolygonGeoJSON(a2GJ, rect)
|
|
38
|
+
#common.createEmptyMultiPointGeoJSON(orgGJ, rect)
|
|
39
|
+
|
|
40
|
+
# XXX add layers to project
|
|
41
|
+
|
|
42
|
+
common.exit()
|
|
43
|
+
|
|
44
|
+
exit()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
3
|
+
import os.path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import common
|
|
7
|
+
|
|
8
|
+
common.openPrj()
|
|
9
|
+
|
|
10
|
+
####
|
|
11
|
+
|
|
12
|
+
common.makeExtent()
|
|
13
|
+
common.makeOrigin()
|
|
14
|
+
common.makeMeasures()
|
|
15
|
+
common.makeViewbox()
|
|
16
|
+
|
|
17
|
+
####
|
|
18
|
+
|
|
19
|
+
common.exit()
|
|
20
|
+
|
|
21
|
+
exit()
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
exec ${tools}/pyqgis.sh ${tools}/makeAreas.py "$@"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
3
|
+
import os.path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import common
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
common.openPrj()
|
|
11
|
+
|
|
12
|
+
areas = common.openVector(common.ctx.areasGJ, "areas")
|
|
13
|
+
|
|
14
|
+
extent = common.getExtent(areas, 'memory:')
|
|
15
|
+
|
|
16
|
+
res = common.dumpGeoJSON(extent, common.ctx.areas_extentGJ)
|
|
17
|
+
print(res)
|
|
18
|
+
|
|
19
|
+
common.exit()
|
|
20
|
+
|
|
21
|
+
exit()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
3
|
+
import os.path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import common
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
common.openPrj()
|
|
11
|
+
|
|
12
|
+
areas = common.openVector(common.ctx.areasGJ, "areas")
|
|
13
|
+
|
|
14
|
+
extent = common.getExtent(areas, 'memory:')
|
|
15
|
+
|
|
16
|
+
origin = common.openVector(common.ctx.originGJ, "origin")
|
|
17
|
+
|
|
18
|
+
measures = common.getMeasures(extent, origin)
|
|
19
|
+
|
|
20
|
+
res = common.dumpGeoJSON(measures, common.ctx.measuresGJ)
|
|
21
|
+
print(res)
|
|
22
|
+
|
|
23
|
+
common.exit()
|
|
24
|
+
|
|
25
|
+
exit()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
3
|
+
import os.path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import common
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
common.openPrj()
|
|
11
|
+
|
|
12
|
+
areas = common.openVector(common.ctx.areasGJ, "areas")
|
|
13
|
+
|
|
14
|
+
extent = common.getExtent(areas, 'memory:')
|
|
15
|
+
f = next(extent.getFeatures())
|
|
16
|
+
print(f)
|
|
17
|
+
print(f.attributes())
|
|
18
|
+
|
|
19
|
+
origin = common.getRoundedOrigin(extent)
|
|
20
|
+
print(origin)
|
|
21
|
+
print(origin.x())
|
|
22
|
+
print(origin.y())
|
|
23
|
+
|
|
24
|
+
# XXX save origin.geojson
|
|
25
|
+
res = common.createPointGeoJSON(common.ctx.originGJ, origin)
|
|
26
|
+
print(res)
|
|
27
|
+
|
|
28
|
+
common.exit()
|
|
29
|
+
|
|
30
|
+
exit()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
import os
|
|
3
|
+
import os.path
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
import common
|
|
7
|
+
|
|
8
|
+
####
|
|
9
|
+
|
|
10
|
+
common.openPrj()
|
|
11
|
+
|
|
12
|
+
extent = common.openVector(common.ctx.areas_extentGJ, "areas_extent")
|
|
13
|
+
origin = common.openVector(common.ctx.originGJ, "origin")
|
|
14
|
+
|
|
15
|
+
viewbox = common.getViewbox()
|
|
16
|
+
|
|
17
|
+
res = common.dumpGeoJSON(viewbox, common.ctx.viewboxGJ)
|
|
18
|
+
print(res)
|
|
19
|
+
|
|
20
|
+
common.exit()
|
|
21
|
+
|
|
22
|
+
exit()
|