@tilda-geo/bicycle-infrastructure 0.1.2 → 0.3.0
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.md +15 -0
- package/NOTICE.md +13 -0
- package/README.md +23 -14
- package/dist/index.d.ts +239 -11
- package/dist/index.js +1997 -921
- package/package.json +11 -9
package/LICENSE.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FixMyCity GmbH
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Notice: where the code comes from
|
|
2
|
+
|
|
3
|
+
The bicycle infrastructure logic of `@tilda-geo/bicycle-infrastructure` is a TypeScript port of the
|
|
4
|
+
LUA processing of [tilda-geo](https://github.com/FixMyBerlin/tilda-geo)
|
|
5
|
+
(`processing/topics/roads_bikelanes`). tilda-geo is licensed under the
|
|
6
|
+
[AGPL-3.0](https://github.com/FixMyBerlin/tilda-geo/blob/develop/LICENSE).
|
|
7
|
+
|
|
8
|
+
FixMyCity GmbH holds the rights to tilda-geo and to this repository. As the rights holder it
|
|
9
|
+
publishes the ported logic here under the ISC license. tilda-geo itself stays under the AGPL-3.0;
|
|
10
|
+
this notice does not change its license.
|
|
11
|
+
|
|
12
|
+
The tagging logic of `@tilda-geo/bicycle-infrastructure-tagging` comes from the iD Radnetz editor of
|
|
13
|
+
FixMyCity GmbH (ISC), and its German labels from the topic docs of tilda-geo.
|
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ npm install @tilda-geo/bicycle-infrastructure
|
|
|
19
19
|
3. Returns **1..N features** (centerline `self` plus transformed `left`/`right` sides), each with:
|
|
20
20
|
- **`category`** — `Radinfrastrukturkategorie` (primary focus; see [`schemas/bicycle-infrastructure-category`](../../schemas/bicycle-infrastructure-category/))
|
|
21
21
|
- plus surface, smoothness, oneway, separation / buffer / marking, traffic_mode, traffic_sign, surface_color, width
|
|
22
|
+
- `_lineReversed` and `offset` (riding direction of the published line of a lane on the road)
|
|
23
|
+
- `todos` (what is missing or wrong in the tagging) and `todoTagFixes`
|
|
22
24
|
|
|
23
25
|
Disallowed sanitizer values become `null`, matching TILDA’s GeoJSON export.
|
|
24
26
|
|
|
@@ -39,11 +41,11 @@ const features = processBikelanes({
|
|
|
39
41
|
|
|
40
42
|
## How it relates to the rest of the monorepo
|
|
41
43
|
|
|
42
|
-
| Piece
|
|
43
|
-
|
|
|
44
|
-
| [`schemas/bicycle-infrastructure-category`](../../schemas/bicycle-infrastructure-category/)
|
|
45
|
-
| [`schemas/bicycle-infrastructure-attributes`](../../schemas/bicycle-infrastructure-attributes/) | Draft vocabularies for non-category fields (fixtures used in tests)
|
|
46
|
-
| [`bicycle-infrastructure-reconciliation`](../bicycle-infrastructure-reconciliation/)
|
|
44
|
+
| Piece | Relationship |
|
|
45
|
+
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
46
|
+
| [`schemas/bicycle-infrastructure-category`](../../schemas/bicycle-infrastructure-category/) | Source of truth for allowed `category` values + fixtures |
|
|
47
|
+
| [`schemas/bicycle-infrastructure-attributes`](../../schemas/bicycle-infrastructure-attributes/) | Draft vocabularies for non-category fields (fixtures used in tests) |
|
|
48
|
+
| [`bicycle-infrastructure-reconciliation`](../bicycle-infrastructure-reconciliation/) | **Internal** tooling that proves this library ≡ TILDA LUA on a Berlin corpus |
|
|
47
49
|
|
|
48
50
|
---
|
|
49
51
|
|
|
@@ -51,13 +53,14 @@ const features = processBikelanes({
|
|
|
51
53
|
|
|
52
54
|
Ported module-for-module from `tilda-geo` → `processing/topics/roads_bikelanes`:
|
|
53
55
|
|
|
54
|
-
| This package
|
|
55
|
-
|
|
|
56
|
-
| `transform/prepare-tags.ts`
|
|
57
|
-
| `transform/transformations.ts`
|
|
58
|
-
| `categories/*`
|
|
59
|
-
| `sanitize/*`, `derive/*`
|
|
60
|
-
| `
|
|
56
|
+
| This package | LUA |
|
|
57
|
+
| ------------------------------- | --------------------------------------------------------------- |
|
|
58
|
+
| `transform/prepare-tags.ts` | `helper/transform_tags/*` |
|
|
59
|
+
| `transform/transformations.ts` | `bikelanes/transformations.lua` |
|
|
60
|
+
| `categories/*` | `bikelanes/bikelane_categories.lua` (+ decision view, sidepath) |
|
|
61
|
+
| `sanitize/*`, `derive/*` | `helper/sanitize_*`, `derive_*`, `bikelane_todo_categories.lua` |
|
|
62
|
+
| `helpers/parse-length.ts` | `helper/parse_length.lua`, `helper/parse_width.lua` |
|
|
63
|
+
| `index.ts` → `processBikelanes` | `bikelanes/bikelanes.lua` |
|
|
61
64
|
|
|
62
65
|
---
|
|
63
66
|
|
|
@@ -68,16 +71,18 @@ From the monorepo root:
|
|
|
68
71
|
```bash
|
|
69
72
|
bun install
|
|
70
73
|
bun run build
|
|
71
|
-
bun run
|
|
74
|
+
bun run test-run
|
|
72
75
|
bun run check-exports
|
|
73
76
|
```
|
|
74
77
|
|
|
75
78
|
- `test/spec.test.ts` — conformance against `schemas/**/fixtures` (via `test/load-spec.ts`)
|
|
76
79
|
- `test/categories.smoke.test.ts` — cases ported from LUA `__tests__`
|
|
77
80
|
|
|
81
|
+
Editor helpers (planner wrapper, required attributes, widths, extract and merge paths) are in [`@tilda-geo/bicycle-infrastructure-tagging`](../bicycle-infrastructure-tagging/). `planTagsForCategory` stays here because it needs the category specs; the tagging package depends on this one.
|
|
82
|
+
|
|
78
83
|
Berlin corpus check (category agreement ~100%): see the **internal** [reconciliation](../bicycle-infrastructure-reconciliation/) package.
|
|
79
84
|
|
|
80
|
-
Releases use [changesets](https://github.com/changesets/changesets)
|
|
85
|
+
Releases use [changesets](https://github.com/changesets/changesets), see [`.changeset/README.md`](../../.changeset/README.md) and the root README **Release** section.
|
|
81
86
|
|
|
82
87
|
---
|
|
83
88
|
|
|
@@ -85,3 +90,7 @@ Releases use [changesets](https://github.com/changesets/changesets) — see the
|
|
|
85
90
|
|
|
86
91
|
- `_adjoining` / `_isolated` / `_adjoiningOrIsolated` use the raw OSM `is_sidepath` tag (same as LUA categorization). TILDA’s `_is_sidepath` CSV estimate is export-only and does not affect category.
|
|
87
92
|
- `highway=construction` lifecycle is handled; the geometry crossing-length filter (>100 m) is skipped when `_length` is absent (typical for live Overpass tags).
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
[ISC](LICENSE.md), FixMyCity GmbH. The logic is ported from the LUA processing of tilda-geo (AGPL-3.0) by its rights holder, see [NOTICE.md](NOTICE.md).
|
package/dist/index.d.ts
CHANGED
|
@@ -14,12 +14,19 @@ interface OsmTags {
|
|
|
14
14
|
_length?: any;
|
|
15
15
|
}
|
|
16
16
|
type ImplicitOneWayConfidence = 'high' | 'medium' | 'low' | 'not_applicable';
|
|
17
|
+
/**
|
|
18
|
+
* How a bikelane category reads `surface:bicycle` (`BikelaneCategory.bicycleSurface` in LUA):
|
|
19
|
+
* `strip`: bicycles use a strip of a wide shared area; `whole_way`: the bikelane is a way of its own.
|
|
20
|
+
*/
|
|
21
|
+
type BicycleSurface = 'strip' | 'whole_way';
|
|
17
22
|
interface BikelaneCategory {
|
|
18
23
|
id: string;
|
|
19
24
|
infrastructureExists: boolean;
|
|
20
25
|
implicitOneWay: boolean;
|
|
21
26
|
implicitOneWayConfidence: ImplicitOneWayConfidence;
|
|
22
27
|
copySurfaceSmoothnessFromParent: boolean;
|
|
28
|
+
/** How `surface:bicycle` applies, see `deriveBikelaneSurfaceTags`; undefined ignores it. */
|
|
29
|
+
bicycleSurface?: BicycleSurface;
|
|
23
30
|
/** Receives a decision-view of the tags; returns truthy when the category matches. */
|
|
24
31
|
condition: (tags: OsmTags) => boolean | undefined;
|
|
25
32
|
/** Optional post-match mutation of the tags (mirrors LUA `process`). */
|
|
@@ -31,7 +38,19 @@ interface BikelaneResult {
|
|
|
31
38
|
_prefix: string | null;
|
|
32
39
|
_infrastructureExists: boolean;
|
|
33
40
|
category: string;
|
|
41
|
+
/**
|
|
42
|
+
* `construction`, `construction_no_access`, `blocked` or `temporary`: the side's own lifecycle,
|
|
43
|
+
* else the one of its road. Only for features with infrastructure.
|
|
44
|
+
*/
|
|
45
|
+
lifecycle?: string | null;
|
|
34
46
|
oneway?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the published line of a lane or track tagged on the road runs against the OSM way
|
|
49
|
+
* (`_line_reversed` in LUA, tilda-geo `6ec40d600`). Lines of the way itself keep its direction.
|
|
50
|
+
*/
|
|
51
|
+
_lineReversed?: boolean;
|
|
52
|
+
/** Sideways offset in meters of left|right lanes, signed relative to the published line. */
|
|
53
|
+
offset?: number;
|
|
35
54
|
surface?: string | null;
|
|
36
55
|
surface_source?: string | null;
|
|
37
56
|
surface_confidence?: string | null;
|
|
@@ -49,7 +68,141 @@ interface BikelaneResult {
|
|
|
49
68
|
surface_color?: string | null;
|
|
50
69
|
traffic_sign?: string | null;
|
|
51
70
|
width?: number | null;
|
|
71
|
+
/**
|
|
72
|
+
* Ids of the todos that apply to the feature (`_todo_list` in LUA), see `BIKELANE_TODOS`.
|
|
73
|
+
* Only for features with infrastructure. Without the Mapillary, age and sidepath-CSV todos.
|
|
74
|
+
*/
|
|
75
|
+
todos?: string[];
|
|
76
|
+
/** Proposed tag changes per todo id (`unset`: tags to remove), when a todo proposes one. */
|
|
77
|
+
todoTagFixes?: Record<string, {
|
|
78
|
+
unset: string[];
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** What the todo conditions read besides the transformed tags (LUA `result_tags`). */
|
|
83
|
+
interface BikelaneTodoResult {
|
|
84
|
+
category: string;
|
|
85
|
+
width?: number | null;
|
|
86
|
+
surface?: string | null;
|
|
87
|
+
surface_source?: string | null;
|
|
88
|
+
oneway?: string;
|
|
89
|
+
implicitOneWayConfidence: ImplicitOneWayConfidence;
|
|
90
|
+
}
|
|
91
|
+
/** Proposed tag change of a todo, for editors and MapRoulette Tag Fix tasks. */
|
|
92
|
+
interface TodoTagFix {
|
|
93
|
+
unset: string[];
|
|
94
|
+
}
|
|
95
|
+
interface BikelaneTodoDefinition {
|
|
96
|
+
id: string;
|
|
97
|
+
desc: string;
|
|
98
|
+
/** `true`: hidden from the inspector, only in the todo table. */
|
|
99
|
+
todoTableOnly: boolean;
|
|
100
|
+
condition: (tags: OsmTags, result: BikelaneTodoResult) => boolean;
|
|
101
|
+
tagFix?: (tags: OsmTags, result: BikelaneTodoResult) => TodoTagFix | undefined;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Port of is_unusual_width.lua: a `width` a human should look at. Not readable by `parseWidth`
|
|
105
|
+
* (`narrow`, `1-2`, `-1`, `0`), or above 50 m (published, but probably a typo). A check date on the
|
|
106
|
+
* way, on the road of a lane, or on the width itself closes the todo.
|
|
107
|
+
*/
|
|
108
|
+
declare function isUnusualWidth(tags: OsmTags, result: Pick<BikelaneTodoResult, 'width'>): boolean;
|
|
109
|
+
/** In the order of `bikelane_todo_categories` in LUA. */
|
|
110
|
+
declare const BIKELANE_TODOS: readonly BikelaneTodoDefinition[];
|
|
111
|
+
interface BikelaneTodos {
|
|
112
|
+
/** Ids of the todos that apply, in the order of `BIKELANE_TODOS`. */
|
|
113
|
+
todos: string[];
|
|
114
|
+
/** Proposed tag changes per todo id; only set when a todo proposes one. */
|
|
115
|
+
todoTagFixes?: Record<string, TodoTagFix>;
|
|
52
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* `tags` are the transformed tags after categorization (the category's `process` may have changed
|
|
119
|
+
* them), `result` what was derived for the feature.
|
|
120
|
+
*/
|
|
121
|
+
declare function deriveBikelaneTodos(tags: OsmTags, result: BikelaneTodoResult): BikelaneTodos;
|
|
122
|
+
|
|
123
|
+
/** What the road todo conditions read besides the tags (LUA `result_tags`). */
|
|
124
|
+
interface RoadTodoResult {
|
|
125
|
+
/** `width` of the road, read by `parseWidth` */
|
|
126
|
+
width?: number | null;
|
|
127
|
+
/**
|
|
128
|
+
* `true` when the `self` bikelane row of the way has the todo `unusual_width` already
|
|
129
|
+
* (`_self_bikelane_has_unusual_width` in LUA): one todo per way.
|
|
130
|
+
*/
|
|
131
|
+
selfBikelaneHasUnusualWidth?: boolean;
|
|
132
|
+
}
|
|
133
|
+
interface RoadTodoDefinition {
|
|
134
|
+
id: string;
|
|
135
|
+
desc: string;
|
|
136
|
+
/** `true`: hidden from the inspector, only in the todo table. */
|
|
137
|
+
todoTableOnly: boolean;
|
|
138
|
+
condition: (tags: OsmTags, result: RoadTodoResult) => boolean;
|
|
139
|
+
}
|
|
140
|
+
/** In the order of `road_todo_categories` in LUA (without `adjoining_of_vs_csv`). */
|
|
141
|
+
declare const ROAD_TODOS: readonly RoadTodoDefinition[];
|
|
142
|
+
/**
|
|
143
|
+
* The todos of a road (the way itself). `result.width` defaults to what `parseWidth` reads from
|
|
144
|
+
* `tags.width`, like the roads table does.
|
|
145
|
+
*/
|
|
146
|
+
declare function deriveRoadTodos(tags: OsmTags, result?: RoadTodoResult): string[];
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Port of osm2pgsql.split_unit + topics/helper/parse_length.lua + topics/helper/parse_width.lua
|
|
150
|
+
* (tilda-geo, state of 2026-11-04). One parser for every `width`, `buffer` and other length value.
|
|
151
|
+
*/
|
|
152
|
+
/**
|
|
153
|
+
* Normalize a length to meters. Units `cm`, `m` and `km` are converted, every other unit
|
|
154
|
+
* (`mm`, `ft`, `in`, `mi`, ...) is `undefined`, like in LUA. A negative length is `undefined`;
|
|
155
|
+
* `0` is kept (`buffer=0` means no buffer). Use `parseWidth` when `0` makes no sense.
|
|
156
|
+
*/
|
|
157
|
+
declare function parseLength(length: string | number | undefined | null): number | undefined;
|
|
158
|
+
/** Like `parseLength` for the width of a road or lane, where `0` can only be a mapping error. */
|
|
159
|
+
declare function parseWidth(width: string | number | undefined | null): number | undefined;
|
|
160
|
+
|
|
161
|
+
/** Port of topics/roads_bikelanes/helper/sanitize_road_tags.lua */
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* `separation` values that make a lane "protected" (`cyclewayOnHighwayProtected`), as in
|
|
165
|
+
* `bikelane_categories.lua`. Other allowed values (`kerb`, `greenery`, ...) do not.
|
|
166
|
+
* Ordered by use in Berlin (extract of 2026-11-09, `highway=cycleway`, separation towards the road):
|
|
167
|
+
* bollard 102, flex_post 35, vertical_panel 28, bump 25, fence 9, guard_rail 6; the others 0.
|
|
168
|
+
* Editors offer them in this order, `bollard` as the default.
|
|
169
|
+
*/
|
|
170
|
+
declare const PROTECTIVE_SEPARATION: readonly ["bollard", "flex_post", "vertical_panel", "bump", "fence", "guard_rail", "planter", "studs", "jersey_barrier"];
|
|
171
|
+
declare const SEPARATION_ALLOWED: readonly ["no", "bollard", "flex_post", "vertical_panel", "studs", "bump", "planter", "kerb", "fence", "jersey_barrier", "guard_rail", "structure", "ditch", "greenery", "hedge", "tree_row", "cone", "kerb;parking_lane", "kerb;bollard", "yes"];
|
|
172
|
+
declare const MARKING_ALLOWED: readonly ["solid_line", "dashed_line", "double_solid_line", "barred_area", "pictogram", "surface"];
|
|
173
|
+
declare const TRAFFIC_MODE_ALLOWED: readonly ["no", "motor_vehicle", "parking", "psv", "bicycle", "foot"];
|
|
174
|
+
declare const SURFACE_COLOR_ALLOWED: readonly ["red", "green", "red;green", "no"];
|
|
175
|
+
|
|
176
|
+
/** Port of topics/helper/sanitize_tags.lua > `surface` */
|
|
177
|
+
|
|
178
|
+
declare const SURFACE_ALLOWED: readonly ["asphalt", "paved", "unpaved", "concrete", "concrete:plates", "concrete:lanes", "paving_stones", "paving_stones:lanes", "sett", "bricks", "stone", "ground", "grass", "sand", "compacted", "fine_gravel", "gravel", "pebblestone", "wood", "woodchips", "metal", "metal_grid", "plastic", "rubber", "grass_paver"];
|
|
179
|
+
|
|
180
|
+
/** Port of topics/roads_bikelanes/bikelanes/helper/derive_traffic_mode.lua */
|
|
181
|
+
|
|
182
|
+
/** Categories where `traffic_mode` is inferred from the road's `parking:<side>`, besides bicycle roads. */
|
|
183
|
+
declare const DIRECTIONAL_PARKING_INFERENCE_CATEGORIES: Set<string>;
|
|
184
|
+
declare const PARKING_ALLOWED: readonly ["no", "yes", "lane", "street_side", "on_kerb", "half_on_kerb", "shoulder", "separate"];
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Port of topics/roads_bikelanes/bikelanes/derive_oneway.lua and
|
|
188
|
+
* topics/roads_bikelanes/bikelanes/helper/side_line_reversed.lua (tilda-geo `6ec40d600`, `bac701775`).
|
|
189
|
+
*
|
|
190
|
+
* OSM `oneway` values are relative to the drawing direction of the way:
|
|
191
|
+
* `yes` flows with the way, `-1` against it, `no` in both directions.
|
|
192
|
+
* https://wiki.openstreetmap.org/wiki/Key:oneway
|
|
193
|
+
* The tags are expected after `normalizeOnewayTags` (`1`/`true` are `yes`, roundabouts `oneway=yes`).
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Whether bicycles ride against the drawing direction of `road` on its `left`|`right` lane when the
|
|
198
|
+
* lane has no `cycleway:<side>:oneway`, the wiki default (right-hand traffic):
|
|
199
|
+
* https://wiki.openstreetmap.org/wiki/Key:cycleway:right:oneway#Implicit_values
|
|
200
|
+
* - One-way road: both sides follow the road, so against the way only on `oneway=-1`.
|
|
201
|
+
* `oneway:bicycle=no` changes nothing: a contraflow lane needs `cycleway:left:oneway=-1`.
|
|
202
|
+
* - Other roads: the right side runs with the way, the left side against it.
|
|
203
|
+
* Exported so editors suggest the same direction the processing derives.
|
|
204
|
+
*/
|
|
205
|
+
declare function defaultSideRunsAgainstWay(road: OsmTags, side: 'left' | 'right'): boolean;
|
|
53
206
|
|
|
54
207
|
/** Port of topics/roads_bikelanes/bikelanes/bikelane_categories.lua — compiled from declarative specs. */
|
|
55
208
|
|
|
@@ -80,23 +233,42 @@ declare function analyzeCategoryGaps(wayTags: OsmTags, results: BikelaneResult[]
|
|
|
80
233
|
* Plan OSM tag adds/changes to reach a target bikelane category.
|
|
81
234
|
* Works in transformed tag space internally; returns nested OSM keys for left/right
|
|
82
235
|
* cycleway (and sidewalk) sides, bare keys for self.
|
|
236
|
+
*
|
|
237
|
+
* The planner reads the same category specs the classifier uses. The match predicate of the
|
|
238
|
+
* target (and of its refining child, e.g. `_adjoining`) is expanded into alternatives: each
|
|
239
|
+
* alternative is a set of tags that is enough on its own (`segregated=yes` + `bicycle` + `foot`,
|
|
240
|
+
* or `traffic_sign=DE:241`). Every alternative becomes a candidate plan; the planner classifies the
|
|
241
|
+
* planned tags and keeps the cheapest candidate that gives the target.
|
|
83
242
|
*/
|
|
84
243
|
|
|
85
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Why a tag is planned: `reason` is an English sentence, `reasonCode` a stable code for apps that
|
|
246
|
+
* write their own text (for example `required_for_category`), `reasonParams` fills its placeholders.
|
|
247
|
+
* The codes are listed in `TAG_REASON_CODES`.
|
|
248
|
+
*/
|
|
249
|
+
interface TagReason {
|
|
250
|
+
reason: string;
|
|
251
|
+
reasonCode: TagReasonCode;
|
|
252
|
+
reasonParams?: Record<string, string>;
|
|
253
|
+
/**
|
|
254
|
+
* Values the mapper can pick instead, when more than one reaches the target (the kind of
|
|
255
|
+
* separation of a protected lane). The planned value (`value` / `to`) is the default and the
|
|
256
|
+
* first entry; the others follow by how often they are mapped.
|
|
257
|
+
*/
|
|
258
|
+
choices?: readonly string[];
|
|
259
|
+
}
|
|
260
|
+
interface TagPlanEntry extends TagReason {
|
|
86
261
|
key: string;
|
|
87
262
|
value: string;
|
|
88
|
-
reason: string;
|
|
89
263
|
}
|
|
90
|
-
interface TagChangeEntry {
|
|
264
|
+
interface TagChangeEntry extends TagReason {
|
|
91
265
|
key: string;
|
|
92
266
|
from: string;
|
|
93
267
|
to: string;
|
|
94
|
-
reason: string;
|
|
95
268
|
}
|
|
96
|
-
interface TagConflictEntry {
|
|
269
|
+
interface TagConflictEntry extends TagReason {
|
|
97
270
|
key: string;
|
|
98
271
|
value: string;
|
|
99
|
-
reason: string;
|
|
100
272
|
}
|
|
101
273
|
interface CategoryTagPlan {
|
|
102
274
|
targetCategoryId: string;
|
|
@@ -104,23 +276,66 @@ interface CategoryTagPlan {
|
|
|
104
276
|
aligned: boolean;
|
|
105
277
|
add: TagPlanEntry[];
|
|
106
278
|
change: TagChangeEntry[];
|
|
279
|
+
/** Keys to delete: `cycleway:both` (or `cycleway`) when a road side is split from the other */
|
|
280
|
+
remove: string[];
|
|
107
281
|
conflicts: TagConflictEntry[];
|
|
108
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* `default`: the cheapest plan, the one `planTagsForCategory` returns.
|
|
285
|
+
* `with_sign`: reaches the target with the traffic sign of the category (DE:240, DE:241, ...).
|
|
286
|
+
* `without_sign`: reaches the target with `traffic_sign=none` and the tags that say the same.
|
|
287
|
+
*/
|
|
288
|
+
type CategoryTagPlanVariantId = 'default' | 'with_sign' | 'without_sign';
|
|
289
|
+
interface CategoryTagPlanVariant extends CategoryTagPlan {
|
|
290
|
+
variantId: CategoryTagPlanVariantId;
|
|
291
|
+
}
|
|
109
292
|
interface ListTargetCategoriesOptions {
|
|
110
293
|
/** Current category id — unlock candidates from its gapDiscriminators are listed first. */
|
|
111
294
|
fromCategory?: string;
|
|
112
295
|
/** When true with `fromCategory`, treat it as incomplete even if the id looks complete. */
|
|
113
296
|
fromIncomplete?: boolean;
|
|
114
297
|
}
|
|
298
|
+
/** The codes of `TagReason.reasonCode`; `{x}` names a parameter. */
|
|
299
|
+
declare const TAG_REASON_CODES: readonly ["required_for_category", "discriminator_for_category", "fixed_by_mapping_target", "bicycle_road", "bicycle_road_sign", "vehicle_destination", "bicycle_road_sign_vehicle_destination", "unsigned_cycleway", "unsigned_cycleway_no_sign", "footway_bicycles_allowed", "bicycle_allowed_on_footway", "footway_sign_bicycles_allowed", "on_highway_cycle_lane", "bus_lane_with_bicycles", "cycle_lane_shared_with_buses", "protected_lane_separation", "protected_lane_parking", "protected_lane_sidepath", "cycleway_crossing", "split_both_sides", "side_presence", "lifecycle", "lifecycle_not_reached", "plan_not_enough", "plan_no_edits"];
|
|
300
|
+
type TagReasonCode = (typeof TAG_REASON_CODES)[number];
|
|
301
|
+
/**
|
|
302
|
+
* The prefix of the road side object a category lives on: `sidewalk` for a footway with bicycles
|
|
303
|
+
* allowed (`sidewalk:right:bicycle=yes`), `cycleway` for the rest.
|
|
304
|
+
*/
|
|
305
|
+
declare function categorySidePrefix(categoryId: string): 'cycleway' | 'sidewalk';
|
|
115
306
|
/**
|
|
116
307
|
* Map a transformed tag key back to OSM way tags for writing.
|
|
117
|
-
* Left/right cycleway (and sidewalk) sub-objects use nested keys (`cycleway:right:lane`)
|
|
308
|
+
* Left/right cycleway (and sidewalk) sub-objects use nested keys (`cycleway:right:lane`); the key
|
|
309
|
+
* that names the side itself (`cycleway`) is `cycleway:right`.
|
|
118
310
|
*/
|
|
119
311
|
declare function writeKeyForSide(transformedKey: string, side: BikelaneResult['_side'], prefix: string | null): string;
|
|
312
|
+
/** The traffic signs that settle `categoryId` on their own, and whether it works without a sign. */
|
|
313
|
+
interface CategorySignOptions {
|
|
314
|
+
/** Signs the planner writes for the category (`DE:240`); never `none` */
|
|
315
|
+
signs: string[];
|
|
316
|
+
/** Some alternative of the category needs no traffic sign (or `traffic_sign=none`) */
|
|
317
|
+
unsignedPossible: boolean;
|
|
318
|
+
}
|
|
319
|
+
/** Which traffic signs settle `categoryId`, read from the category specs. */
|
|
320
|
+
declare function categorySignOptions(categoryId: string): CategorySignOptions;
|
|
120
321
|
declare function listTargetCategories(options?: ListTargetCategoriesOptions): string[];
|
|
121
322
|
interface PlanTagsForCategoryOptions {
|
|
122
323
|
side?: BikelaneResult['_side'];
|
|
324
|
+
/**
|
|
325
|
+
* Tags the plan must contain, in transformed (bare) keys: `{ traffic_sign: 'DE:240' }`. They are
|
|
326
|
+
* written for the side (`cycleway:right:traffic_sign`) and may overwrite `traffic_sign=none`: a
|
|
327
|
+
* fixed tag is an explicit choice of the mapper (a mapping target).
|
|
328
|
+
*/
|
|
329
|
+
fixed?: Record<string, string>;
|
|
330
|
+
/**
|
|
331
|
+
* The lifecycle the side must get. `temporary` writes `temporary=yes` for the side
|
|
332
|
+
* (`cycleway:right:temporary=yes`). `construction` writes a way of its own as
|
|
333
|
+
* `highway=construction` + `construction=<highway>` and a road side under the prefix
|
|
334
|
+
* (`construction:cycleway:right=lane`).
|
|
335
|
+
*/
|
|
336
|
+
lifecycle?: PlanLifecycle;
|
|
123
337
|
}
|
|
338
|
+
type PlanLifecycle = 'construction' | 'temporary';
|
|
124
339
|
declare class UnknownTargetCategoryError extends Error {
|
|
125
340
|
readonly targetCategoryId: string;
|
|
126
341
|
constructor(targetCategoryId: string);
|
|
@@ -131,10 +346,21 @@ declare class UnknownTargetCategoryError extends Error {
|
|
|
131
346
|
* Returned keys use nested OSM form for left/right cycleway (and sidewalk) sides
|
|
132
347
|
* (`cycleway:right:lane`); bare keys for self-side objects.
|
|
133
348
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
349
|
+
* - Tags that settle a category are alternatives: `segregated=yes` (with `bicycle` and `foot`) or
|
|
350
|
+
* `traffic_sign=DE:241` is enough, the plan never asks for both. Plans that add no traffic sign
|
|
351
|
+
* come first.
|
|
352
|
+
* - `traffic_sign=none` is never overwritten (unless `options.fixed` says so).
|
|
353
|
+
* - Macros the classifier evaluates imperatively have preferred tags (`MACRO_PLAN_ALTERNATIVES`);
|
|
354
|
+
* the rest (e.g. `cyclewayOnHighwayProtected`) may still yield a `_category` conflict.
|
|
136
355
|
*/
|
|
137
356
|
declare function planTagsForCategory(wayTags: OsmTags, targetCategoryId: string, options?: PlanTagsForCategoryOptions): CategoryTagPlan;
|
|
357
|
+
/**
|
|
358
|
+
* The ways to reach `targetCategoryId`, the plan of `planTagsForCategory` first (`default`).
|
|
359
|
+
* For categories a traffic sign can settle, further variants: `with_sign` (the sign of the
|
|
360
|
+
* category) and `without_sign` (`traffic_sign=none` plus the tags that say the same). Variants that
|
|
361
|
+
* do not reach the target or repeat an earlier one are left out.
|
|
362
|
+
*/
|
|
363
|
+
declare function planTagVariantsForCategory(wayTags: OsmTags, targetCategoryId: string, options?: PlanTagsForCategoryOptions): CategoryTagPlanVariant[];
|
|
138
364
|
|
|
139
365
|
/** Small predicate AST for declarative category specs (OSMnexus-inspired). */
|
|
140
366
|
|
|
@@ -214,6 +440,8 @@ interface CategorySpec {
|
|
|
214
440
|
implicitOneWay: boolean;
|
|
215
441
|
implicitOneWayConfidence: ImplicitOneWayConfidence;
|
|
216
442
|
copySurfaceSmoothnessFromParent: boolean;
|
|
443
|
+
/** How `surface:bicycle` applies, see `deriveBikelaneSurfaceTags`; undefined ignores it. */
|
|
444
|
+
bicycleSurface?: BicycleSurface;
|
|
217
445
|
match?: TagPredicate;
|
|
218
446
|
excludes?: TagPredicate[];
|
|
219
447
|
refining?: RefiningChild[];
|
|
@@ -244,7 +472,7 @@ declare const BIKELANE_TRANSFORMATIONS: CenterLineTransformation[];
|
|
|
244
472
|
* tags in-place BEFORE `getTransformedObjects`, exactly as `roads_bikelanes.lua` does.
|
|
245
473
|
*/
|
|
246
474
|
|
|
247
|
-
/** Apply all pre-transforms in the same order as
|
|
475
|
+
/** Apply all pre-transforms in the same order as roads_bikelanes_ways.lua. */
|
|
248
476
|
declare function prepareTags(tags: OsmTags): void;
|
|
249
477
|
|
|
250
478
|
/** Port of topics/helper/highway_classes.lua */
|
|
@@ -271,4 +499,4 @@ declare const ALLOWED_HIGHWAYS: Set<string>;
|
|
|
271
499
|
|
|
272
500
|
declare function processBikelanes(objectTags: OsmTags): BikelaneResult[];
|
|
273
501
|
|
|
274
|
-
export { ALLOWED_HIGHWAYS, BIKELANE_TRANSFORMATIONS, type BikelaneResult, CATEGORY_DEFINITIONS, CATEGORY_SPECS, type CategoryGap, type CategoryGapResult, type CategorySpec, type CategoryTagPlan, type GapDiscriminator, type ListTargetCategoriesOptions, MAJOR_ROAD_CLASSES, MINOR_ROAD_CLASSES, type OsmTags, PATH_CLASSES, type PlanTagsForCategoryOptions, SIDEPATH_HIGHWAY_CLASSES, TRUNK_MOTORWAY_CLASSES, type TagChangeEntry, type TagConflictEntry, type TagPlanEntry, UnknownTargetCategoryError, analyzeCategoryGaps, categorizeBikelane, getTransformedObjects, isIncompleteCategoryId, listTargetCategories, planTagsForCategory, prepareTags, processBikelanes, specsWithGapDiscriminators, writeKeyForSide };
|
|
502
|
+
export { ALLOWED_HIGHWAYS, BIKELANE_TODOS, BIKELANE_TRANSFORMATIONS, type BikelaneResult, type BikelaneTodoDefinition, type BikelaneTodoResult, type BikelaneTodos, CATEGORY_DEFINITIONS, CATEGORY_SPECS, type CategoryGap, type CategoryGapResult, type CategorySignOptions, type CategorySpec, type CategoryTagPlan, type CategoryTagPlanVariant, type CategoryTagPlanVariantId, DIRECTIONAL_PARKING_INFERENCE_CATEGORIES, type GapDiscriminator, type ListTargetCategoriesOptions, MAJOR_ROAD_CLASSES, MARKING_ALLOWED, MINOR_ROAD_CLASSES, type OsmTags, PARKING_ALLOWED, PATH_CLASSES, PROTECTIVE_SEPARATION, type PlanLifecycle, type PlanTagsForCategoryOptions, ROAD_TODOS, type RoadTodoDefinition, type RoadTodoResult, SEPARATION_ALLOWED, SIDEPATH_HIGHWAY_CLASSES, SURFACE_ALLOWED, SURFACE_COLOR_ALLOWED, TAG_REASON_CODES, TRAFFIC_MODE_ALLOWED, TRUNK_MOTORWAY_CLASSES, type TagChangeEntry, type TagConflictEntry, type TagPlanEntry, type TagReason, type TagReasonCode, type TodoTagFix, UnknownTargetCategoryError, analyzeCategoryGaps, categorizeBikelane, categorySidePrefix, categorySignOptions, defaultSideRunsAgainstWay, deriveBikelaneTodos, deriveRoadTodos, getTransformedObjects, isIncompleteCategoryId, isUnusualWidth, listTargetCategories, parseLength, parseWidth, planTagVariantsForCategory, planTagsForCategory, prepareTags, processBikelanes, specsWithGapDiscriminators, writeKeyForSide };
|