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

update: server json response

parent 40b7c081
No related branches found
No related tags found
2 merge requests!9Clhp map,!8Clhp map
......@@ -9,7 +9,6 @@ class Measurement {
String bodyOfWater;
LatLng center;
List <SubDiv> subDivs;
List <LatLng> corners;
Measurement({
required this.measurementID,
......@@ -18,7 +17,6 @@ class Measurement {
required this.bodyOfWater,
required this.center,
required this.subDivs,
required this.corners,
});
factory Measurement.fromJson(Map<String, dynamic> json) {
......@@ -29,7 +27,6 @@ class Measurement {
bodyOfWater: json['BodyOfWater'] ?? 'nil',
center: LatLng(json['CenterLat'], json['CenterLon']),
subDivs: (json['Subdivisions'] as List<dynamic>).map((data) => SubDiv.fromJson(data)).toList(),
corners: (json['Corners'] as List<dynamic>).map((corner) => LatLng(corner[0], corner[1])).toList(),
);
}
}
......
No preview for this file type
......@@ -38,7 +38,8 @@ def get_all_markers(self, cursor, waterBodyName):
'AvgThickness': row[11],
'CenLatitude': row[12],
'CenLongitude': row[13],
'Accuracy': row[14]
'Accuracy': row[14],
'Color': calculateColor(row[11]) # NB color calculated based on average thickness, should be minimum
}
# Check if measurement ID already exists in measurement_data
......@@ -60,7 +61,6 @@ def get_all_markers(self, cursor, waterBodyName):
'Active': bool(row[6])
},
'Subdivisions': [sub_division], # Array of sub_division objects
'Corners': [], # NB remove value if not used
}
# Convert dictionary values to list of measurements
......@@ -85,6 +85,7 @@ def get_all_markers(self, cursor, waterBodyName):
# Write marker data to response object
self.wfile.write(marker_data.encode('utf-8'))
def calculateColor(thickness: int): # NB not final colors nor ranges
if 0 < thickness < 4:
return 0xFFff0000 # Red
......@@ -96,4 +97,3 @@ def calculateColor(thickness: int): # NB not final colors nor ranges
return 0xFF00d6ff # Blue
else:
return 0xFF939393 # Gray
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