Skip to content
Snippets Groups Projects
Commit 6c59aee0 authored by Sara Savanovic Djordjevic's avatar Sara Savanovic Djordjevic
Browse files

fix: addition of no measurement subdivs

parent b6ad7b70
No related branches found
No related tags found
1 merge request!13Clhp map
......@@ -72,8 +72,8 @@ class SubDiv {
return SubDiv(
sub_div_id: json['SubdivID'].toString(),
groupID: json['GroupID'] ?? 0,
minThickness: json['MinThickness'].toDouble() ?? 0.0,
avgThickness: json['AvgThickness'].toDouble() ?? 0.0,
minThickness: json['MinThickness'] ?? 0,
avgThickness: json['AvgThickness'] ?? 0,
center: json['CenLatitude'] != null && json['CenLongitude'] != null
? LatLng(json['CenLatitude'], json['CenLongitude'])
: LatLng(0.0, 0.0),
......
......@@ -5,16 +5,6 @@ import 'package:syncfusion_flutter_maps/maps.dart';
import '../data_classes.dart';
/// A class containing thickness data for each subdivision of the map.
class IceThicknessModel {
IceThicknessModel(this.sub_div_id, this.thickness, this.color, this.savedColor);
final String sub_div_id;
final int thickness;
Color color;
final Color savedColor;
}
/// ChoroplethMap is a stateful widget that contains a choropleth map.
/// The map is created using the Syncfusion Flutter Maps library and
/// coordinates fetched from the server.
......@@ -35,10 +25,9 @@ class ChoroplethMap extends StatefulWidget {
class _ChoroplethMapState extends State<ChoroplethMap> {
int _selectedIndex = -1; // Subdivision/map tile index
Color _selectedColor = Colors.grey; // Initialise to gray
late MapShapeSource _dataSource;
late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior();
List<SubDiv> _subdivisions = <SubDiv>[];
final List<SubDiv> _subdivisions = <SubDiv>[];
@override
void initState() {
......@@ -55,11 +44,14 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
widget.relation,
shapeDataField: 'sub_div_id',
dataCount: _subdivisions.length,
primaryValueMapper: (int index) =>
_subdivisions[index].sub_div_id,
shapeColorValueMapper: (int index) =>
_subdivisions[index].avgThickness, // NB will later be minThickness, fix in server first
primaryValueMapper: (int index) => _subdivisions[index].sub_div_id,
shapeColorValueMapper: (int index) => _subdivisions[index].avgThickness, // NB will later be minThickness
shapeColorMappers: const [
MapColorMapper(
from: -2,
to: -1,
color: Color(0xFF8C8C8C),
text: '>8'),
MapColorMapper(
from: 0,
to: 4,
......@@ -91,7 +83,6 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
children: [
SfMapsTheme(
data: SfMapsThemeData( // Coloring of selected shape
selectionColor: _selectedColor,
selectionStrokeWidth: 3.5,
selectionStrokeColor: Colors.blue[600],
),
......@@ -107,7 +98,6 @@ class _ChoroplethMapState extends State<ChoroplethMap> {
onSelectionChanged: (int index) {
setState(() {
_selectedIndex = index;
_selectedColor = _subdivisions[index].color;
});
widget.onSelectionChanged(_selectedIndex);
},
......
No preview for this file type
......@@ -156,7 +156,6 @@ def validate_cords(easting, northing):
default_x, default_y = 266707, 6749365
if not (100000 <= easting <= 900000) or not (0 <= northing <= 10000000):
print("cords given are made default to middle of lake mjosa")
easting, northing = default_x, default_y
else:
print("cords are kept")
......
This diff is collapsed.
No preview for this file type
......@@ -123,8 +123,8 @@ def fill_remaining_subdivisions(lake_name: str, sub_div_ids: list):
sub_divisions = []
for sub_div in relation['features']:
if sub_div['properties']['sub_div_id'] not in sub_div_ids:
sub_div_id = sub_div['properties']['sub_div_id']
sub_div_id = int(sub_div['properties']['sub_div_id'])
if sub_div_id not in sub_div_ids:
center_lat = sub_div['properties']['sub_div_center'][0]
center_lng = sub_div['properties']['sub_div_center'][1]
......@@ -133,12 +133,12 @@ def fill_remaining_subdivisions(lake_name: str, sub_div_ids: list):
sub_division = {
'SubdivID': sub_div_id,
'GroupID': None,
'MinThickness': 0.0, # NB placeholders
'AvgThickness': 0.0,
'MinThickness': -1.0, # NB placeholders
'AvgThickness': -1.0,
'CenLatitude': center_lat,
'CenLongitude': center_lng,
'Accuracy': None,
'Color': 0xFF939393, # NB placeholder
'Color': 0xFF00d6ff, # NB placeholder
'IceStats': ice_stats,
}
......@@ -162,4 +162,4 @@ def calculateColor(thickness: float): # NB neither final colors nor ranges
elif thickness > 8:
return 0xFF00d6ff # Blue
else:
return 0xFF939393 # Grey
return 0xFF8C8C8C # Grey
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment