import 'package:manager_api_new/api.dart'; /// Centre d'affichage d'une SectionMap. /// /// Priorité : le point « Centrer sur » configuré dans manager-app /// (`centerLatitude`/`centerLongitude`, `map_config.dart`) — puis, à défaut, le /// point GPS de la section (`latitude`/`longitude`, qui sert au beacon et à la /// zone de déclenchement, pas au cadrage) — puis un centre par défaut. /// /// Miroir de `MapSection.tsx` côté visitapp-web. class MapCenter { static const double defaultLatitude = 50.465503; static const double defaultLongitude = 4.865105; final double latitude; final double longitude; const MapCenter(this.latitude, this.longitude); static MapCenter of(MapDTO? map) { final center = _parse(map?.centerLatitude, map?.centerLongitude); if (center != null) return center; final sectionPoint = _parse(map?.latitude, map?.longitude); if (sectionPoint != null) return sectionPoint; return const MapCenter(defaultLatitude, defaultLongitude); } static MapCenter? _parse(String? latitude, String? longitude) { if (latitude == null || longitude == null) return null; final lat = double.tryParse(latitude); final lng = double.tryParse(longitude); if (lat == null || lng == null) return null; return MapCenter(lat, lng); } }