feat: implement est_width parsing and sidebar display - #289
Conversation
| ) : ( | ||
| <code>{secureWidthSource}</code> | ||
| )} | ||
| {properties[widthConfidence] && ( |
| 'traffic_sign:backward', | ||
| 'confidence', // true key is `maxspeed_confidence`, `surface_confidence`, … but we overwrite that when passing props | ||
| 'width_source', | ||
| 'width_confidence', |
| { column = 'width_confidence', type = 'text' }, | ||
| { column = 'width_source', type = 'text' }, |
There was a problem hiding this comment.
Regel: Unsere Tabellen haben immer den gleichen Shape id, tags, meta, geom, minzoom
| FROM information_schema.columns | ||
| WHERE table_name = '${tableName}' | ||
| AND column_name IN ('osm_id', 'osm_type') | ||
| AND column_name IN ('osm_id', 'osm_type', 'width_confidence', 'width_source') |
| @@ -0,0 +1,87 @@ | |||
| describe("parse_width", function() | |||
| require('init') | |||
| require('init') | ||
| require('osm2pgsql') | ||
|
|
||
| local logged_errors = {} |
| -- return osm2pgsql.define_table(_options) | ||
| -- end | ||
|
|
||
| function osm2pgsql.define_table(options) |
| @@ -0,0 +1,101 @@ | |||
| describe('RoadClassification', function() | |||
There was a problem hiding this comment.
fehlt inner describe blcok weil alels ja nicht road clas.… teste sondern with
| local width = nil | ||
| local width_confidence = nil | ||
|
|
||
| if object_tags.width then |
There was a problem hiding this comment.
Refactor to local function surface_direct(tags)
Nach Rebase:
width = parse_length(object_tags.width),
width_source = SANITIZE_TAGS.safe_string(object_tags['source:width']),
width_effective = parse_length(object_tags['width:effective']),
neues muster:
local FOO = derive_witdth(tags)
local result_tags = {
width = foo.width
width_source = FOO.source
width_confience = foo.conficnde
}
local surface_tags_result = SURFACE_TAGS.surface_tags_with_parent(object.tags, object._parent_tags)
…
surface = surface_tags_result.value,
surface_confidence = surface_tags_result.confidence,
surface_source = surface_tags_result.source,
| # Make sure we have the latest lua path at hand. | ||
| # Szenario: We just added a lua helper in a new folder but did not run the full processing, yet | ||
| bun run ./processing/run-tests-update-lua-package-paths.ts | ||
| NODE_PATH=./app/node_modules bun run ./processing/run-tests-update-lua-package-paths.ts |
There was a problem hiding this comment.
raus, bun verwendne
brew install bun
2a75126 to
f6c89bc
Compare
2e74a65 to
459574e
Compare
459574e to
f864b1a
Compare
- Roads show measured vs estimated width confidence in the inspector - Width metadata stays in tags (no extra DB columns or export hacks) - Reuse existing parse_length and TagsTableRowValueSourceConfidence patterns Ping FixMyBerlin#289 Co-authored-by: Cursor <cursoragent@cursor.com>
- Unblocks pre-push knip on feature branches Ping FixMyBerlin#289 Co-authored-by: Cursor <cursoragent@cursor.com>
|
Taking this over with a clean rebuild on current Please close this draft when convenient — thanks for the first pass and the grill process on the plan. |
|
Replacement PR: #362 |
|
Continuing at #362 |
Co-authored-by: Cursor <cursoragent@cursor.com>
bunx tsc was resolving to a global TypeScript 5 install on WSL instead of the project's TypeScript 6 package, which only exposes the tsc6 bin. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- Roads show measured vs estimated width confidence in the inspector - Width metadata stays in tags (no extra DB columns or export hacks) - Reuse existing parse_length and TagsTableRowValueSourceConfidence patterns Ping FixMyBerlin#289 Co-authored-by: Cursor <cursoragent@cursor.com>
- Unblocks pre-push knip on feature branches Ping FixMyBerlin#289 Co-authored-by: Cursor <cursoragent@cursor.com>
f38a3c8 to
02dc35c
Compare
tordans
left a comment
There was a problem hiding this comment.
Erste Blick sieht gut aus.
| "@clack/prompts": "1.7.0", | ||
| "@faker-js/faker": "^10.5.0", | ||
| "@heroicons/react": "2.2.0", | ||
| "@maplibre/maplibre-gl-style-spec": "^24.8.1", |
There was a problem hiding this comment.
Höchstwahrscheinlich falsch, dass das entfernt wurde. Könnte daran liegen, dass du den Symlink zu dem Static Data Repo nicht aktiv hast. (Siehe bun run somethingsomethign-symlink)
| }) | ||
| assert.are.same(result, { | ||
| width = 5, | ||
| width_source = nil, |
There was a problem hiding this comment.
Hier müsste jetzt IMO etwas stehen wie
| width_source = nil, | |
| width_source = 'tag_est_width', |
Siehe die anderen _source Werte: Die _source ist immer ein Enum mit Werten für diesen Case. Bzw. manchmal ein Freitext. Hier könnten wir einen Case haben, wo es eine Mischung ist. Bin unsicher, ob wir so etwas schon haben im System, aber es müsst auch in den Docs gehen dass man sagt Entweder Enum oder Sanitized Freitext
| ---@param tags OsmTags | ||
| ---@return DeriveWidthResultUnion | ||
| local function derive_width(tags) | ||
| local width_source = SANITIZE_TAGS.safe_string(tags['source:width']) |
There was a problem hiding this comment.
Note to self: Das passt
| if width then | ||
| return { | ||
| width = width, | ||
| width_source = width_source, |
There was a problem hiding this comment.
| width_source = width_source, | |
| width_source = width_source or 'tag_width', |
Fallback: Enum
| } | ||
| end | ||
|
|
||
| width = parse_length(tags.est_width) |
There was a problem hiding this comment.
| width = parse_length(tags.est_width) | |
| width = parse_length(tags.est_width) | |
| local est_width_source = SANITIZE_TAGS.safe_string(tags['source:est_width']) |
https://taginfo.geofabrik.de/europe:germany/keys/source%3Aest_width
| if width then | ||
| return { | ||
| width = width, | ||
| width_source = width_source, |
There was a problem hiding this comment.
| width_source = width_source, | |
| width_source = est_width_source or width_source or 'est_width_tag', |
Default müsste source:est_width sein; einige Mapper könnten aber trotzdem source:width verwenden; Fallback dann das Enum.
| description: Wert stammt aus dem OSM-Tag `width`. | ||
| - value: low | ||
| label: Geschätzt | ||
| description: Wert stammt aus dem OSM-Tag `est_width`, weil `width` fehlt oder nicht geparst werden konnte. |
There was a problem hiding this comment.
| description: Wert stammt aus dem OSM-Tag `est_width`, weil `width` fehlt oder nicht geparst werden konnte. | |
| description: Wert stammt aus dem OSM-Tag `est_width`. |
| format: sanitized_strings | ||
| values: | ||
| - value: ALKIS | ||
| label: Aus ALKIS Daten ausgemessen | ||
| - value: ARCore | ||
| label: Mit dem Handy-Metermaß von StreetComplete gemessen |
There was a problem hiding this comment.
Ah, wir haben es schon so angelegt dass es sanitized_strings UND enum ist. Und haben sogar bestimmte Felder übersetzt. Kann man so machen… dann fügen wir hier einfach unsere ENUM Werte mit ein.
So hier jetzt das Erste:
https://github.com/FixMyBerlin/private-issues/issues/280
Ist hauptsaechlich gevibecoded also ich verstehe auch nicht alles weil ich mich auch nicht tief genug in Tilda eingearbeitet habe.
Habe aber den Implementation plan immer schoen durch einen Grill Prozess durch geschickt.
PR Review: dev-est_width
Branch Summary
developcmandm), falls back toest_widthwhen the defaultwidthtag is missing, logs parsing errors to a dedicated database table, and displays the width's confidence and source in the sidebar inspector and export files.Changed Files (19 total)
parse_width.lua250 cm->2.5 m) and normalizing decimals.width_errors.luawidth_errors) to log unparsable width tags.RoadClassification.luawidth->est_width, settingwidth_confidenceandwidth_source.roads_bikelanes.luawidth_confidenceandwidth_sourcecolumns toroads/roadsPathClassestables.ExcludeByWidth.luaparse_widthutility.RoadWidth.luaTagsTableRowCompositWidth.tsxtranslationsWdith.const.tswidth_confidence(Geschätzt,Direkt gemessen) and common sources.ConditionalFormattedValue.tsxwidth_confidenceandwidth_source.export.$regionSlug.$tableName.tswidth_confidenceandwidth_sourcecolumns in exports.ParseWidth.test.luaRoadClassification.test.lua.genfilesImplementation Details & Code Highlights
1. Robust Unit Parsing (
parse_width.lua)We normalize comma decimals and convert non-meter units like
cmorkmto meter floats:2. OSM Metadata Fallback (
RoadClassification.lua)We fallback to
est_widthifwidthis empty/unparsable, and assignhighvslowconfidence categories:3. Database Schema Migration (
roads_bikelanes.lua)The parsed attributes are saved into dedicated columns on the
roadsandroadsPathClassestables:4. Inline Inspector Display (
TagsTableRowCompositWidth.tsx)In the sidebar inspector, we display the source and the confidence value inline in parentheses inside a collapsible disclosure:
Output Example:
Quelle: Orthofoto 2024 (Direkt gemessen)