添加设备
This commit is contained in:
parent
6abf207151
commit
7eec50c877
@ -1,4 +1,5 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
libserialport=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\git\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\
|
||||
path_provider=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider-2.1.4\\
|
||||
path_provider_android=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_android-2.2.10\\
|
||||
path_provider_foundation=C:\\Users\\Administrator\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\path_provider_foundation-2.4.0\\
|
||||
|
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-23 17:31:42.127712","version":"3.24.0","swift_package_manager_enabled":false}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.4.0\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_linux","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"libserialport","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\git\\\\libserialport-d6d27ef7aaf89e4dfa026db0c50dd3053c546710\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"C:\\\\Users\\\\Administrator\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"libserialport","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-08-26 18:23:25.517122","version":"3.24.0","swift_package_manager_enabled":false}
|
Binary file not shown.
Before Width: | Height: | Size: 325 KiB |
166
lib/controllers/gnss_Controller.dart
Normal file
166
lib/controllers/gnss_Controller.dart
Normal file
@ -0,0 +1,166 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gnss/gnss.dart';
|
||||
|
||||
import '../models/pilePoint/coord_trans.dart';
|
||||
|
||||
|
||||
class GnssController extends GetxController {
|
||||
late final Gnss gnss;
|
||||
LocationData? locationData;
|
||||
late Pos3D pilerCenter;
|
||||
|
||||
var locationUpdate = 0.obs;
|
||||
// late final PilerPointCalculate pilerCenterPoint;
|
||||
//三个定义
|
||||
var maindrilldistance = 2.0.obs; //主天线与车心距离
|
||||
var auxdrilldistance = 2.0.obs; //副天线与车心距离
|
||||
var offsetangle = 0.0.obs; //主副连线与车身夹角
|
||||
late final CoordTrans coordTrans;
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
|
||||
// pilerCenterPoint = PilerPointCalculate(
|
||||
// maindrilldistance.value,
|
||||
// auxdrilldistance.value,
|
||||
// offsetangle.value,
|
||||
// );
|
||||
// 调用 pilerPos3D 方法
|
||||
|
||||
pilerCenter = Pos3D(4196584.0, 517728, 0.0);
|
||||
// 插入定时器测试代码
|
||||
timer = Timer.periodic(Duration(seconds: 1), (Timer timer) {
|
||||
pilerCenter.X += 0.2;
|
||||
pilerCenter.Y += 0.2;
|
||||
pilerCenter.rotation = pilerCenter.rotation + pi / 180; // 确保旋转角度在0-360度之间
|
||||
});
|
||||
|
||||
gnss = Gnss(port: "/dev/ttysWK2", baudrate: 115200);
|
||||
// gnss = Gnss(port: "COM1", baudrate: 115200);
|
||||
gnss.start();
|
||||
gnss.locationStream.listen((location) {
|
||||
locationData = location;
|
||||
// print(locationData);
|
||||
// var xyh = coordTrans.d2p(CoordBLH(
|
||||
// B: location.latitude, L: location.longitude, H: location.altitude));
|
||||
// pilerCenter = pilerCenterPoint.pilerPos3D(xyh, location.heading,
|
||||
// location.pitch, location.baseLength, offsetangle.value);
|
||||
// print(
|
||||
// 'X: ${pilerCenter.X}, Y: ${pilerCenter.Y}, Rotation: ${pilerCenter.rotation}');
|
||||
|
||||
locationUpdate.value++;
|
||||
});
|
||||
|
||||
coordTrans = CoordTrans(TransOptions(L0: 108.5, elevation: 0));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
gnss.dispose();
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
class Pos3D {
|
||||
double X;
|
||||
double Y;
|
||||
double rotation;
|
||||
|
||||
Pos3D(this.X, this.Y, this.rotation);
|
||||
}
|
||||
|
||||
// class PilerPointCalculate {
|
||||
// final double mainDrillDistance; //主天线与钻头距离
|
||||
|
||||
// final double auxDrillDistance; //副天线与钻头距离
|
||||
// final double offsetangle;
|
||||
// PilerPointCalculate(
|
||||
// this.mainDrillDistance,
|
||||
// this.auxDrillDistance,
|
||||
// this.offsetangle,
|
||||
// );
|
||||
// // 计算副天线的坐标
|
||||
// Offset auxPointCalculate(
|
||||
// CoordXYH mainPoint, double baseLength, double pitch, double heading) {
|
||||
// // 将角度转换为弧度
|
||||
// double pitchRad = pitch * pi / 180;
|
||||
// double headingRad = (270 - heading) * pi / 180; //(270-)
|
||||
|
||||
// // 计算水平投影距离
|
||||
// double dXY = baseLength * cos(pitchRad);
|
||||
|
||||
// // 计算副天线的坐标
|
||||
// double x2 = mainPoint.X + dXY * cos(headingRad);
|
||||
// double y2 = mainPoint.Y + dXY * sin(headingRad);
|
||||
// return Offset(x2, y2);
|
||||
// }
|
||||
|
||||
// // 计算交点
|
||||
// List findIntersections(CoordXYH mainPoint, Offset auxPoint) {
|
||||
// // 计算第二个点 b 的坐标
|
||||
// // Offset auxPoint = _auxPointCalculate(mainPoint, baseLength, pitch, heading);
|
||||
|
||||
// double dx = auxPoint.dx - mainPoint.X;
|
||||
// double dy = auxPoint.dy - mainPoint.Y;
|
||||
// double d = sqrt(dx * dx + dy * dy);
|
||||
|
||||
// if (d > mainDrillDistance + auxDrillDistance ||
|
||||
// d < (mainDrillDistance - auxDrillDistance).abs()) {
|
||||
// // 圆不相交
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// double a_ = (mainDrillDistance * mainDrillDistance -
|
||||
// auxDrillDistance * auxDrillDistance +
|
||||
// d * d) /
|
||||
// (2 * d);
|
||||
// double h = sqrt(mainDrillDistance * mainDrillDistance - a_ * a_);
|
||||
|
||||
// double x2 = mainPoint.X + a_ * (dx / d);
|
||||
// double y2 = mainPoint.Y + a_ * (dy / d);
|
||||
|
||||
// double rx = -dy * (h / d);
|
||||
// double ry = dx * (h / d);
|
||||
|
||||
// Offset intersection1 = Offset(x2 + rx, y2 + ry);
|
||||
// Offset intersection2 = Offset(x2 - rx, y2 - ry);
|
||||
|
||||
// return [intersection1, intersection2];
|
||||
// }
|
||||
|
||||
// // 计算车心
|
||||
// Pos3D pilerPos3D(CoordXYH mainPoint, double heading, double pitch,
|
||||
// double baseLength, double offsetangle) {
|
||||
// // 找到两个可能的车心点
|
||||
// Offset auxPoint = auxPointCalculate(mainPoint, baseLength, pitch, heading);
|
||||
// List intersections = findIntersections(mainPoint, auxPoint);
|
||||
|
||||
// if (intersections.isEmpty) {
|
||||
// throw Exception('无法找到车心点,圆不相交');
|
||||
// }
|
||||
|
||||
// // 以主点为起点连线到副点作为横轴
|
||||
// double dx = auxPoint.dx - mainPoint.X;
|
||||
// double dy = auxPoint.dy - mainPoint.Y;
|
||||
|
||||
// // 横轴逆时针旋转90度为纵轴
|
||||
// double verticalX = -dy;
|
||||
// double verticalY = dx;
|
||||
|
||||
// // 选择位于纵轴正半轴的点作为最终的车心坐标
|
||||
// Offset intersection = (intersections[1].dx - mainPoint.X) * verticalX +
|
||||
// (intersections[1].dy - mainPoint.Y) * verticalY >
|
||||
// 0
|
||||
// ? intersections[1]
|
||||
// : intersections[0];
|
||||
|
||||
// double rotation = (atan2(dy, dx) * 180 / pi) + 90 + offsetangle;
|
||||
|
||||
// return Pos3D(intersection.dx, intersection.dy, rotation);
|
||||
// }
|
||||
// }
|
@ -1,60 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:roslibdart/roslibdart.dart';
|
||||
|
||||
class PlumDataController extends GetxController {
|
||||
var isGenerate = false.obs; //是否生成
|
||||
var angle = 0.0.obs; //方向弧度
|
||||
var isDirect = false.obs; //是否为方向设置
|
||||
var checkValue = "".obs; //checkPile -桩点坐标,checkDirection-方向设置
|
||||
var checkName = "".obs;
|
||||
var centerXY = Offset.zero.obs; //中心点
|
||||
var space = 5.0.obs; //间距 m
|
||||
var pileWidth = 400.0.obs; //打桩宽度 m
|
||||
var genLenth = 0.obs; //半径
|
||||
var isPileId = false.obs;
|
||||
var direction = 0.0.obs; //角度
|
||||
var isSave = false.obs; //是否保存
|
||||
var centerOffset = Offset.zero.obs;
|
||||
var linePointOffset = Offset.zero.obs;
|
||||
var linePointXY = Offset.zero.obs;
|
||||
var isUp = false.obs;
|
||||
var plumList = [Offset.zero];
|
||||
// var shouldPaint = true.obs;
|
||||
var isMap = false.obs;
|
||||
late Service service;
|
||||
late Ros ros;
|
||||
var canvasSize = Size.zero;
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
super.onInit();
|
||||
// plumList.value = [];
|
||||
// centerXY.value = const Offset(3790620.0588630675, 577014.4059290753);
|
||||
|
||||
// for (int i = -2; i <= 2; i++) {
|
||||
// for (int j = -2; j <= 2; j++) {
|
||||
// plumList.add(Offset(centerXY.value.dx + i, centerXY.value.dy + j));
|
||||
// }
|
||||
// }
|
||||
|
||||
// ros = BaseService().getRos();
|
||||
// ros.connect();
|
||||
// service = Service(
|
||||
// name: '/smash_point_list_service',
|
||||
// ros: ros,
|
||||
// type: "nav2_smash_behavior/srv/SmashPointList");
|
||||
// var json = {'data': []};
|
||||
// service.call(json).then((value) {
|
||||
// print('ros$value');
|
||||
// });
|
||||
}
|
||||
|
||||
updateLinePoint(Offset offset) {
|
||||
linePointOffset.value = offset;
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
import 'package:scence_map/controllers/plumController.dart';
|
||||
import 'appbar.dart';
|
||||
import 'controllers/plumController.dart';
|
||||
|
||||
import 'pages/pass_track/view.dart';
|
||||
import 'pages/pile/pileNav/view.dart';
|
||||
import 'pages/pile/rightDra/pileGenerate.dart';
|
||||
|
||||
void main() {
|
||||
@ -73,9 +74,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
Container(
|
||||
color: Colors.green,
|
||||
),
|
||||
PassTrack(
|
||||
date: '',
|
||||
),
|
||||
// PassTrack(
|
||||
// date: '',
|
||||
// ),
|
||||
RealView(),
|
||||
Container(
|
||||
color: Colors.blue,
|
||||
),
|
||||
@ -96,6 +98,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
drawerEdgeDragWidth: 0.0, // 禁止通过滑动打开drawer
|
||||
endDrawer: _currentIndex.value == 1
|
||||
? Drawer(
|
||||
width: size.width * .8,
|
||||
|
@ -1,63 +0,0 @@
|
||||
class CoordTrans {
|
||||
int id;
|
||||
// ignore: non_constant_identifier_names
|
||||
double L0;
|
||||
String belt;
|
||||
String? calibs;
|
||||
String dstEllipsoid;
|
||||
double dx;
|
||||
double dy;
|
||||
double dz;
|
||||
double wx;
|
||||
double wy;
|
||||
double wz;
|
||||
double k;
|
||||
double elevation;
|
||||
int isMain;
|
||||
String name;
|
||||
double rota;
|
||||
String srcEllipsoid;
|
||||
CoordTrans({
|
||||
required this.name,
|
||||
// ignore: non_constant_identifier_names
|
||||
required this.L0,
|
||||
required this.belt,
|
||||
this.calibs,
|
||||
required this.dstEllipsoid,
|
||||
required this.dx,
|
||||
required this.dy,
|
||||
required this.dz,
|
||||
required this.id,
|
||||
required this.wx,
|
||||
required this.wy,
|
||||
required this.wz,
|
||||
required this.k,
|
||||
required this.elevation,
|
||||
required this.isMain,
|
||||
required this.rota,
|
||||
required this.srcEllipsoid,
|
||||
});
|
||||
factory CoordTrans.fromJson(Map<dynamic, dynamic> data) {
|
||||
return CoordTrans(
|
||||
name: data['name'],
|
||||
id: data['id'],
|
||||
L0: data['L0'].toDouble(),
|
||||
belt: data['belt'],
|
||||
calibs: data['calibs'],
|
||||
dstEllipsoid: data['dstEllipsoid'],
|
||||
dx: data['dx'].toDouble(),
|
||||
dy: data['dy'].toDouble(),
|
||||
dz: data['dz'].toDouble(),
|
||||
wx: data['wx'].toDouble(),
|
||||
wy: data['wy'].toDouble(),
|
||||
wz: data['wz'].toDouble(),
|
||||
rota: data['rota'].toDouble(),
|
||||
k: data['k'].toDouble(),
|
||||
isMain: data['is_main'],
|
||||
elevation: data['elevation'].toDouble(),
|
||||
srcEllipsoid: data['srcEllipsoid'],
|
||||
);
|
||||
}
|
||||
|
||||
void forEach(Null Function(dynamic key, dynamic value) param0) {}
|
||||
}
|
683
lib/models/pilePoint/coord_trans.dart
Normal file
683
lib/models/pilePoint/coord_trans.dart
Normal file
@ -0,0 +1,683 @@
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
class CoordGPS {
|
||||
double LAT; //纬度
|
||||
double LNG; //经度
|
||||
double? ALT; //高度
|
||||
CoordGPS({this.ALT, required this.LAT, required this.LNG});
|
||||
}
|
||||
|
||||
class CoordXYH {
|
||||
double X;
|
||||
double Y;
|
||||
double H;
|
||||
CoordXYH({required this.X, required this.Y, required this.H});
|
||||
}
|
||||
|
||||
class CoordBLH {
|
||||
double B;
|
||||
double L;
|
||||
double H;
|
||||
CoordBLH({required this.B, required this.H, required this.L});
|
||||
}
|
||||
|
||||
class CoordXYZ {
|
||||
double X;
|
||||
double Y;
|
||||
double Z;
|
||||
CoordXYZ({required this.X, required this.Y, required this.Z});
|
||||
}
|
||||
|
||||
class PointXY {
|
||||
double X;
|
||||
double Y;
|
||||
PointXY({required this.X, required this.Y});
|
||||
}
|
||||
|
||||
class Region {
|
||||
double X;
|
||||
double Y;
|
||||
double? width;
|
||||
double? heigth;
|
||||
double? D;
|
||||
Region({this.D, required this.X, required this.Y, this.heigth, this.width});
|
||||
}
|
||||
|
||||
class Ellipsoid {
|
||||
late double A;
|
||||
late double F;
|
||||
late double B;
|
||||
late double E12;
|
||||
late double E22;
|
||||
Ellipsoid(String name) {
|
||||
const Map<String, Map<String, double>> datums = {
|
||||
'BJ54': {'a': 6378245, 'f': 1 / 298.3},
|
||||
'XA80': {'a': 6378140, 'f': 1 / 298.257},
|
||||
'WGS84': {'a': 6378137, 'f': 1 / 298.257223563},
|
||||
'WGS2000': {'a': 6378137, 'f': 1 / 298.257222101}
|
||||
};
|
||||
var Datum = datums[name];
|
||||
if (Datum != null) {
|
||||
double a = Datum['a']!;
|
||||
double f = Datum['f']!;
|
||||
double b = a - f * a;
|
||||
double e12 = (a * a - b * b) / (a * a); // 第一偏心率平方
|
||||
double e22 = (a * a - b * b) / (b * b); // 第二偏心率平方
|
||||
A = a;
|
||||
F = f;
|
||||
B = b;
|
||||
E12 = e12;
|
||||
E22 = e22;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TransParm {
|
||||
late double dx;
|
||||
late double dy;
|
||||
late double dz;
|
||||
late double rx;
|
||||
late double ry;
|
||||
late double rz;
|
||||
late double rota;
|
||||
late double k;
|
||||
|
||||
TransParm(TransOptions options) {
|
||||
dx = options.dx ?? 0;
|
||||
dy = options.dy ?? 0;
|
||||
dz = options.dz ?? 0;
|
||||
rx = options.rx ?? 0;
|
||||
ry = options.ry ?? 0;
|
||||
rz = options.rz ?? 0;
|
||||
k = options.k ?? 0;
|
||||
rota = options.rota ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
class TransOptions {
|
||||
double? dx; //X平移(M)
|
||||
double? dy; //Y平移(M)
|
||||
double? dz; //z平移(M)
|
||||
double? rx; //X旋转(°)
|
||||
double? ry; //Y旋转(°)
|
||||
double? rz; //Z旋转(°)
|
||||
double? rota; //平面旋转,用于4参数
|
||||
double? k; //尺度(ppm)
|
||||
double? L0; //中央子午线(经度)
|
||||
String? srcEllipsoid; //源椭球名称
|
||||
String? dstEllipsoid; //目标椭球名称
|
||||
double? zoneWidth; //带宽度,用于未指定中央子午线时自动计算
|
||||
double? elevation; //投影高程
|
||||
TransOptions({
|
||||
this.L0,
|
||||
this.dstEllipsoid,
|
||||
this.dx,
|
||||
this.dy,
|
||||
this.dz,
|
||||
this.elevation,
|
||||
this.k,
|
||||
this.rota,
|
||||
this.rx,
|
||||
this.ry,
|
||||
this.rz,
|
||||
this.srcEllipsoid,
|
||||
});
|
||||
}
|
||||
|
||||
//主天线
|
||||
class CoordTrans {
|
||||
late double L0; //中央子午线
|
||||
late double zoneWidth; //带宽度
|
||||
late double elevation; //投影高程
|
||||
late double rota; //平面旋转,用于4参数
|
||||
late Ellipsoid srcEllipsoid; //源椭球
|
||||
late Ellipsoid dstEllipsoid; //目标椭球
|
||||
late TransParm transParm; //7参数
|
||||
CoordTrans(TransOptions options) {
|
||||
transParm = TransParm(options);
|
||||
L0 = options.L0 ?? 0;
|
||||
elevation = options.elevation ?? 0;
|
||||
srcEllipsoid = Ellipsoid(options.srcEllipsoid ?? 'WGS84');
|
||||
dstEllipsoid = Ellipsoid(options.dstEllipsoid ?? 'WGS2000');
|
||||
zoneWidth = options.zoneWidth ?? 3;
|
||||
}
|
||||
|
||||
CoordXYH GPS2XY(CoordGPS gps) {
|
||||
return d2p(CoordBLH(H: gps.ALT ?? elevation, B: gps.LAT, L: gps.LNG));
|
||||
}
|
||||
|
||||
//经纬度转平面坐标
|
||||
CoordXYH d2p(CoordBLH blh) {
|
||||
CoordXYZ zj = BLH2XYZ(blh);
|
||||
CoordXYZ xzj = XYZ2XYZ(zj);
|
||||
CoordBLH xdd = XYZ2BLH(xzj);
|
||||
CoordXYH xpm = BL2XY(xdd);
|
||||
return xpm;
|
||||
}
|
||||
|
||||
//平面坐标转大地坐标
|
||||
CoordBLH p2d(CoordXYH xyh) {
|
||||
CoordBLH bl = XY2BL(xyh, true);
|
||||
CoordXYZ zj = BLH2XYZ(bl, true);
|
||||
CoordXYZ xzj = XYZ2XYZ(zj, true);
|
||||
CoordBLH xdd = XYZ2BLH(xzj, true);
|
||||
return xdd;
|
||||
}
|
||||
|
||||
setZoneWidth(width) {
|
||||
if (width != 6 && width != 3) {
|
||||
// print('带宽应当为6或者为3');
|
||||
} else {
|
||||
zoneWidth = width;
|
||||
}
|
||||
}
|
||||
|
||||
setL0(l0) {
|
||||
L0 = l0;
|
||||
}
|
||||
|
||||
int getZoneNo(double lng) {
|
||||
// 6度带
|
||||
// 这里应为向下取整
|
||||
if (zoneWidth == 6) {
|
||||
return ((lng + 6) / 6).floor();
|
||||
}
|
||||
// 3度带
|
||||
return ((lng + 1.5) / 3).floor();
|
||||
}
|
||||
|
||||
PointXY xy2xyLocal(PointXY source) {
|
||||
double x = source.X;
|
||||
double y = source.Y;
|
||||
double destx = x * transParm.k * cos(rota) -
|
||||
y * transParm.k * sin(rota) +
|
||||
transParm.dx;
|
||||
double desty = x * transParm.k * sin(rota) +
|
||||
y * transParm.k * cos(rota) +
|
||||
transParm.dy;
|
||||
|
||||
return PointXY(X: destx, Y: desty);
|
||||
}
|
||||
|
||||
CoordXYZ BLH2XYZ(CoordBLH pointBLH, [srcDst = false]) {
|
||||
Ellipsoid ellipsoid = srcDst ? srcEllipsoid : dstEllipsoid;
|
||||
double a = ellipsoid.A;
|
||||
double e12 = ellipsoid.E12;
|
||||
|
||||
double radB = pointBLH.B / 180 * pi;
|
||||
double radL = pointBLH.L / 180 * pi;
|
||||
double H = pointBLH.H;
|
||||
|
||||
double N = a / sqrt(1 - e12 * sin(radB) * sin(radB)); // 卯酉圈半径
|
||||
|
||||
double X = (N + H) * cos(radB) * cos(radL);
|
||||
double Y = (N + H) * cos(radB) * sin(radL);
|
||||
double Z = (N * (1 - e12) + H) * sin(radB);
|
||||
|
||||
return CoordXYZ(X: X, Y: Y, Z: Z);
|
||||
}
|
||||
|
||||
/*
|
||||
七参数转换
|
||||
不同椭球参数下, 地心直角坐标系之间转换
|
||||
dX, dY, dZ: 三个坐标方向的平移参数
|
||||
wX, wY, wZ: 三个方向的旋转角参数(单位为弧度)
|
||||
Kppm: 尺度参数, 单位是ppm,如果是以米为单位, 需要在传参前 除以1000000
|
||||
*/
|
||||
CoordXYZ XYZ2XYZ(CoordXYZ xyz, [srcDst = false]) {
|
||||
double X = xyz.X;
|
||||
double Y = xyz.Y;
|
||||
double Z = xyz.Z;
|
||||
double dX = transParm.dx;
|
||||
double dY = transParm.dy;
|
||||
double dZ = transParm.dz;
|
||||
double rX = transParm.rx / 3600 / 180 * pi;
|
||||
double rY = transParm.ry / 3600 / 180 * pi;
|
||||
double rZ = transParm.rz / 3600 / 180 * pi;
|
||||
double Kppm = transParm.k / 1000000;
|
||||
CoordXYZ result = CoordXYZ(X: 0, Y: 0, Z: 0);
|
||||
if (srcDst) {
|
||||
result.X = X - dX - Kppm * X + rY * Z - rZ * Y;
|
||||
result.Y = Y - dY - Kppm * Y - rX * Z + rZ * X;
|
||||
result.Z = Z - dZ - Kppm * Z + rX * Y - rY * X;
|
||||
} else {
|
||||
result.X = X + dX + Kppm * X - rY * Z + rZ * Y;
|
||||
result.Y = Y + dY + Kppm * Y + rX * Z - rZ * X;
|
||||
result.Z = Z + dZ + Kppm * Z - rX * Y + rY * X;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
地心直角坐标系 转换到 地心大地坐标系
|
||||
用直接法2
|
||||
https://wenku.baidu.com/view/30a08f9ddd88d0d233d46a50.html
|
||||
*/
|
||||
CoordBLH XYZ2BLH(CoordXYZ XYZ, [srcDst = false]) {
|
||||
double X = XYZ.X;
|
||||
double Y = XYZ.Y;
|
||||
double Z = XYZ.Z;
|
||||
Ellipsoid ellipsoid = srcDst ? srcEllipsoid : dstEllipsoid;
|
||||
double a = ellipsoid.A;
|
||||
double b = ellipsoid.B;
|
||||
double e12 = ellipsoid.E12;
|
||||
double e22 = ellipsoid.E22;
|
||||
double L = atan(Y / X);
|
||||
// 弧度转角度
|
||||
double degL = L * 180 / pi;
|
||||
// Y值为正, 东半球, 否则西半球
|
||||
if (Y > 0) {
|
||||
while (degL < 0) {
|
||||
degL += 180;
|
||||
}
|
||||
while (degL > 180) {
|
||||
degL -= 180;
|
||||
}
|
||||
} else {
|
||||
while (degL > 0) {
|
||||
degL -= 180;
|
||||
}
|
||||
while (degL < -180) {
|
||||
degL += 180;
|
||||
}
|
||||
}
|
||||
|
||||
double tgU = Z / (sqrt(X * X + Y * Y) * sqrt(1 - e12));
|
||||
double U = atan(tgU);
|
||||
|
||||
double tgB = (Z + b * e22 * pow(sin(U), 3)) /
|
||||
(sqrt(X * X + Y * Y) - a * e12 * pow(cos(U), 3));
|
||||
double B = atan(tgB);
|
||||
double degB = B * 180 / pi; // 弧度转角度
|
||||
if (Z > 0) {
|
||||
// Z值为正, 北半球, 否则南半球
|
||||
while (degB < 0) {
|
||||
degB += 90;
|
||||
}
|
||||
while (degB > 90) {
|
||||
degB -= 90;
|
||||
}
|
||||
} else {
|
||||
while (degB > 0) {
|
||||
degB -= 90;
|
||||
}
|
||||
while (degB < -90) {
|
||||
degB += 90;
|
||||
}
|
||||
}
|
||||
|
||||
while (degB < 0) {
|
||||
degB += 360;
|
||||
}
|
||||
while (degB > 360) {
|
||||
degB -= 360;
|
||||
}
|
||||
|
||||
double N = a / sqrt(1 - e12 * sin(B) * sin(B)); // 卯酉圈半径
|
||||
double H = 0;
|
||||
// B接近极区, 在±90°附近
|
||||
if ((degB).abs() > 80) {
|
||||
H = Z / sin(B) - N * (1 - e12);
|
||||
} else {
|
||||
H = sqrt(X * X + Y * Y) / cos(B) - N;
|
||||
}
|
||||
return CoordBLH(B: degB, L: degL, H: H);
|
||||
}
|
||||
|
||||
/*
|
||||
地心大地坐标系 转换到 大地平面坐标系
|
||||
prjHeight: 投影面高程
|
||||
http://www.cnblogs.com/imeiba/p/5696967.html
|
||||
*/
|
||||
CoordXYH BL2XY(CoordBLH BLH,
|
||||
[srcDst = false, offsetY = 500000, offsetX = 0]) {
|
||||
Ellipsoid ellipsoid = srcDst ? srcEllipsoid : dstEllipsoid;
|
||||
double a = ellipsoid.A;
|
||||
double b = ellipsoid.B;
|
||||
double e12 = ellipsoid.E12;
|
||||
double e22 = ellipsoid.E22;
|
||||
if (L0 == 0) {
|
||||
int zoneNo = getZoneNo(BLH.L);
|
||||
L0 = (zoneNo - 0.5) * zoneWidth;
|
||||
}
|
||||
double radL0 = L0 / 180 * pi;
|
||||
|
||||
double radB = BLH.B / 180 * pi;
|
||||
double radL = BLH.L / 180 * pi;
|
||||
|
||||
double N = a / sqrt(1 - e12 * sin(radB) * sin(radB)); // 卯酉圈半径
|
||||
double T = tan(radB) * tan(radB);
|
||||
double C = e22 * cos(radB) * cos(radB);
|
||||
double A = (radL - radL0) * cos(radB);
|
||||
double M = a *
|
||||
((1 - e12 / 4 - 3 * e12 * e12 / 64 - 5 * e12 * e12 * e12 / 256) * radB -
|
||||
(3 * e12 / 8 + 3 * e12 * e12 / 32 + 45 * e12 * e12 * e12 / 1024) *
|
||||
sin(2 * radB) +
|
||||
(15 * e12 * e12 / 256 + 45 * e12 * e12 * e12 / 1024) *
|
||||
sin(4 * radB) -
|
||||
(35 * e12 * e12 * e12 / 3072) * sin(6 * radB));
|
||||
|
||||
//x,y的计算公式见孔祥元等主编武汉大学出版社2002年出版的《控制测量学》的第72页
|
||||
//书的的括号有问题,( 和 [ 应该交换
|
||||
|
||||
double x = M +
|
||||
N *
|
||||
tan(radB) *
|
||||
(A * A / 2 +
|
||||
(5 - T + 9 * C + 4 * C * C) * A * A * A * A / 24 +
|
||||
(61 - 58 * T + T * T + 600 * C - 330 * e22) *
|
||||
A *
|
||||
A *
|
||||
A *
|
||||
A *
|
||||
A *
|
||||
A /
|
||||
720);
|
||||
double y = N *
|
||||
(A +
|
||||
(1 - T + C) * A * A * A / 6 +
|
||||
(5 - 18 * T * T * T + 72 * C - 58 * e22) * A * A * A * A * A / 120);
|
||||
|
||||
x = offsetX + x * (b + elevation) / b;
|
||||
y = offsetY + y * (b + elevation) / b;
|
||||
|
||||
return CoordXYH(
|
||||
X: (x * 1000).round() / 1000, Y: (y * 1000).round() / 1000, H: BLH.H);
|
||||
}
|
||||
|
||||
/*
|
||||
大地平面坐标系 转换到 地心大地坐标系
|
||||
prjHeight: 投影面高程
|
||||
http://www.cnblogs.com/imeiba/p/5696967.html
|
||||
*/
|
||||
CoordBLH XY2BL(CoordXYH xyh,
|
||||
[srcDst = false, offsetY = 500000, offsetX = 0]) {
|
||||
Ellipsoid ellipsoid = srcDst ? srcEllipsoid : dstEllipsoid;
|
||||
double a = ellipsoid.A;
|
||||
double b = ellipsoid.B;
|
||||
double e12 = ellipsoid.E12;
|
||||
double e22 = ellipsoid.E22;
|
||||
|
||||
double e1 = (1 - sqrt(1 - e12)) / (1 + sqrt(1 - e12));
|
||||
double radL0 = L0 / 180 * pi;
|
||||
// 带内大地坐标
|
||||
double Y = xyh.Y % 1000000;
|
||||
double x = (xyh.X - offsetX) * b / (b + elevation);
|
||||
double y = (Y - offsetY) * b / (b + elevation);
|
||||
|
||||
double u = x /
|
||||
(a * (1 - e12 / 4 - 3 * e12 * e12 / 64 - 5 * e12 * e12 * e12 / 256));
|
||||
double fai = u +
|
||||
(3 * e1 / 2 - 27 * e1 * e1 * e1 / 32) * sin(2 * u) +
|
||||
(21 * e1 * e1 / 16 - 55 * e1 * e1 * e1 * e1 / 32) * sin(4 * u) +
|
||||
(151 * e1 * e1 * e1 / 96) * sin(6 * u) +
|
||||
(1097 * e1 * e1 * e1 * e1 / 512) * sin(8 * u);
|
||||
double C = e22 * cos(fai) * cos(fai);
|
||||
double T = tan(fai) * tan(fai);
|
||||
double N = a / sqrt(1 - e12 * sin(fai) * sin(fai));
|
||||
double R = a *
|
||||
(1 - e12) /
|
||||
sqrt((1 - e12 * sin(fai) * sin(fai)) *
|
||||
(1 - e12 * sin(fai) * sin(fai)) *
|
||||
(1 - e12 * sin(fai) * sin(fai)));
|
||||
double D = y / N;
|
||||
|
||||
double L = radL0 +
|
||||
(D -
|
||||
(1 + 2 * T + C) * D * D * D / 6 +
|
||||
(5 - 2 * C + 28 * T - 3 * C * C + 8 * e22 + 24 * T * T) *
|
||||
D *
|
||||
D *
|
||||
D *
|
||||
D *
|
||||
D /
|
||||
120) /
|
||||
cos(fai);
|
||||
double B = fai -
|
||||
(N * tan(fai) / R) *
|
||||
(D * D / 2 -
|
||||
(5 + 3 * T + 10 * C - 4 * C * C - 9 * e22) *
|
||||
D *
|
||||
D *
|
||||
D *
|
||||
D /
|
||||
24 +
|
||||
(61 + 90 * T + 298 * C + 45 * T * T - 256 * e22 - 3 * C * C) *
|
||||
D *
|
||||
D *
|
||||
D *
|
||||
D *
|
||||
D *
|
||||
D /
|
||||
720);
|
||||
|
||||
B = B * 180 / pi;
|
||||
L = L * 180 / pi;
|
||||
return CoordBLH(B: B, L: L, H: xyh.H);
|
||||
}
|
||||
|
||||
//两点之间的距离公式
|
||||
dist(PointXY p1, PointXY p2) {
|
||||
double d = sqrt(pow((p2.X - p1.X), 2) + pow((p2.Y - p1.Y), 2));
|
||||
return d;
|
||||
}
|
||||
|
||||
//求坐标方位角
|
||||
double fwj(PointXY p1, PointXY p2) {
|
||||
double dx = p2.X - p1.X;
|
||||
double dy = p2.Y - p1.Y;
|
||||
return pi - sign(dy) - atan(dx / dy);
|
||||
}
|
||||
|
||||
// 计算三参数
|
||||
TransOptions calcThree(CoordBLH p1, CoordXYH p2) {
|
||||
CoordXYZ source = BLH2XYZ(p1);
|
||||
CoordBLH bl = XY2BL(p2, true);
|
||||
CoordXYZ dest = BLH2XYZ(bl, true);
|
||||
|
||||
double dX = dest.X - source.X;
|
||||
double dY = dest.Y - source.Y;
|
||||
double dZ = dest.Z - source.Z;
|
||||
return TransOptions(dx: dX, dy: dY, dz: dZ);
|
||||
}
|
||||
|
||||
// TransOptions calcFour(List p1, List p2, int PointCount) {
|
||||
// double rota = 0;
|
||||
// double scale = 0;
|
||||
// double dx = 0;
|
||||
// double dy = 0;
|
||||
// if (PointCount == 2) {
|
||||
// rota = fwj(p2[0] as PointXY, p2[1]) - fwj(p1[0], p1[1]);
|
||||
// scale = dist(p2[0], p2[1]) / dist(p1[0], p1[1]);
|
||||
// dx = p2[0].X - scale * cos(rota) * p1[0].X + scale * sin(rota) * p1[0].Y;
|
||||
// dy = p2[0].Y - scale * sin(rota) * p1[0].X - scale * cos(rota) * p1[0].Y;
|
||||
// } else if (PointCount > 2) {
|
||||
// double u = 1.0, v = 0, Dx = 0.0, Dy = 0.0;
|
||||
// int intCount = PointCount;
|
||||
|
||||
// Matrix4 dx1 = Matrix.zeros(4, 1);
|
||||
// // Matrix4 B1 = Matrix.zeros(2 * intCount, 4);
|
||||
// Matrix4 B1 = Matrix4.zero();
|
||||
// for (int i = 0; i < 2 * intCount; i++) {
|
||||
// for (int j = 0; j < 4; j++) {
|
||||
// B1.setEntry(i, j, 0);
|
||||
// }
|
||||
// }
|
||||
// Matrix4 W1 = Matrix.zeros(2 * intCount, 1);
|
||||
// // Matrix4 BT = Matrix.zeros(4, 2 * intCount);
|
||||
// Matrix4 BT = Matrix4.zero();
|
||||
// for (int i = 0; i < 4; i++) {
|
||||
// for (int j = 0; j < 2 * intCount; j++) {
|
||||
// BT.setEntry(i, j, 0);
|
||||
// }
|
||||
// }
|
||||
// Matrix4 N = Matrix4(
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// );
|
||||
// Matrix4 InvN = Matrix4(
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// );
|
||||
// Matrix4 BTW = Matrix.zeros(4, 1);
|
||||
// for (int i = 0; i < intCount; i++) {
|
||||
// //计算误差方程系数
|
||||
// B1.setEntry(2 * i, 0, 1);
|
||||
// B1.setEntry(2 * i, 1, 0);
|
||||
// B1.setEntry(2 * i, 2, p1[i].X);
|
||||
// B1.setEntry(2 * i, 3, -p1[i].Y);
|
||||
|
||||
// B1.setEntry(2 * i + 1, 0, 0);
|
||||
// B1.setEntry(2 * i + 1, 1, 1);
|
||||
// B1.setEntry(2 * i + 1, 2, p1[i].Y);
|
||||
// B1.setEntry(2 * i + 1, 3, p1[i].X);
|
||||
// // B1[2 * i][0] = 1;
|
||||
// // B1[2 * i][1] = 0;
|
||||
// // B1[2 * i][2] = p1[i].X;
|
||||
// // B1[2 * i][3] = -p1[i].Y;
|
||||
|
||||
// // B1[2 * i + 1][0] = 0;
|
||||
// // B1[2 * i + 1][1] = 1;
|
||||
// // B1[2 * i + 1][2] = p1[i].Y;
|
||||
// // B1[2 * i + 1][3] = p1[i].X;
|
||||
// }
|
||||
// for (int i = 0; i < intCount; i++) {
|
||||
// //计算误差方程系常数
|
||||
// // W1[2 * i][0] = p2[i].X - u * p1[i].X + v * p1[i].Y - Dx;
|
||||
// // W1[2 * i + 1][0] = p2[i].Y - u * p1[i].Y - v * p1[i].X - Dy;
|
||||
// W1.setEntry(2 * i, 0, p2[i].X - u * p1[i].X + v * p1[i].Y - Dx);
|
||||
// W1.setEntry(2 * i + 1, 0, p2[i].Y - u * p1[i].Y - v * p1[i].X - Dy);
|
||||
// }
|
||||
// // 最小二乘求解
|
||||
// Matrix4 b1 = Matrix4.identity();
|
||||
// // 矩阵 B1 的转置
|
||||
// BT = Matrix4.copy(b1);
|
||||
// BT.transpose();
|
||||
// // 矩阵乘法
|
||||
// N = BT * B1;
|
||||
// // 逆矩阵
|
||||
// InvN = N.clone();
|
||||
// InvN.invert();
|
||||
// BTW = BT * (W1);
|
||||
// dx1 = InvN * (BTW);
|
||||
|
||||
// Dx = Dx + dx1[0][0];
|
||||
// Dy = Dy + dx1[1][0];
|
||||
// u = u + dx1[2][0];
|
||||
// v = v + dx1[3][0];
|
||||
// dx = Dx;
|
||||
// dy = Dy;
|
||||
// rota = atan(v / u);
|
||||
// scale = u / cos(rota);
|
||||
// }
|
||||
// return TransOptions(rota: rota, k: scale, dx: dx, dy: dy);
|
||||
// }
|
||||
|
||||
// // 计算七参数
|
||||
// TransOptions calcBuras(List p1, List p2, pointCount) {
|
||||
// let B1 = Matrix.zeros(pointCount * 3, 7);
|
||||
// let dx1 = Matrix.zeros(7, 1);
|
||||
// let L = Matrix.zeros(pointCount * 3, 1);
|
||||
// let BT = Matrix.zeros(7, pointCount * 3);
|
||||
// let N = Matrix.zeros(7, 7);
|
||||
// let InvN = Matrix.zeros(7, 7);
|
||||
// let BTL = Matrix.zeros(7, 1);
|
||||
// for (int i = 0; i < pointCount * 3; i++) {
|
||||
// if (i % 3 == 0) {
|
||||
// L[i][0] = p2[(i / 3).floor()].X;
|
||||
// } else if (i % 3 == 1) {
|
||||
// L[i][0] = p2[(i / 3).floor()].Y;
|
||||
// } else if (i % 3 == 2) {
|
||||
// L[i][0] = p2[(i / 3).floor()].Z;
|
||||
// }
|
||||
// }
|
||||
|
||||
// for (int i = 0; i < pointCount * 3; i++) {
|
||||
// if (i % 3 == 0) {
|
||||
// int index = (i / 3) as int;
|
||||
// B1[i][0] = 1;
|
||||
// B1[i][1] = 0;
|
||||
// B1[i][2] = 0;
|
||||
// B1[i][3] = p1[index].X;
|
||||
// B1[i][4] = 0;
|
||||
// B1[i][5] = -p1[index].Z;
|
||||
// B1[i][6] = p1[index].Y;
|
||||
// } else if (i % 3 == 1) {
|
||||
// int index = ((i - 1) / 3) as int;
|
||||
// B1[i][0] = 0;
|
||||
// B1[i][1] = 1;
|
||||
// B1[i][2] = 0;
|
||||
// B1[i][3] = p1[index].Y;
|
||||
// B1[i][4] = p1[index].Z;
|
||||
// B1[i][5] = 0;
|
||||
// B1[i][6] = -p1[index].X;
|
||||
// } else if (i % 3 == 2) {
|
||||
// int index = ((i - 2) / 3) as int;
|
||||
// B1[i][0] = 0;
|
||||
// B1[i][1] = 0;
|
||||
// B1[i][2] = 1;
|
||||
// B1[i][3] = p1[index].Z;
|
||||
// B1[i][4] = -p1[index].Y;
|
||||
// B1[i][5] = p1[index].X;
|
||||
// B1[i][6] = 0;
|
||||
// }
|
||||
// }
|
||||
// Matrix4 b1 = Matrix4.identity();
|
||||
// BT = B1.transpose();
|
||||
// N = BT.mmul(B1);
|
||||
// InvN = inverse(N);
|
||||
// BTL = BT.mmul(L);
|
||||
// dx1 = InvN.mmul(BTL);
|
||||
|
||||
// double dx = dx1[0][0];
|
||||
// double dy = dx1[1][0];
|
||||
// double dz = dx1[2][0];
|
||||
// double scale = dx1[3][0];
|
||||
// double rotax = dx1[4][0] / dx1[3][0];
|
||||
// double rotay = dx1[5][0] / dx1[3][0];
|
||||
// double rotaz = dx1[6][0] / dx1[3][0];
|
||||
|
||||
// return TransOptions(
|
||||
// dx: dx, dy: dy, dz: dz, k: scale, rx: rotax, ry: rotay, rz: rotaz);
|
||||
// }
|
||||
|
||||
double sign(num number) {
|
||||
if (number < 0) {
|
||||
return -1.0;
|
||||
} else if (number > 0) {
|
||||
return 1.0;
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
|
||||
import 'package:cpnav/service/base.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
|
||||
class PassTrackController extends GetxController {
|
||||
final mapController = Get.put(ScenceMapController());
|
||||
|
@ -2,7 +2,8 @@ import 'package:cpnav/pages/pass_track/view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
|
||||
|
||||
ScenceMapController mapController = Get.put(ScenceMapController());
|
||||
|
||||
|
@ -5,7 +5,7 @@ import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
import 'package:scence_map/scence_map.dart';
|
||||
|
||||
import 'package:syncfusion_flutter_sliders/sliders.dart';
|
||||
|
@ -1,9 +1,8 @@
|
||||
import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
|
||||
import '../../../controllers/plumController.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
import 'package:scence_map/controllers/plumController.dart';
|
||||
|
||||
|
||||
ScenceMapController mapController = Get.find<ScenceMapController>();
|
||||
|
@ -1,12 +1,14 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
import 'package:scence_map/controllers/plumController.dart';
|
||||
|
||||
import 'package:scence_map/scence_map.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../controllers/plumController.dart';
|
||||
import '../../../models/pilePoint/hyrecorditem.dart';
|
||||
import '../../pass_track/view.dart';
|
||||
import 'draw_pile.dart';
|
||||
|
||||
class RealView extends StatefulWidget {
|
||||
@ -192,13 +194,15 @@ class _RealViewState extends State<RealView> {
|
||||
return Stack(
|
||||
children: [
|
||||
Obx(() => AbsorbPointer(
|
||||
absorbing: controller.isGenerate.value
|
||||
? true
|
||||
: false, //设置CenterLayout 内的GestureDetector 不生效
|
||||
child: const ScenceMapView(
|
||||
children: [],
|
||||
),
|
||||
)),
|
||||
absorbing: controller.isGenerate.value
|
||||
? true
|
||||
: false, //设置CenterLayout 内的GestureDetector 不生效
|
||||
// child: const ScenceMapView(
|
||||
// children: [],
|
||||
// ),
|
||||
child: PassTrack(
|
||||
date: '',
|
||||
))),
|
||||
center,
|
||||
back,
|
||||
],
|
||||
|
@ -2,9 +2,9 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:scence_map/controller.dart';
|
||||
import 'package:scence_map/controllers/controller.dart';
|
||||
import 'package:scence_map/controllers/plumController.dart';
|
||||
|
||||
import '../../../controllers/plumController.dart';
|
||||
|
||||
import '../../../service/pile/device_type.dart';
|
||||
import '../../../service/pile/input.dart';
|
||||
@ -192,13 +192,17 @@ class PileGenerate extends GetView<PlumDataController> {
|
||||
child: const Text('确定'),
|
||||
onPressed: () {
|
||||
// 执行确定的逻辑
|
||||
var dx = controller.canvasSize.width / 2;
|
||||
var dy = controller.canvasSize.height / 2;
|
||||
var dx = (controller.canvasSize.width) / 2;
|
||||
var dy = (controller.canvasSize.height) / 2;
|
||||
var rotation = mapController.rotation.value;
|
||||
for (int i = 0; i < controller.plumList.length; i++) {
|
||||
Offset item = controller.plumList[i];
|
||||
|
||||
Offset xy = mapController.ScreenCenter2xy(
|
||||
item.dx - dx, item.dy - dy);
|
||||
var dx1 = (item.dx - dx) * cos(rotation) +
|
||||
(item.dy - dy) * sin(rotation);
|
||||
var dy1 = -(item.dx - dx) * sin(rotation) +
|
||||
(item.dy - dy) * cos(rotation);
|
||||
Offset xy = mapController.ScreenCenter2xy(dx1, dy1);
|
||||
PilePoint pilePoint = PilePoint(
|
||||
x: xy.dx,
|
||||
y: xy.dy,
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <libserialport/libserialport_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) libserialport_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "LibserialportPlugin");
|
||||
libserialport_plugin_register_with_registrar(libserialport_registrar);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
libserialport
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
26
pubspec.lock
26
pubspec.lock
@ -73,6 +73,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.8"
|
||||
dylib:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dylib
|
||||
sha256: bf609b3eb6492a3309b3d1dbe8f83a4031de5535dd7686be33487051cc760bb0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.3"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -131,6 +139,15 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
gnss:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: fb8ede658017931ab37db2aed4190e9a6ccd6000
|
||||
url: "https://git.mcxa.cn:89/flutter/gnss.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -187,6 +204,15 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.1"
|
||||
libserialport:
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: d6d27ef7aaf89e4dfa026db0c50dd3053c546710
|
||||
url: "https://git.mcxa.cn:89/flutter/libserialport.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -32,6 +32,10 @@ dependencies:
|
||||
sdk: flutter
|
||||
scence_map:
|
||||
path: plugins/scence_map
|
||||
gnss:
|
||||
git:
|
||||
url: https://git.mcxa.cn:89/flutter/gnss.git
|
||||
ref: main
|
||||
|
||||
# The following adds the Cupertino Icons font to your application.
|
||||
# Use with the CupertinoIcons class for iOS style icons.
|
||||
@ -69,7 +73,6 @@ flutter:
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- images/pilerCar.png
|
||||
- images/navi_pointer.png
|
||||
- images/satellite.png
|
||||
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <libserialport/libserialport_plugin_c_api.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
LibserialportPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("LibserialportPluginCApi"));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
libserialport
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
Loading…
Reference in New Issue
Block a user