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

add: last updated at text

parent b7026f45
No related branches found
No related tags found
2 merge requests!5Clhp map,!4Clhp map
......@@ -8,20 +8,21 @@ const String serverURI = "https://127.0.0.1:$port/";
const String mapEndpoint = "update_map";
const int fetchInterval = 60; // Fetch marker data every n minutes
// Map center
// Map variables
LatLng mapCenter = LatLng(60.7666, 10.8471);
DateTime lastUpdate = null!; // Last time marker data was fetched from server
// Font variables
const textColor = Colors.white;
final appTitleStyle = GoogleFonts.dmSans(
fontSize: 35,
color: Colors.black,
fontWeight: FontWeight.bold, // Add this line to make the text bold
fontWeight: FontWeight.bold,
);
final titleStyle = GoogleFonts.dmSans(
fontSize: 35,
color: textColor,
fontWeight: FontWeight.bold, // Add this line to make the text bold
fontWeight: FontWeight.bold,
);
final regTextStyle = GoogleFonts.dmSans(fontSize: 19, color: textColor);
final chartTextStyle = GoogleFonts.dmSans(fontSize: 14, color: textColor);
......
......@@ -35,6 +35,9 @@ Future<List<Measurement>> fetchMarkerData() async {
print('Update time written to file');
} catch (error) { print('Error in writing to file: $error');}
// Update lastUpdate variable
lastUpdate = DateTime.now();
return jsonData.map((data) => Measurement.fromJson(data)).toList();
} else {
throw Exception('Failed to parse marker data: Unexpected response format');
......
......@@ -7,6 +7,7 @@ import 'sat_layer.dart';
import 'package:flutter_map/flutter_map.dart';
import 'cloropleth_map.dart';
import 'dart:typed_data';
import 'package:google_fonts/google_fonts.dart';
/// MapContainerWidget is the main widget that contains the map with all
/// its layers, polygons and markers.
......@@ -31,7 +32,6 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
bool isTapped = false; // Button tap state tracker
final MapController _mapController = MapController(); // Map controller to re-center map view
// recenterMap moves the map back to its initial view
void recenterMap() {
_mapController.move(mapCenter, 9.0);
......@@ -110,7 +110,25 @@ class _MapContainerWidgetState extends State<MapContainerWidget> {
width: screenWidth * boxWidth,
height: screenWidth * boxHeight,
child: Container(
color: const Color(0x883366ff)
color: const Color(0x883366ff),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(height: 5),
Text( // Display time of most recent server fetch
'Last updated at ${lastUpdate.day == DateTime.now().day
&& lastUpdate.month == DateTime.now().month
&& lastUpdate.year == DateTime.now().year ?
'${lastUpdate.hour}:${lastUpdate.minute}' :
'${lastUpdate.month}:${lastUpdate.day}'}',
style: GoogleFonts.dmSans(
fontSize: 12,
color: Colors.black,
),
),
],
),
),
),
SizedBox( // Lake map
......
No preview for this file type
......@@ -16,12 +16,15 @@ def get_relation(self, body_of_water: str):
if len(polygons) <= 1:
print("Failed to convert to polygons")
return
# Divide relation into tiles and append tiles to relation object
tiles = divide_relation(polygons)
# polygon_data = pd.concat([polygon_data, gpd.GeoDataFrame(tiles)], ignore_index=True)
# tiles = divide_relation(polygons)
# tiles_dicts = [{"geometry": tile["polygon"], "SubDivID": tile["SubDivID"]} for tile in tiles]
# tiles_gdf = gpd.GeoDataFrame(tiles_dicts)
# combined_data = pd.concat([polygon_data, tiles_gdf], ignore_index=True)
# Transform geojson to json -> syncfusion_flutter_maps lib requires json
# Parse geojson to json -> syncfusion_flutter_maps lib requires json
geojson_dict = json.loads(polygon_data.to_json())
response_json = json.dumps(geojson_dict)
......
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