@tije-syntra/snap-to-line 0.1.0-beta.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tije-syntra
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @tije-syntra/snap-to-line (TypeScript)
2
+
3
+ Beta TypeScript port of [github.com/tije-syntra/snap-to-line](https://github.com/tije-syntra/snap-to-line) **v1.2.0** — GPS route snapping with Viterbi segment tracking for live bus dashboards.
4
+
5
+ Published on npm under [@tije-syntra/snap-to-line](https://www.npmjs.com/package/@tije-syntra/snap-to-line) (org: [tije-syntra](https://www.npmjs.com/org/tije-syntra)).
6
+
7
+ > **Status: 0.1.0-beta.1** — API names and types mirror the Go library; some advanced stabilizers (full folded-geometry branch lock) are simplified in this release.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install @tije-syntra/snap-to-line@beta
13
+ ```
14
+
15
+ ## Quick start
16
+
17
+ ```typescript
18
+ import {
19
+ NewSnapper,
20
+ LiveBusSnapConfig,
21
+ MapOffRoute,
22
+ SnapDegraded,
23
+ DefaultOffRoutePolicy,
24
+ type GPSPoint,
25
+ type LineString,
26
+ type Stop,
27
+ } from "@tije-syntra/snap-to-line";
28
+
29
+ const line: LineString = [
30
+ [106.0, -6.0],
31
+ [106.05, -6.0],
32
+ [106.1, -6.0],
33
+ ];
34
+
35
+ const stops: Stop[] = [
36
+ { ID: "A", Order: 1, Point: line[0] },
37
+ { ID: "B", Order: 2, Point: line[1] },
38
+ { ID: "C", Order: 3, Point: line[2] },
39
+ ];
40
+
41
+ const cfg = LiveBusSnapConfig(stops);
42
+ const snapper = NewSnapper(line, stops, cfg);
43
+
44
+ const point: GPSPoint = {
45
+ Point: [106.04, -6.0002],
46
+ Speed: 25,
47
+ Bearing: 90,
48
+ Timestamp: Date.now(),
49
+ };
50
+
51
+ const result = snapper.Snap(point);
52
+ const policy = DefaultOffRoutePolicy();
53
+ const offRoute = MapOffRoute(result, SnapDegraded(result), policy);
54
+
55
+ console.log(result.SegmentOrder, result.Confidence, offRoute);
56
+ ```
57
+
58
+ ## Publish (org maintainers)
59
+
60
+ ```bash
61
+ npm publish --tag beta --access public --otp=XXXXXX
62
+ ```
63
+
64
+ ## Build
65
+
66
+ ```bash
67
+ npm install
68
+ npm test
69
+ npm run build
70
+ ```
71
+
72
+ Dual **ESM + CJS** output via [tsup](https://tsup.egoist.dev/).
73
+
74
+ ## License
75
+
76
+ MIT — see [LICENSE](./LICENSE).