@osm-editor-kit/osm-route-snapper 0.1.0-alpha.0 → 0.1.0-alpha.2
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/README.md +9 -10
- package/dist/index.js +4 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
# `@osm-editor-kit/osm-route-snapper`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is an **alpha** release and still under active development. APIs may change; install with the npm `alpha` dist-tag.
|
|
4
5
|
|
|
5
6
|
## What it does
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Turn session OSM data (`@osm-editor-kit/osm-data`) into a [route-snapper](https://github.com/a-b-street/route-snapper) graph:
|
|
8
9
|
|
|
9
|
-
- Build
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- TanStack Query
|
|
10
|
+
- Build graph bytes from coverage (vendored `osm-to-route-snapper` WASM)
|
|
11
|
+
- Export a routing-network GeoJSON (edges split at intersections)
|
|
12
|
+
- Export highway ways as GeoJSON LineStrings
|
|
13
|
+
- Cache key / signature when coverage changes
|
|
14
|
+
- Optional TanStack Query hook that rebuilds the graph as the map downloads more OSM
|
|
14
15
|
|
|
15
16
|
## Usage
|
|
16
17
|
|
|
@@ -27,9 +28,7 @@ import {
|
|
|
27
28
|
|
|
28
29
|
```ts
|
|
29
30
|
const graphBytes = await buildRouteSnapperGraphBytes(parsedOsm)
|
|
30
|
-
const routingNetwork = graphBytes
|
|
31
|
-
? await routingNetworkGeoJsonFromBytes(graphBytes)
|
|
32
|
-
: null
|
|
31
|
+
const routingNetwork = graphBytes ? await routingNetworkGeoJsonFromBytes(graphBytes) : null
|
|
33
32
|
```
|
|
34
33
|
|
|
35
34
|
**React + TanStack Query** — `createRouteSnapperGraphApi` wires coverage growth to automatic full rebuilds (WASM has no incremental API):
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@ import initOsmToRouteSnapper, { convert } from '../vendor/osm-to-route-snapper/o
|
|
|
2
2
|
import { useQuery } from '@tanstack/react-query';
|
|
3
3
|
import initRouteSnapper, { JsRouteSnapper } from 'route-snapper';
|
|
4
4
|
|
|
5
|
+
// src/build-graph.ts
|
|
6
|
+
|
|
5
7
|
// src/parsed-osm-to-xml.ts
|
|
6
8
|
function escapeXml(value) {
|
|
7
9
|
return value.replaceAll("&", "&").replaceAll('"', """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">");
|
|
@@ -33,6 +35,8 @@ function parsedOsmToXml(data) {
|
|
|
33
35
|
const ways = Object.values(data.ways).map(renderWay).join("");
|
|
34
36
|
return `<?xml version="1.0" encoding="UTF-8"?><osm version="0.6" generator="osm-route-snapper">${nodes}${ways}</osm>`;
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
// src/build-graph.ts
|
|
36
40
|
var initPromise;
|
|
37
41
|
async function ensureOsmToRouteSnapperReady() {
|
|
38
42
|
if (!initPromise) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osm-editor-kit/osm-route-snapper",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
4
|
"description": "Build route-snapper graph bytes and routing-network GeoJSON from parsed OSM coverage (WASM).",
|
|
5
|
+
"homepage": "https://github.com/osmberlin/street-space-editor/tree/main/packages/osm-route-snapper",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"author": "Tobias Jordans",
|
|
7
8
|
"repository": {
|
|
@@ -9,12 +10,12 @@
|
|
|
9
10
|
"url": "git+https://github.com/osmberlin/street-space-editor.git",
|
|
10
11
|
"directory": "packages/osm-route-snapper"
|
|
11
12
|
},
|
|
12
|
-
"type": "module",
|
|
13
|
-
"sideEffects": false,
|
|
14
13
|
"files": [
|
|
15
14
|
"dist",
|
|
16
15
|
"vendor"
|
|
17
16
|
],
|
|
17
|
+
"type": "module",
|
|
18
|
+
"sideEffects": false,
|
|
18
19
|
"exports": {
|
|
19
20
|
".": {
|
|
20
21
|
"types": "./dist/index.d.ts",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"postpack": "bun ../../scripts/package-exports-restore.ts"
|
|
37
38
|
},
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"@osm-editor-kit/osm-data": "
|
|
40
|
+
"@osm-editor-kit/osm-data": "^0.1.0-alpha.1"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@types/geojson": "^7946.0.16",
|