diff --git a/lib/hardware_interface/test_interface.dart b/lib/hardware_interface/test_interface.dart index 913c82f..2d4ba34 100644 --- a/lib/hardware_interface/test_interface.dart +++ b/lib/hardware_interface/test_interface.dart @@ -19,8 +19,8 @@ class TestHardwareInterface extends BaseHardwareInterface { database.updateDatabase("random_1", random.nextDouble()); - database.updateDatabase("rocket latitude", sin(i / 50)/100 + 42.37); - database.updateDatabase("rocket longitude", cos(i / 50)/100 -71.06); + database.updateDatabase("rocket latitude", sin(i / 50) / 100 + 42.37); + database.updateDatabase("rocket longitude", cos(i / 50) / 100 - 71.06); database.updateDatabase("groundstation latitude", 42.361145); database.updateDatabase("groundstation longitude", -71.0570803); diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index ac5fcb3..32043b7 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -13,43 +13,37 @@ import 'package:latlong2/latlong.dart'; import 'package:url_launcher/url_launcher.dart'; //import 'package:flutter_groundstation/widgets/map_widget.dart'; -double LatLonToDistance(loc1, loc2){ - var p = 0.017453292519943295; - var c = cos; - var a = 0.5 - c((loc2.latitude - loc1.latitude) * p)/2 + - c(loc1.latitude * p) * c(loc2.latitude * p) * - (1 - c((loc2.longitude - loc1.longitude) * p))/2; - return 12742 * asin(sqrt(a)); - } +double LatLonToDistance(loc1, loc2) { + var p = 0.017453292519943295; + var c = cos; + var a = 0.5 - c((loc2.latitude - loc1.latitude) * p) / 2 + c(loc1.latitude * p) * c(loc2.latitude * p) * (1 - c((loc2.longitude - loc1.longitude) * p)) / 2; + return 12742 * asin(sqrt(a)); +} class MapWidget extends StatefulWidget { const MapWidget({super.key}); - + @override State createState() => _MapWidgetState(); } late List circles; - class _MapWidgetState extends BaseWidgetState { - -var groundstation_location = LatLng(42.361145, -71.0570803); -List rocket_path = []; + var groundstation_location = LatLng(42.361145, -71.0570803); + List rocket_path = []; @override Widget build(BuildContext context) { - var rocket_location = LatLng(getDatabaseValue("rocket latitude", 42.37), getDatabaseValue("rocket longitude", -71.06)); if (rocket_path.isEmpty || LatLonToDistance(rocket_location, rocket_path.last) > 0.5) { rocket_path.add(rocket_location); } - + return FlutterMap( options: MapOptions( center: LatLng(groundstation_location.latitude, groundstation_location.longitude), zoom: 10, ), - nonRotatedChildren: [ RichAttributionWidget( attributions: [ @@ -65,7 +59,7 @@ List rocket_path = []; urlTemplate: 'https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}', //urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', userAgentPackageName: 'com.example.app', - ), + ), PolylineLayer( polylines: [ Polyline( @@ -76,21 +70,20 @@ List rocket_path = []; ], ), CircleLayer( - circles: [ - CircleMarker( - point: LatLng(rocket_location.latitude, rocket_location.longitude), - radius: 5, - color: Color.fromARGB(255, 133, 2, 255), - ), - CircleMarker( - point: LatLng(groundstation_location.latitude, groundstation_location.longitude), - radius: 5, - color: Color.fromARGB(255, 255, 154, 2), - ) - ], - ), + circles: [ + CircleMarker( + point: LatLng(rocket_location.latitude, rocket_location.longitude), + radius: 5, + color: Color.fromARGB(255, 133, 2, 255), + ), + CircleMarker( + point: LatLng(groundstation_location.latitude, groundstation_location.longitude), + radius: 5, + color: Color.fromARGB(255, 255, 154, 2), + ) + ], + ), ], ); } } - diff --git a/lib/widgets/tabs/map_tab.dart b/lib/widgets/tabs/map_tab.dart index 61e147a..748d66d 100644 --- a/lib/widgets/tabs/map_tab.dart +++ b/lib/widgets/tabs/map_tab.dart @@ -17,4 +17,4 @@ class MapTab extends StatelessWidget { ], ); } -} \ No newline at end of file +}