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/src/lib/print.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { PlatformError } from '@effect/platform/Error'
|
|
2
|
+
|
|
3
|
+
import { FileSystem } from '@effect/platform'
|
|
4
|
+
import { Doc } from '@effect/printer'
|
|
5
|
+
import { Effect, Order, Record } from 'effect'
|
|
6
|
+
|
|
7
|
+
import type { _GeoJSON } from './geojson/geojson-types'
|
|
8
|
+
|
|
9
|
+
import { printGeoJSON } from './geojson/geojson-print'
|
|
10
|
+
import { decodeGeoJSON } from './geojson/geojson-schema'
|
|
11
|
+
import { splitTypes } from './print-utils'
|
|
12
|
+
|
|
13
|
+
export function printGeoJsonAsTs(
|
|
14
|
+
varname: string,
|
|
15
|
+
typename: string,
|
|
16
|
+
geojson: Readonly<_GeoJSON>
|
|
17
|
+
): Doc.Doc<never> {
|
|
18
|
+
const types = splitTypes(typename)
|
|
19
|
+
const basetypename = Doc.encloseSep(
|
|
20
|
+
types.map((t) => Doc.text(`type ${t}`)),
|
|
21
|
+
Doc.empty,
|
|
22
|
+
Doc.empty,
|
|
23
|
+
Doc.text(`, `)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
return Doc.vsep([
|
|
27
|
+
Doc.hcat([
|
|
28
|
+
Doc.text(`import { `),
|
|
29
|
+
basetypename,
|
|
30
|
+
Doc.text(` } from 'svgmapviewer/geo'`),
|
|
31
|
+
]),
|
|
32
|
+
Doc.line,
|
|
33
|
+
Doc.hcat([
|
|
34
|
+
Doc.text(`export const ${varname}: ${typename} = `),
|
|
35
|
+
printGeoJSON(geojson),
|
|
36
|
+
]),
|
|
37
|
+
Doc.line,
|
|
38
|
+
Doc.text(`export default ${varname}`),
|
|
39
|
+
])
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
43
|
+
export function printAllTs(): Doc.Doc<never> {
|
|
44
|
+
return Doc.vsep([
|
|
45
|
+
Doc.vsep(
|
|
46
|
+
Record.toEntries(_names)
|
|
47
|
+
.toSorted((a, b) => Order.string(a[1], b[1]))
|
|
48
|
+
.map(([k, v]) => Doc.text(`import ${v} from './${k}'`))
|
|
49
|
+
),
|
|
50
|
+
Doc.line,
|
|
51
|
+
Doc.text(`export const mapData = {`),
|
|
52
|
+
Doc.indent(
|
|
53
|
+
Doc.vsep(Record.values(_names).map((v) => Doc.text(`${v},`))),
|
|
54
|
+
2
|
|
55
|
+
),
|
|
56
|
+
Doc.text(`}`),
|
|
57
|
+
])
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const convName = (
|
|
61
|
+
_type: _Type
|
|
62
|
+
): Effect.Effect<void, PlatformError, FileSystem.FileSystem> =>
|
|
63
|
+
Effect.gen(function* () {
|
|
64
|
+
const fs = yield* FileSystem.FileSystem
|
|
65
|
+
const jsonStr = yield* fs.readFileString(`./${_type}.json`)
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
67
|
+
const jsonObj = JSON.parse(jsonStr)
|
|
68
|
+
const geojson = decodeGeoJSON(jsonObj)
|
|
69
|
+
const doc = printGeoJsonAsTs(_names[_type], _types[_type], geojson)
|
|
70
|
+
const ts = Doc.render(doc, { style: 'pretty' })
|
|
71
|
+
yield* fs.writeFileString(`./${_type}.ts`, ts)
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
75
|
+
export const convNames = (): Effect.Effect<
|
|
76
|
+
void[],
|
|
77
|
+
PlatformError,
|
|
78
|
+
FileSystem.FileSystem
|
|
79
|
+
> => Effect.all(Record.keys(_types).map(convName))
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line functional/functional-parameters
|
|
82
|
+
export const saveAllTs = (): Effect.Effect<
|
|
83
|
+
void,
|
|
84
|
+
PlatformError,
|
|
85
|
+
FileSystem.FileSystem
|
|
86
|
+
> =>
|
|
87
|
+
Effect.gen(function* () {
|
|
88
|
+
const fs = yield* FileSystem.FileSystem
|
|
89
|
+
const doc = printAllTs()
|
|
90
|
+
const ts = Doc.render(doc, { style: 'pretty' })
|
|
91
|
+
yield* fs.writeFileString(`./all.ts`, ts)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
////
|
|
95
|
+
|
|
96
|
+
const _types = {
|
|
97
|
+
areas: 'MultiPolygonGeoJSON',
|
|
98
|
+
internals: 'MultiPolygonGeoJSON',
|
|
99
|
+
origin: 'PointGeoJSON',
|
|
100
|
+
measures: 'LineStringGeoJSON<MeasureProperties>',
|
|
101
|
+
viewbox: 'LineStringGeoJSON',
|
|
102
|
+
|
|
103
|
+
'map-points': 'OsmPointGeoJSON',
|
|
104
|
+
'map-lines': 'OsmLineStringGeoJSON',
|
|
105
|
+
'map-multilinestrings': 'OsmMultiLineStringGeoJSON',
|
|
106
|
+
'map-multipolygons': 'OsmMultiPolygonGeoJSON',
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type _Type = keyof typeof _types
|
|
110
|
+
|
|
111
|
+
const _names = {
|
|
112
|
+
areas: 'areas',
|
|
113
|
+
internals: 'internals',
|
|
114
|
+
origin: 'origin',
|
|
115
|
+
measures: 'measures',
|
|
116
|
+
viewbox: 'viewbox',
|
|
117
|
+
|
|
118
|
+
'map-points': 'points',
|
|
119
|
+
'map-lines': 'lines',
|
|
120
|
+
'map-multilinestrings': 'multilinestrings',
|
|
121
|
+
'map-multipolygons': 'multipolygons',
|
|
122
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "FeatureCollection",
|
|
3
|
+
"name": "areas",
|
|
4
|
+
"crs": {
|
|
5
|
+
"type": "name",
|
|
6
|
+
"properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" }
|
|
7
|
+
},
|
|
8
|
+
"features": [
|
|
9
|
+
{
|
|
10
|
+
"type": "Feature",
|
|
11
|
+
"properties": {
|
|
12
|
+
"a": "a",
|
|
13
|
+
"b": 123,
|
|
14
|
+
"c": null
|
|
15
|
+
},
|
|
16
|
+
"geometry": {
|
|
17
|
+
"type": "MultiPolygon",
|
|
18
|
+
"coordinates": [[[[123, 1.23]]]]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"useDefineForClassFields": true,
|
|
8
|
+
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
|
|
11
|
+
/* Bundler mode */
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"declaration": true,
|
|
16
|
+
"declarationDir": "./dist",
|
|
17
|
+
"isolatedDeclarations": true,
|
|
18
|
+
"verbatimModuleSyntax": true,
|
|
19
|
+
"moduleDetection": "force",
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
|
|
22
|
+
"resolveJsonModule": true,
|
|
23
|
+
|
|
24
|
+
/* Linting */
|
|
25
|
+
"strict": true,
|
|
26
|
+
"noUnusedLocals": true,
|
|
27
|
+
"noUnusedParameters": true,
|
|
28
|
+
"noFallthroughCasesInSwitch": true,
|
|
29
|
+
|
|
30
|
+
"types": ["node"]
|
|
31
|
+
},
|
|
32
|
+
"include": ["src"],
|
|
33
|
+
"exclude": ["src/**/*.test.*"]
|
|
34
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
|
|
8
|
+
/* Bundler mode */
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"declaration": false,
|
|
13
|
+
"isolatedDeclarations": false,
|
|
14
|
+
"verbatimModuleSyntax": false,
|
|
15
|
+
"moduleDetection": "force",
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
|
|
18
|
+
/* Linting */
|
|
19
|
+
"strict": true,
|
|
20
|
+
"noUnusedLocals": true,
|
|
21
|
+
"noUnusedParameters": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
|
|
24
|
+
"types": ["@vitest/browser/providers/playwright"]
|
|
25
|
+
},
|
|
26
|
+
"include": ["tests/browser"]
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2023"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
|
|
8
|
+
/* Bundler mode */
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"allowImportingTsExtensions": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"moduleDetection": "force",
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["*.config.ts", "*.config-*.ts"]
|
|
24
|
+
}
|