summaryrefslogtreecommitdiffstats
path: root/lib/map/navigationHome.dart
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2023-09-24 12:45:03 -0400
committerScott Murray <scott.murray@konsulko.com>2023-09-24 12:55:47 -0400
commit80a4f8d75a66c22a23e825d4c0fb4065e2e58cb8 (patch)
tree07751588fbd9f0a5cecceabe593a716f01facbac /lib/map/navigationHome.dart
parent9bc83e64c508ad8c69a3950d5421774f9b53a31f (diff)
Rework to use KUKSA.val databroker gRPC API
Rework to move from the WebSocket API with the older KUKSA.val server to the gRPC "VAL" API of the databroker. Changes include: - All VISS WebSocket API code has been removed, and the signal providers replumbed to be driven by a new VssClient class with a dashboard-specific child class to hold all the gRPC API handling. - The generated code for the VAL API and its dependencies has been checked in under lib/generated, as there still does not seem to be a good way to generate it during the Flutter build. - The "flutter-" prefix has been dropped from the configuration file name (i.e. it's now just "cluster-dashboard.yaml") to match the naming used for the other Flutter applications. The authorization token field name has been renamed to "authorization", and there are new "use-tls" and "ca-certificate" configuration fields. TLS is disabled by default for now, and the default CA certificate is /etc/kuksa.val/CA.pem. - Bumped minimum SDK version to 2.18 in pubspec.yaml to enable "super" keyword support. This matches what the version was set to in the other applications. - The unused navigation support has been removed to simplify maintenance, as it is more likely that it will be replaced with something else in the future than fixed to be usable. - Removed .dart_tool generated output that had been checked in, and added .gitignore file from flutter-homescreen so that things will hopefully stay clean in the future. Since pubspec.lock is not checked in here, it has also been added to .gitignore. Bug-AGL: SPEC-4762 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Id35c569cdbb8476a527717ece7b4bb369c4874b7
Diffstat (limited to 'lib/map/navigationHome.dart')
-rw-r--r--lib/map/navigationHome.dart136
1 files changed, 0 insertions, 136 deletions
diff --git a/lib/map/navigationHome.dart b/lib/map/navigationHome.dart
deleted file mode 100644
index 5218de7..0000000
--- a/lib/map/navigationHome.dart
+++ /dev/null
@@ -1,136 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-
-import 'dart:async';
-import 'package:flutter/material.dart';
-import 'package:flutter_cluster_dashboard/cluster_config.dart';
-import 'package:flutter_map/flutter_map.dart';
-import 'package:flutter_riverpod/flutter_riverpod.dart';
-import 'package:flutter_cluster_dashboard/map/networkPolyline.dart';
-import 'package:flutter_cluster_dashboard/provider.dart';
-import 'package:flutter_cluster_dashboard/vehicle_signal/vehicle_signal_provider.dart';
-import 'package:latlong2/latlong.dart';
-
-class NavigationHome extends ConsumerStatefulWidget {
- const NavigationHome({Key? key}) : super(key: key);
-
- @override
- ConsumerState<NavigationHome> createState() => _NavigationHomeState();
-}
-
-class _NavigationHomeState extends ConsumerState<NavigationHome> {
- late Timer timerCurrLocation;
- Timer timerPolyline = Timer.periodic(const Duration(hours: 10), ((timer) {}));
- double pathStroke = 5;
- late MapController mapController;
- // randomly initialization of the variable
- LatLng src = LatLng(31.71, 76.95);
- LatLng markerLocation = LatLng(31.71, 76.95);
-
- @override
- void initState() {
- super.initState();
- mapController = MapController();
-
- WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
- var vehicle = ref.read(vehicleSignalProvider);
- var polylineDB = ref.read(polyLineStateProvider);
- final polylineDBNotifier = ref.read(polyLineStateProvider.notifier);
- final clusterConfig = ref.read(clusterConfigStateprovider);
- // timer for updating map center and zoom
- timerCurrLocation = Timer.periodic(const Duration(seconds: 2), (timer) {
- polylineDB = ref.read(polyLineStateProvider);
-
- vehicle = ref.read(vehicleSignalProvider);
- markerLocation = LatLng(vehicle.currLat, vehicle.currLng);
- // move and center
- mapController.move(LatLng(vehicle.currLat, vehicle.currLng), 15);
-
- // rotate
- double rotationDegree = 0;
- int n = polylineDB.currPolyLineList.length;
- if (polylineDB.currPolyLineList.isNotEmpty && n > 1) {
- rotationDegree = calcAngle(
- polylineDB.currPolyLineList[0], polylineDB.currPolyLineList[1]);
-
- rotationDegree = (rotationDegree.isNaN) ? 0 : rotationDegree;
- }
- // print("Rotation:$rotationDegree");
- mapController.rotate(-1 * rotationDegree);
- });
-
- // update polyline in polyline db
- if (polylineDB.currPolyLineList.isEmpty && clusterConfig.orsApiKey.isNotEmpty) {
- timerPolyline.cancel();
- timerPolyline =
- Timer.periodic(const Duration(seconds: 10), (timer) async {
- List data = await getJsonData(ref, vehicle.currLat, vehicle.currLng,
- vehicle.desLat, vehicle.desLng);
- List<LatLng> currList =
- data.map((element) => LatLng(element[1], element[0])).toList();
- polylineDBNotifier.update(currPolyLineList: currList);
- });
- }
- });
- }
-
- @override
- void dispose() {
- super.dispose();
- timerCurrLocation.cancel();
- timerPolyline.cancel();
- }
-
- double tempangle = 0;
- @override
- Widget build(BuildContext context) {
- final currListProvider = ref.watch(polyLineStateProvider);
- List<LatLng> currPolyLineList = currListProvider.currPolyLineList;
-
- return FlutterMap(
- mapController: mapController,
- options: MapOptions(
- rotation: 0,
- center: src,
- minZoom: 12,
- zoom: 12,
- maxZoom: 22.0,
- keepAlive: true,
- ),
- layers: [
- TileLayerOptions(
- maxZoom: 22,
- maxNativeZoom: 18,
- subdomains: ["a", "b", "c"],
- urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
- userAgentPackageName: 'dev.fleaflet.flutter_map.example',
- ),
- if (currPolyLineList.isNotEmpty)
- PolylineLayerOptions(
- polylineCulling: false,
- polylines: [
- if (currPolyLineList.isNotEmpty)
- Polyline(
- strokeWidth: pathStroke,
- points: currPolyLineList,
- color: Colors.blue,
- ),
- ],
- ),
- if (currPolyLineList.isNotEmpty)
- MarkerLayerOptions(
- rotate: true,
- markers: [
- Marker(
- point: markerLocation,
- width: 70,
- height: 70,
- builder: (context) => Image.asset(
- "images/car.png",
- ),
- ),
- ],
- ),
- ],
- );
- }
-}