mirror of
https://github.com/FoggedLens/deflock-app.git
synced 2026-08-17 16:37:31 +02:00
profile filtering and submissions fixes
This commit is contained in:
@@ -18,14 +18,16 @@ class PendingUpload {
|
|||||||
'lat': coord.latitude,
|
'lat': coord.latitude,
|
||||||
'lon': coord.longitude,
|
'lon': coord.longitude,
|
||||||
'dir': direction,
|
'dir': direction,
|
||||||
'profile': profile.name,
|
'profile': profile.toJson(),
|
||||||
'attempts': attempts,
|
'attempts': attempts,
|
||||||
};
|
};
|
||||||
|
|
||||||
factory PendingUpload.fromJson(Map<String, dynamic> j) => PendingUpload(
|
factory PendingUpload.fromJson(Map<String, dynamic> j) => PendingUpload(
|
||||||
coord: LatLng(j['lat'], j['lon']),
|
coord: LatLng(j['lat'], j['lon']),
|
||||||
direction: j['dir'],
|
direction: j['dir'],
|
||||||
profile: CameraProfile.alpr(), // only built‑in for now
|
profile: j['profile'] is Map<String, dynamic>
|
||||||
|
? CameraProfile.fromJson(j['profile'])
|
||||||
|
: CameraProfile.alpr(), // fallback for legacy, more logic can be added
|
||||||
attempts: j['attempts'] ?? 0,
|
attempts: j['attempts'] ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,21 +15,18 @@ class OverpassService {
|
|||||||
) async {
|
) async {
|
||||||
if (profiles.isEmpty) return [];
|
if (profiles.isEmpty) return [];
|
||||||
|
|
||||||
// Build regex of surveillance:type values from enabled profiles
|
// Build one node query per enabled profile (each with all its tags required)
|
||||||
final types = profiles
|
final nodeClauses = profiles.map((profile) {
|
||||||
.map((p) => p.tags['surveillance:type'])
|
final tagFilters = profile.tags.entries
|
||||||
.whereType<String>()
|
.map((e) => '["${e.key}"="${e.value}"]')
|
||||||
.toSet();
|
.join('\n ');
|
||||||
final regex = types.join('|');
|
return '''node\n $tagFilters\n (${bbox.southWest.latitude},${bbox.southWest.longitude},\n ${bbox.northEast.latitude},${bbox.northEast.longitude});''';
|
||||||
|
}).join('\n ');
|
||||||
|
|
||||||
final query = '''
|
final query = '''
|
||||||
[out:json][timeout:25];
|
[out:json][timeout:25];
|
||||||
(
|
(
|
||||||
node
|
$nodeClauses
|
||||||
["man_made"="surveillance"]
|
|
||||||
["surveillance:type"~"^(${regex})\$"]
|
|
||||||
(${bbox.southWest.latitude},${bbox.southWest.longitude},
|
|
||||||
${bbox.northEast.latitude},${bbox.northEast.longitude});
|
|
||||||
);
|
);
|
||||||
out body 250;
|
out body 250;
|
||||||
''';
|
''';
|
||||||
|
|||||||
@@ -32,13 +32,16 @@ class Uploader {
|
|||||||
print('Uploader: Created changeset ID: $csId');
|
print('Uploader: Created changeset ID: $csId');
|
||||||
|
|
||||||
// 2. create node
|
// 2. create node
|
||||||
|
// Merge tags: direction in PendingUpload should always be present,
|
||||||
|
// and override any in the profile for upload purposes
|
||||||
|
final mergedTags = Map<String, String>.from(p.profile.tags)
|
||||||
|
..['direction'] = p.direction.round().toString();
|
||||||
|
final tagsXml = mergedTags.entries.map((e) =>
|
||||||
|
'<tag k="${e.key}" v="${e.value}"/>').join('\n ');
|
||||||
final nodeXml = '''
|
final nodeXml = '''
|
||||||
<osm>
|
<osm>
|
||||||
<node changeset="$csId" lat="${p.coord.latitude}" lon="${p.coord.longitude}">
|
<node changeset="$csId" lat="${p.coord.latitude}" lon="${p.coord.longitude}">
|
||||||
<tag k="man_made" v="surveillance"/>
|
$tagsXml
|
||||||
<tag k="surveillance:type" v="ALPR"/>
|
|
||||||
<tag k="camera:type" v="fixed"/>
|
|
||||||
<tag k="direction" v="${p.direction.round()}"/>
|
|
||||||
</node>
|
</node>
|
||||||
</osm>''';
|
</osm>''';
|
||||||
print('Uploader: Creating node...');
|
print('Uploader: Creating node...');
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class AddCameraSheet extends StatelessWidget {
|
|||||||
title: const Text('Profile'),
|
title: const Text('Profile'),
|
||||||
trailing: DropdownButton<CameraProfile>(
|
trailing: DropdownButton<CameraProfile>(
|
||||||
value: session.profile,
|
value: session.profile,
|
||||||
items: appState.profiles
|
items: appState.enabledProfiles
|
||||||
.map((p) => DropdownMenuItem(value: p, child: Text(p.name)))
|
.map((p) => DropdownMenuItem(value: p, child: Text(p.name)))
|
||||||
.toList(),
|
.toList(),
|
||||||
onChanged: (p) =>
|
onChanged: (p) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user