车位置
This commit is contained in:
parent
b300935498
commit
22b7993ffc
File diff suppressed because one or more lines are too long
@ -91,20 +91,44 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
width: 10,
|
||||
),
|
||||
Obx(
|
||||
() => InkWell(
|
||||
onTap: () {
|
||||
// Navigator.push(context,
|
||||
// MaterialPageRoute(builder: (context) => const ScenceMap())),
|
||||
},
|
||||
child: Image(
|
||||
image: const AssetImage('images/satellite.png'),
|
||||
// width: 40,
|
||||
color: appcontroller.isDarkMode.value
|
||||
? Colors.white70
|
||||
: const Color.fromARGB(200, 29, 28, 28),
|
||||
height: 40,
|
||||
),
|
||||
),
|
||||
() {
|
||||
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: Row(
|
||||
children: [
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(fontSize: 12),
|
||||
),
|
||||
Image(
|
||||
image: const AssetImage('images/satellite.png'),
|
||||
// width: 40,
|
||||
color: color,
|
||||
height: 40,
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
|
@ -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]),
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user