From b4bbaf3109fbcd9835410d11345043a0fa24db90 Mon Sep 17 00:00:00 2001 From: Janez T Date: Mon, 27 Oct 2025 21:55:00 +0100 Subject: [PATCH] feat: Implement language-based filtering for WMS layers in Slovenian and Croatian --- CLAUDE.md | 25 +++++++++ lib/screens/map_tab.dart | 107 ++++++++++++++++++++------------------- 2 files changed, 81 insertions(+), 51 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 09f8b1e..cbd0b56 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -586,6 +586,7 @@ org.gradle.jvmargs=-Xmx4096m - Bounds: X: 373217.65-695777.65m, Y: 31118.30-246158.30m - Origin: Top-left (373217.65, 246158.30) - Resolutions: Calculated from scale denominators (420m/px at zoom 0 to 0.028m/px at zoom 15) +- **Language Filter**: Only shown when app language is Slovenian (sl) or Croatian (hr) **Tile Caching**: - All WMS layers (base + overlays) use `flutter_map_tile_caching` @@ -617,6 +618,8 @@ TileLayer( #### Overview The app integrates Slovenian government WMS (Web Map Service) layers using a custom EPSG:3794 coordinate reference system. This enables high-resolution aerial imagery and specialized overlays (cadastral parcels, forest roads) for SAR operations in Slovenia. +**Language-Based Filtering**: WMS layers are only shown to users when the app language is set to Slovenian (sl) or Croatian (hr), since these layers only cover Slovenia geographically and are irrelevant to users in other regions. + #### Architecture **Layer Types**: @@ -700,6 +703,28 @@ FMTCTileProvider getTileProviderForWms(MapLayer layer) { #### Usage in Map +**Language Filtering** (`lib/screens/map_tab.dart`): + +The following UI elements are only visible when `localeName == 'sl' || localeName == 'hr'`: +1. **Slovenian Aerial 2024 layer** in the base layer selector +2. **Cadastral Parcels overlay toggle** in map options +3. **Forest Roads overlay toggle** in map options +4. **WMS Overlays section divider** and header + +```dart +// Implementation pattern +final locale = AppLocalizations.of(context)!.localeName; +if (locale == 'sl' || locale == 'hr') { + // Show WMS layer option + ListTile( + title: Text(_slovenianAerialLayer.name), + // ... + ); +} +``` + +This ensures users in other regions (English, German, French, Spanish, Italian) don't see geographically irrelevant layers. + **Base Layer** (`lib/screens/map_tab.dart`): ```dart if (_currentLayer.isWms && _currentLayer.crs != null) { diff --git a/lib/screens/map_tab.dart b/lib/screens/map_tab.dart index 7d3677d..03020eb 100644 --- a/lib/screens/map_tab.dart +++ b/lib/screens/map_tab.dart @@ -545,21 +545,23 @@ class _MapTabState extends State with AutomaticKeepAliveClientMixin { Navigator.pop(context); }, )), - // Slovenian WMS base layer - ListTile( - leading: _currentLayer == _slovenianAerialLayer - ? const Icon(Icons.check_circle, color: Colors.green) - : const Icon(Icons.radio_button_unchecked), - title: Text(_slovenianAerialLayer.name), - subtitle: Text(_slovenianAerialLayer.attribution), - onTap: () async { - setState(() { - _currentLayer = _slovenianAerialLayer; - }); - _saveSettings(); - Navigator.pop(context); - }, - ), + // Slovenian WMS base layer (only for Slovenian/Croatian regions) + if (AppLocalizations.of(context)!.localeName == 'sl' || + AppLocalizations.of(context)!.localeName == 'hr') + ListTile( + leading: _currentLayer == _slovenianAerialLayer + ? const Icon(Icons.check_circle, color: Colors.green) + : const Icon(Icons.radio_button_unchecked), + title: Text(_slovenianAerialLayer.name), + subtitle: Text(_slovenianAerialLayer.attribution), + onTap: () async { + setState(() { + _currentLayer = _slovenianAerialLayer; + }); + _saveSettings(); + Navigator.pop(context); + }, + ), // Offline MBTiles layers section if (_mbtilesLayers.isNotEmpty) ...[ const Divider(), @@ -599,43 +601,46 @@ class _MapTabState extends State with AutomaticKeepAliveClientMixin { }, )), ], - // WMS Overlays section - const Divider(), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), - child: Text( - AppLocalizations.of(context)!.wmsOverlays, - style: Theme.of(context).textTheme.labelLarge?.copyWith( - color: Colors.grey[600], - ), + // WMS Overlays section (only for Slovenian/Croatian regions) + if (AppLocalizations.of(context)!.localeName == 'sl' || + AppLocalizations.of(context)!.localeName == 'hr') ...[ + const Divider(), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + child: Text( + AppLocalizations.of(context)!.wmsOverlays, + style: Theme.of(context).textTheme.labelLarge?.copyWith( + color: Colors.grey[600], + ), + ), ), - ), - Consumer( - builder: (context, mapProvider, _) { - return Column( - children: [ - CheckboxListTile( - secondary: const Icon(Icons.grid_on, color: Colors.blue), - title: Text(AppLocalizations.of(context)!.cadastralParcels), - subtitle: const Text('© GURS'), - value: mapProvider.showCadastralOverlay, - onChanged: (value) { - mapProvider.toggleCadastralOverlay(); - }, - ), - CheckboxListTile( - secondary: const Icon(Icons.route, color: Colors.green), - title: Text(AppLocalizations.of(context)!.forestRoads), - subtitle: const Text('© GURS'), - value: mapProvider.showForestRoadsOverlay, - onChanged: (value) { - mapProvider.toggleForestRoadsOverlay(); - }, - ), - ], - ); - }, - ), + Consumer( + builder: (context, mapProvider, _) { + return Column( + children: [ + CheckboxListTile( + secondary: const Icon(Icons.grid_on, color: Colors.blue), + title: Text(AppLocalizations.of(context)!.cadastralParcels), + subtitle: const Text('© GURS'), + value: mapProvider.showCadastralOverlay, + onChanged: (value) { + mapProvider.toggleCadastralOverlay(); + }, + ), + CheckboxListTile( + secondary: const Icon(Icons.route, color: Colors.green), + title: Text(AppLocalizations.of(context)!.forestRoads), + subtitle: const Text('© GURS'), + value: mapProvider.showForestRoadsOverlay, + onChanged: (value) { + mapProvider.toggleForestRoadsOverlay(); + }, + ), + ], + ); + }, + ), + ], ], ), ),