Add elevation and country code lookup functionality to map components#233
Add elevation and country code lookup functionality to map components#233Claudio-Chies wants to merge 2 commits intodbrgn:mainfrom
Conversation
|
In Action: Screencast.from.2026-01-26.14-58-19.mp4 |
WalkthroughAdds map-based elevation and country lookups: BaseMap queries terrain contours and country boundaries after marker moves and emits results via new onElevationLookup and onCountryLookup callbacks propagated through SingleMap to LocationForm for form updates and hints. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SingleMap
participant BaseMap
participant DataLayers as Terrain & Countries
participant LocationForm
User->>SingleMap: drag marker / change position
activate SingleMap
SingleMap->>BaseMap: forward position update
activate BaseMap
BaseMap->>DataLayers: queryElevation(coords)
BaseMap->>DataLayers: queryCountryCode(coords)
activate DataLayers
DataLayers-->>BaseMap: elevation (or null) + zoomTooLow
DataLayers-->>BaseMap: countryCode (or null)
deactivate DataLayers
BaseMap-->>SingleMap: onElevationLookup({elevation, zoomTooLow})
BaseMap-->>SingleMap: onCountryLookup({countryCode})
deactivate BaseMap
SingleMap-->>LocationForm: forward lookup events
deactivate SingleMap
activate LocationForm
LocationForm->>LocationForm: set elevation / set hint / set countryCode
deactivate LocationForm
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/src/routes/locations/LocationForm.svelte (1)
237-241: Bug: wrong field error displayed for name field.The error message displays
fieldErrors.longitudeinstead offieldErrors.name.🐛 Proposed fix
{`#if` fieldErrors.name !== undefined} <div class="field-error"> - {$i18n.t('common.error', {message: fieldErrors.longitude})} + {$i18n.t('common.error', {message: fieldErrors.name})} </div> {/if}
🤖 Fix all issues with AI agents
In `@frontend/src/translations/de/translation.json`:
- Line 223: Run the i18n parser locally and commit the sync changes: execute the
project command npm run i18n:parse, review the generated updates to translation
files (ensure the translation key "hint--zoom-in-elevation" and other keys are
updated), add and commit the resulting files, and push the branch so CI no
longer reports translations out of sync.
In `@frontend/src/translations/en/translation.json`:
- Around line 223-224: Remove the extra blank line before the
"hint--zoom-in-elevation" translation key to match the project's i18n formatting
and then run the parser to regenerate translation artifacts: run `npm run
i18n:parse` locally (this will re-sync translation files), review the generated
changes, and commit them; ensure the translation key "hint--zoom-in-elevation"
is adjacent to the surrounding entries with no stray blank line so the i18n sync
pipeline passes.
🧹 Nitpick comments (2)
frontend/src/routes/locations/LocationForm.svelte (1)
41-47: Consider clearing countryCode when lookup returns null for consistency.The
handleElevationLookupclearselevationwhen the lookup returns null, buthandleCountryLookupdoes not clearcountryCode. This creates asymmetric behavior. If the marker is placed over international waters or an area without country data, the previous country code persists while elevation is cleared.Consider whether the country code should also be cleared when the lookup returns null:
♻️ Optional: Clear countryCode when null
function handleCountryLookup(data: {countryCode: string | null}) { const {countryCode: newCountryCode} = data; if (newCountryCode !== null) { countryCode = newCountryCode; + } else { + countryCode = ''; } }frontend/src/lib/components/BaseMap.svelte (1)
329-359: Consider tile loading timing for lookups.The data layers are initialized on
style.load, but tiles may not be fully loaded when the user first interacts with the marker. IfqueryRenderedFeaturesis called before the tiles forterrain-contours-dataorcountries-dataare loaded at the marker's location, it will return empty results.This is likely acceptable since:
- Users typically zoom/pan before placing markers, allowing tiles to load
- The UI handles null results gracefully (shows hint for elevation)
However, consider noting this behavior in the hint message or triggering a re-lookup when the user zooms/pans to load new tiles.
Auto-fill elevation and country code when placing location marker
Description
When adding or editing a location, the elevation and country code fields are now automatically filled when the user places a marker on the map (via double-click/tap or by dragging).
This re-implements the proposed changes from #198 in a less invasive way, no version bump, same structure
Changes
Key Differences to PR #198
Notes
Closes #55
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.