Phase 6: glance widget with cached address

App type changed to widget for glance support. GlanceView shows
event type, date/time, and street+housenumber (or coordinates as
fallback). Addresses are cached in Event storage on first view in
history. Glance-required modules annotated with (:glance). Address
distance threshold raised to 70m.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
EiSiMo 2026-04-13 15:31:46 +02:00
parent eea1a835cd
commit 79cdb9f210
9 changed files with 134 additions and 12 deletions

View file

@ -28,13 +28,16 @@ class GeocodingService {
}
function _onResponse(responseCode as Number, data as Dictionary or String or Null) as Void {
System.println("GEO: responseCode=" + responseCode);
if (responseCode != 200 || data == null || !(data instanceof Dictionary)) {
System.println("GEO: bad response, data=" + data);
_callback.invoke(null);
return;
}
var features = data["features"];
if (features == null || !(features instanceof Array) || features.size() == 0) {
System.println("GEO: no features");
_callback.invoke(null);
return;
}
@ -42,6 +45,7 @@ class GeocodingService {
var feature = features[0] as Dictionary;
var props = feature["properties"] as Dictionary;
var geometry = feature["geometry"] as Dictionary;
System.println("GEO: props=" + props);
// Haversine check: only use address if result is within threshold.
if (geometry != null) {
@ -50,20 +54,23 @@ class GeocodingService {
var rLon = (coords[0] as Double).toFloat();
var rLat = (coords[1] as Double).toFloat();
var dist = Haversine.distance(_lat, _lon, rLat, rLon);
System.println("GEO: dist=" + dist + " max=" + Config.ADDRESS_MAX_DISTANCE_M);
if (dist > Config.ADDRESS_MAX_DISTANCE_M) {
System.println("GEO: too far, rejecting");
_callback.invoke(null);
return;
}
}
}
_callback.invoke(_formatAddress(props));
var addr = _formatAddress(props);
System.println("GEO: address=" + addr);
_callback.invoke(addr);
}
private function _formatAddress(props as Dictionary) as String {
var street = props["street"];
var number = props["housenumber"];
var city = props["city"];
var parts = "";
if (street != null) {
@ -72,12 +79,6 @@ class GeocodingService {
parts = parts + " " + number;
}
}
if (city != null) {
if (!parts.equals("")) {
parts = parts + ", ";
}
parts = parts + city;
}
return parts.equals("") ? "Unbekannt" : parts;
}
}