laptop
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:bus_infotainment/audio_cache.dart';
|
||||
@@ -16,28 +17,24 @@ class BusSequences extends InfoModule {
|
||||
|
||||
Map<String, BusDestination> destinations = {};
|
||||
|
||||
BusSequences.fromCSV(String destinationsCSV, String busSequencesCSV) {
|
||||
BusSequences.fromCSV(String destinationsJson, String busSequencesCSV) {
|
||||
|
||||
|
||||
|
||||
// Init the bus destinations
|
||||
List<List<String>> destinationRows = CsvConverter().convert(destinationsCSV);
|
||||
destinationRows.removeAt(0);
|
||||
Map<String, dynamic> destinationData = jsonDecode(destinationsJson);
|
||||
|
||||
print("Destination rows: ${destinationRows.length}");
|
||||
print("Destination rows: ${destinationData.length}");
|
||||
|
||||
for (int i = 0; i < destinationRows.length; i++) {
|
||||
for (String destinationName in destinationData.keys) {
|
||||
try {
|
||||
Map<String, dynamic> destinationDetails = destinationData[destinationName];
|
||||
|
||||
List<dynamic> entries = destinationRows[i];
|
||||
// print("Parsing destination row $i: $entries");
|
||||
String blind = destinationName;
|
||||
|
||||
String routeNumber = entries[0].toString();
|
||||
|
||||
BusRoute route = routes.containsKey(routeNumber) ? routes[routeNumber]! : BusRoute(routeNumber: routeNumber);
|
||||
|
||||
String blind = entries[1].toString();
|
||||
|
||||
double lat = double.parse(entries[2].toString());
|
||||
double long = double.parse(entries[3].toString());
|
||||
List<String> location = destinationDetails['Location'].split(', ');
|
||||
double lat = double.parse(location[0]);
|
||||
double long = double.parse(location[1]);
|
||||
|
||||
Vector2 grid = OSGrid.toNorthingEasting(lat, long);
|
||||
|
||||
@@ -46,11 +43,10 @@ class BusSequences extends InfoModule {
|
||||
destination.easting = grid.x;
|
||||
destination.northing = grid.y;
|
||||
|
||||
route.destinations.add(destination);
|
||||
|
||||
routes[routeNumber] = route;
|
||||
destinations[blind] = destination;
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
print("Error parsing destination: $e");
|
||||
}
|
||||
}
|
||||
|
||||
print("Loaded ${destinations.length} destinations");
|
||||
|
||||
Reference in New Issue
Block a user