Custom icons, improved GPS, history layout, address fixes

- Replace placeholder SVG icons with custom PNG icons (80x80 padded)
- AffineTransform for pixel-perfect icon centering in menu ring
- Colored circles behind icons with icon drawn at 60% size
- GPS: always wait full timeout (30s), keep best quality fix
- History: show address, PLZ+city, coordinates on separate lines
- Geocoding: fall back to "name" field for street-level results,
  include PLZ+city in cached address data
- 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 19:05:17 +02:00
parent 79cdb9f210
commit 216d40c2c5
18 changed files with 108 additions and 101 deletions

View file

@ -2,15 +2,15 @@ import Toybox.Communications;
import Toybox.Lang;
// Reverse-geocodes a lat/lon pair via Photon API. Calls back with
// a formatted address string or null on failure.
// a Dictionary { "addr" => String, "zip" => String } or null.
class GeocodingService {
private var _callback as Method(address as String or Null) as Void;
private var _callback as Method(result as Dictionary or Null) as Void;
private var _lat as Float;
private var _lon as Float;
function initialize(lat as Float, lon as Float,
callback as Method(address as String or Null) as Void) {
callback as Method(result as Dictionary or Null) as Void) {
_callback = callback;
_lat = lat;
_lon = lon;
@ -28,16 +28,13 @@ 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;
}
@ -45,7 +42,6 @@ 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) {
@ -54,31 +50,38 @@ 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;
}
}
}
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 parts = "";
if (street != null) {
parts = street as String;
if (number != null) {
parts = parts + " " + number;
}
if (street == null) { street = props["name"]; }
if (street == null) {
_callback.invoke(null);
return;
}
return parts.equals("") ? "Unbekannt" : parts;
var addr = street as String;
var number = props["housenumber"];
if (number != null) {
addr = addr + " " + number;
}
var result = { "addr" => addr } as Dictionary;
var zip = props["postcode"];
var city = props["city"];
if (zip != null || city != null) {
var zipCity = "";
if (zip != null) { zipCity = zip as String; }
if (city != null) {
if (!zipCity.equals("")) { zipCity = zipCity + " "; }
zipCity = zipCity + city;
}
result["zip"] = zipCity;
}
_callback.invoke(result);
}
}