feat: Implement language-based filtering for WMS layers in Slovenian and Croatian

This commit is contained in:
Janez T
2025-10-27 21:55:00 +01:00
parent a4dc85d130
commit b4bbaf3109
2 changed files with 81 additions and 51 deletions

View File

@@ -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) {

View File

@@ -545,21 +545,23 @@ class _MapTabState extends State<MapTab> 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<MapTab> 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<MapProvider>(
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<MapProvider>(
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();
},
),
],
);
},
),
],
],
),
),