车位置

This commit is contained in:
刘媛 2024-11-18 18:02:15 +08:00
parent b300935498
commit 22b7993ffc
4 changed files with 74 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -91,20 +91,44 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
width: 10,
),
Obx(
() => InkWell(
() {
Color color = appcontroller.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28);
int status = realcontroller.status.value;
if (status == 4) {
color = Colors.green;
} else if (status == 1) {
color = Colors.red;
} else {
if (status != 0) {
color = Colors.blue;
}
}
String text = "";
text = "${realcontroller.sa.value}/${realcontroller.sv.value}";
return InkWell(
onTap: () {
// Navigator.push(context,
// MaterialPageRoute(builder: (context) => const ScenceMap())),
},
child: Image(
child: Row(
children: [
Text(
text,
style: const TextStyle(fontSize: 12),
),
Image(
image: const AssetImage('images/satellite.png'),
// width: 40,
color: appcontroller.isDarkMode.value
? Colors.white70
: const Color.fromARGB(200, 29, 28, 28),
color: color,
height: 40,
)
],
),
),
);
},
),
const SizedBox(
width: 10,

View File

@ -114,8 +114,8 @@ class ProcessEntity {
}
factory ProcessEntity.fromString(String str) {
List<String> list = str.split(",");
factory ProcessEntity.fromList(List<String> list) {
return ProcessEntity(
utc:int.parse( list[2]),
lat: double.parse(list[3]),

View File

@ -1,3 +1,4 @@
import 'dart:math';
import 'dart:typed_data';
import 'dart:ui';
import 'package:cpnav/pages/setting/child_pages/XyChange/xy_change.dart';
@ -178,6 +179,9 @@ class RealController extends GetxController {
impact_force: []).obs;
var dataCount = 0.obs;
CoordTrans? coordTrans;
var status = 0.obs;
var sa = 0.obs;
var sv = 0.obs;
reset() {
sightOffset1.value = const Offset(3, 3);
sightOffsetInit1.value = const Offset(0, 0);
@ -190,9 +194,23 @@ class RealController extends GetxController {
var isDataVisible = false.obs;
onBleData(Uint8List data) {
String str = String.fromCharCodes(data);
ProcessEntity process = ProcessEntity.fromString(str);
processdata.value = process;
String first = str.split("#POSA")[1];
List<String> list = first.split(",");
double baseLine = double.parse(list[7]);
double heading = double.parse(list[8]);
double pitch = double.parse(list[9]);
status.value = int.parse(list[1]);
sa.value = int.parse(list[10]);
List<String> svStr = list[11].trim().split(" ");
sv.value = int.parse(svStr[0]);
ProcessEntity process = ProcessEntity.fromList(list);
processdata.update((value) {
// value.speed = process.speed;
value?.lat = process.lat;
value?.lng = process.lng;
value?.alt = process.height;
value?.utc = process.utc;
});
dataCount.value++;
CoorTransModel trans = xyChangeController.coorTrans.value;
coordTrans ??= CoordTrans(TransOptions(
@ -213,9 +231,19 @@ class RealController extends GetxController {
mapController.deviceList[settingController.currentDevice.value?.tid];
if (centerDev != null) {
// log("center${xyh.X},${xyh.Y}");
centerDev.x.value = xyh.X;
centerDev.y.value = xyh.Y;
centerDev.update.value++;
double pitchRad = pitch * pi / 180;
double headingRad = (270 - heading) * pi / 180; //(270-)
centerDev.rotation.value = headingRad;
//
double dXY = baseLine * cos(pitchRad);
// 线
double carX = xyh.X + dXY * cos(headingRad);
double carY = xyh.Y + dXY * sin(headingRad);
centerDev.x.value = carX;
centerDev.y.value = carY;
}
}
}