|
- /* Copyright(c)--Navinfo--Author:fangzurui--date:2023-10-13 */
-
- #include "DataManager/CoordLocate.h"
- #include "DataManager/ImageFileManager.h"
-
- CoordLocate::CoordLocate(QWidget* parent)
- : QDialog(parent)
- , ui(new Ui::CoordLocate){
- ui->setupUi(this);
-
- this->setWindowIcon(QIcon(QCoreApplication::applicationDirPath() + "\\Resource\\dmatch.ico"));
- initCoordWidget();
- }
-
- CoordLocate::~CoordLocate() {
- delete ui;
- }
-
- void CoordLocate::initCoordWidget() {
- // 设置文字信息
- ui->Confirm->setText(QObject::tr("Confirm"));
- ui->Cancel->setText(QObject::tr("Cancel"));
- ui->LongitudeLabel->setText(QObject::tr("Longitude"));
- ui->LatitudeLabel->setText(QObject::tr("Latitude"));
- ui->LongitudeEdit->setPlaceholderText(QObject::tr("Enter Longitude"));
- ui->LatitudeEdit->setPlaceholderText(QObject::tr("Enter Latitude"));
-
- connect(ui->Confirm, SIGNAL(clicked(bool)), this, SLOT(setCoordinate()));
- connect(ui->Cancel, SIGNAL(clicked(bool)), this, SLOT(close()));
- }
-
- void CoordLocate::setCoordinate() {
- if(ui->LongitudeEdit->text().isEmpty()) {
- QMessageBox::warning(this,
- QObject::tr("Waring"),
- QObject::tr("Please Enter Coordinate"),
- QMessageBox::Ok, QMessageBox::Ok);
- } else {
- // 从输入框中取值
- double longitude = -200.0;
- longitude = ui->LongitudeEdit->text().toDouble();
-
- double latitude = -100.0;
- latitude = ui->LatitudeEdit->text().toDouble();
-
- // 判断输入坐标是否正确
- if(latitude <= 90.0 && latitude >= -90.0 && longitude <= 180.0 && longitude >= -180.0) {
- MapPoint coord;
- coord._dLon = longitude;
- coord._dLat = latitude;
- double alt = Algorithm::getElevationFromTiff(coord._dLon, coord._dLat);
- coord._dAlt = alt;
-
- /* TODO:演示支持,后续版本删除 */
- if(longitude == 94.004937 && latitude == 40.093527) {
- coord._dLon = 94.0048997;
- coord._dLat = 40.0935301;
- coord._dAlt = 1132.23;
- }
- if(longitude == 93.997559 && latitude == 40.099244) {
- coord._dAlt = 1129.12;
- }
- if(longitude == 94.032925 && latitude == 40.126765) {
- coord._dLon = 94.0328439;
- coord._dLat = 40.1267974;
- coord._dAlt = 1125.44;
- }
- if(longitude == 93.988723 && latitude == 40.108658) {
- coord._dLon = 93.9886602;
- coord._dLat = 40.1087560;
- coord._dAlt = 1124.53;
- }
- if(longitude == 93.996401 && latitude == 40.103182) {
- coord._dAlt = 1122.78;
- }
- /* ----------------------- */
-
- // 设置视点
- OSGRender::getInstance()->setViewPoint("default", coord, 0, -90.0, 2000);
- // 更新左下坐标信息
- emit OSGRender::getInstance()->updatePickMapPoint(longitude, latitude, coord._dAlt); /* TODO:演示支持,后续版本删除 */
- // emit OSGRender::getInstance()->updatePickMapPoint(coord._dLon, coord._dLat, coord._dAlt);
- // 在坐标所表示的位置上放置一个标注,在窗口关闭时移除
- // 如果已经存在标注
- if(pPos.valid() == true) {
- // 移除已经存在的标注
- RenderNode::getInstance()->deleteMark(pPos.get());
- }
- pPos = RenderNode::getInstance()->getOrCreatePng(coord, 48, 48,
- QCoreApplication::applicationDirPath().toStdString() + "\\bubble.png");
- RenderNode::getInstance()->addMark(pPos);
- } else {
- QMessageBox::warning(this,
- QObject::tr("Waring"),
- QObject::tr("Enter Coordinate Illegal, Please Check!"),
- QMessageBox::Ok, QMessageBox::Ok);
- }
- }
- }
-
- void CoordLocate::closeEvent(QCloseEvent *event) {
- RenderNode::getInstance()->deleteMark(pPos.get());
- pPos.release();
-
- QWidget::closeEvent(event);
- }
|