diff --git a/app/lib/pages/widgets/cloropleth_map.dart b/app/lib/pages/widgets/cloropleth_map.dart index 55afa8df331cbf51ff6643185f8f699f57cb4639..632a504b862781e697b7e34bb79a4ef6daccdf57 100644 --- a/app/lib/pages/widgets/cloropleth_map.dart +++ b/app/lib/pages/widgets/cloropleth_map.dart @@ -7,10 +7,11 @@ import 'dart:convert'; /// A class containing thickness data for each subdivision of the map. class IceThicknessModel { - IceThicknessModel(this.subDivID, this.thickness); + IceThicknessModel(this.sub_div_id, this.thickness, this.color); - final String subDivID; + final String sub_div_id; final int thickness; + final Color color; } /// ChoroplethMap is a stateful widget that contains a choropleth map. @@ -30,6 +31,7 @@ class ChoroplethMap extends StatefulWidget { } class _ChoroplethMapState extends State<ChoroplethMap> { + int selectedIndex = -1; late MapShapeSource mapShapeSource; late final MapZoomPanBehavior _zoomPanBehavior = MapZoomPanBehavior(); List<IceThicknessModel> iceThicknessList = <IceThicknessModel>[]; @@ -39,9 +41,15 @@ class _ChoroplethMapState extends State<ChoroplethMap> { super.initState(); final Random random = Random(); - for (int i = 0; i <= 60; i++) { + for (int i = 0; i <= 120; i++) { + int red = random.nextInt(256); + int green = random.nextInt(256); + int blue = random.nextInt(256); + + Color randomColor = Color.fromRGBO(red, green, blue, 1); + int randomNumber = random.nextInt(21); // 0 -> 20, NB: temp test data - iceThicknessList.add(IceThicknessModel(i.toString(), randomNumber)); + iceThicknessList.add(IceThicknessModel(i.toString(), randomNumber, randomColor)); } } @@ -54,14 +62,27 @@ class _ChoroplethMapState extends State<ChoroplethMap> { MapShapeLayer( source: MapShapeSource.memory( // Map polygon widget.relation, // JSON coordinates from server - shapeDataField: 'properties.sub_div_id', + shapeDataField: 'sub_div_id', dataCount: iceThicknessList.length, - primaryValueMapper: (int index) => iceThicknessList[index].subDivID, - shapeColorValueMapper: (int index) => iceThicknessList[index].thickness, + primaryValueMapper: (int index) => iceThicknessList[index].sub_div_id, + shapeColorValueMapper: (int index) => iceThicknessList[index].color, + ), + //color: Colors.blue.shade400, // Map color + //zoomPanBehavior: _zoomPanBehavior, + //strokeColor: Colors.black, + // Shape selection + selectedIndex: selectedIndex, + onSelectionChanged: (int index) { + setState(() { + selectedIndex = index; + }); + print("Selection triggered"); + }, + selectionSettings: MapSelectionSettings( + color: Colors.orange, + strokeColor: Colors.red[900], + strokeWidth: 3, ), - color: Colors.blue.shade400, // Map color - zoomPanBehavior: _zoomPanBehavior, - strokeColor: Colors.black, ), ], ), diff --git a/server/map/__pycache__/get_relation.cpython-311.pyc b/server/map/__pycache__/get_relation.cpython-311.pyc index aa9d38516dd833f6e5af95e22894dbd1ee066866..5fa72e24fbe220c417ab4c9ccf18c4749e3298ba 100644 Binary files a/server/map/__pycache__/get_relation.cpython-311.pyc and b/server/map/__pycache__/get_relation.cpython-311.pyc differ diff --git a/server/map/get_relation.py b/server/map/get_relation.py index 5a384e045cd8e56f24157fa4dc012ccef024e3a1..0df98873d90597269dbcf16f6b5956bfb0d6d6fc 100644 --- a/server/map/get_relation.py +++ b/server/map/get_relation.py @@ -28,6 +28,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water divided_map.extend(combine_grid_with_poly(polygon, lines)) + ''' ####################### PLOTTIND ############################ tiles = [gpd.GeoDataFrame(geometry=[tile]) for tile in divided_map] @@ -44,6 +45,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water plt.show() ##################### PLOTTIND END ########################### + ''' features = [] @@ -62,7 +64,7 @@ def get_relation(self, body_of_water: str): # NB: implement body_of_water tile_feature = { 'type': 'Feature', 'properties': { - 'sub_div_id': sub_div_id, + 'sub_div_id': str(sub_div_id), 'sub_div_center': center }, 'geometry': rounded_tile.__geo_interface__