2024-08-18 22:42:37 +08:00
|
|
|
import 'dart:ui';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
import 'package:cpnav/service/base.dart';
|
2024-08-26 18:25:21 +08:00
|
|
|
import 'package:scence_map/controllers/controller.dart';
|
2024-08-27 18:08:05 +08:00
|
|
|
import 'package:scence_map/record_entity.dart';
|
|
|
|
|
2024-08-18 22:42:37 +08:00
|
|
|
class PassTrackController extends GetxController {
|
|
|
|
final mapController = Get.put(ScenceMapController());
|
|
|
|
|
|
|
|
String projCode;
|
|
|
|
String projType;
|
|
|
|
late final GetServices service;
|
2024-08-28 17:56:53 +08:00
|
|
|
RecordEntity? selectedPilePoint;
|
2024-08-18 22:42:37 +08:00
|
|
|
PassTrackController(this.projCode, this.projType);
|
|
|
|
|
|
|
|
@override
|
|
|
|
void onInit() {
|
|
|
|
super.onInit();
|
|
|
|
service = GetServices(projCode: projCode, projType: projType);
|
|
|
|
loadProject();
|
|
|
|
loadSideLine();
|
2024-08-27 18:08:05 +08:00
|
|
|
// loadBindDevice();
|
|
|
|
loadRcordList();
|
2024-08-18 22:42:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
loadBindDevice() async {
|
|
|
|
var binddevices = await service.getDeviceBind();
|
|
|
|
for (var device in binddevices) {
|
|
|
|
var dev = DeviceItem.fromJson(device);
|
|
|
|
mapController.deviceList[dev.TID] = dev;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loadCoorTrans() async {}
|
|
|
|
|
|
|
|
loadProject() async {}
|
|
|
|
|
|
|
|
loadSideLine() async {
|
|
|
|
var data = await service.getSideLine();
|
|
|
|
double maxX = -double.infinity;
|
|
|
|
double maxY = -double.infinity;
|
|
|
|
double minX = double.infinity;
|
|
|
|
double minY = double.infinity;
|
|
|
|
var sideLineData = data as Map<String, dynamic>;
|
2024-08-23 17:54:57 +08:00
|
|
|
// var sideLineData = data;
|
2024-08-18 22:42:37 +08:00
|
|
|
sideLineData.forEach((group, items) {
|
|
|
|
for (var item in items) {
|
|
|
|
SideLineItem sideLineItem = SideLineItem.fromJson(item);
|
|
|
|
var sideLineList = mapController.sideLinListeMap[group];
|
|
|
|
if (sideLineList == null) {
|
|
|
|
sideLineList = [];
|
|
|
|
mapController.sideLinListeMap[group] = sideLineList;
|
|
|
|
}
|
|
|
|
sideLineList.add(sideLineItem);
|
|
|
|
if (sideLineItem.x > maxX) {
|
|
|
|
maxX = sideLineItem.x;
|
|
|
|
}
|
|
|
|
if (sideLineItem.y > maxY) {
|
|
|
|
maxY = sideLineItem.y;
|
|
|
|
}
|
|
|
|
if (sideLineItem.x < minX) {
|
|
|
|
minX = sideLineItem.x;
|
|
|
|
}
|
|
|
|
if (sideLineItem.y < minY) {
|
|
|
|
minY = sideLineItem.y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (maxX != -double.infinity &&
|
|
|
|
maxY != -double.infinity &&
|
|
|
|
minX != double.infinity &&
|
|
|
|
minY != double.infinity) {
|
|
|
|
mapController.centerXY = Offset((maxX + minX) / 2, (maxY + minY) / 2);
|
|
|
|
}
|
|
|
|
}
|
2024-08-27 18:08:05 +08:00
|
|
|
|
|
|
|
loadRcordList() async {
|
|
|
|
List record = await service.getRcordList("2024-08-7");
|
|
|
|
if (record.isNotEmpty) {
|
|
|
|
for (var i = 0; i < record.length; i++) {
|
|
|
|
RecordEntity item = RecordEntity.fromJson(record[i]);
|
|
|
|
mapController.recordList.add(item);
|
|
|
|
}
|
|
|
|
mapController.centerXY = Offset(
|
|
|
|
mapController.recordList[mapController.recordList.length - 1].x,
|
|
|
|
mapController.recordList[mapController.recordList.length - 1].y);
|
|
|
|
//将地图或画布的中心定位到最新记录的位置上
|
|
|
|
}
|
|
|
|
}
|
2024-08-18 22:42:37 +08:00
|
|
|
}
|