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

update: more error handling

parent 17c3992d
No related branches found
No related tags found
1 merge request!13Clhp map
...@@ -23,7 +23,9 @@ class Measurement { ...@@ -23,7 +23,9 @@ class Measurement {
try { try {
return Measurement( return Measurement(
measurementID: json['MeasurementID'] ?? 0, measurementID: json['MeasurementID'] ?? 0,
timeMeasured: DateTime.parse(json['TimeMeasured']), timeMeasured: json['TimeMeasured'] != null
? DateTime.parse(json['TimeMeasured'])
: DateTime(0),
sensor: Sensor.fromJson(json['Sensor']), sensor: Sensor.fromJson(json['Sensor']),
bodyOfWater: json['BodyOfWater'] != null ? json['BodyOfWater'].toString() : 'nil', bodyOfWater: json['BodyOfWater'] != null ? json['BodyOfWater'].toString() : 'nil',
center: LatLng( center: LatLng(
...@@ -148,6 +150,14 @@ class Sensor { ...@@ -148,6 +150,14 @@ class Sensor {
factory Sensor.fromJson(Map<String, dynamic> json) { factory Sensor.fromJson(Map<String, dynamic> json) {
try { try {
if (json == null) {
return Sensor(
sensorID: -1,
sensorType: 'Weather data only',
active: false
);
}
return Sensor( return Sensor(
sensorID: json['SensorID'] ?? 0, sensorID: json['SensorID'] ?? 0,
sensorType: json['SensorType'] ?? 'nil', sensorType: json['SensorType'] ?? 'nil',
......
import json import json
from datetime import datetime
from server.consts import LAKE_RELATIONS_PATH from server.consts import LAKE_RELATIONS_PATH
from server.ModelFromNVE.icemodellingscripts.getIceThicknessLakes import get_raw_dates, ice_prognosis_raw_data from server.ModelFromNVE.icemodellingscripts.getIceThicknessLakes import get_raw_dates, ice_prognosis_raw_data
...@@ -74,7 +75,7 @@ def get_measurements(self, cursor, lake_name): ...@@ -74,7 +75,7 @@ def get_measurements(self, cursor, lake_name):
remaining_sub_divs = fillRemainingSubdivisions(lake_name, sub_div_ids) remaining_sub_divs = fillRemainingSubdivisions(lake_name, sub_div_ids)
measurement_data[-1] = { measurement_data[-1] = {
'MeasurementID': -1, 'MeasurementID': -1,
'TimeMeasured': None, 'TimeMeasured': datetime.now(),
'CenterLat': None, 'CenterLat': None,
'CenterLon': None, 'CenterLon': None,
'Sensor': None, 'Sensor': None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment