13 , _latitudeFact(new
Fact(0, _latitudeFactName,
FactMetaData::valueTypeDouble, this))
14 , _longitudeFact(new
Fact(0, _longitudeFactName,
FactMetaData::valueTypeDouble, this))
16 , _hemisphereFact(new
Fact(0, _hemisphereFactName,
FactMetaData::valueTypeUint8, this))
17 , _eastingFact(new
Fact(0, _eastingFactName,
FactMetaData::valueTypeDouble, this))
18 , _northingFact(new
Fact(0, _northingFactName,
FactMetaData::valueTypeDouble, this))
23 if (_metaDataMap.isEmpty()) {
27 _latitudeFact->setMetaData(_metaDataMap[_latitudeFactName]);
28 _longitudeFact->setMetaData(_metaDataMap[_longitudeFactName]);
29 _zoneFact->setMetaData(_metaDataMap[_zoneFactName]);
30 _hemisphereFact->setMetaData(_metaDataMap[_hemisphereFactName]);
31 _eastingFact->setMetaData(_metaDataMap[_eastingFactName]);
32 _northingFact->setMetaData(_metaDataMap[_northingFactName]);
33 _mgrsFact->setMetaData(_metaDataMap[_mgrsFactName]);
36EditPositionDialogController::~EditPositionDialogController()
41void EditPositionDialogController::setCoordinate(QGeoCoordinate coordinate)
43 if (!coordinate.isValid()) {
44 qCWarning(EditPositionDialogControllerLog) <<
"Attempt to set invalid coordinate";
48 if (coordinate == _coordinate) {
52 const bool wasInvalid = !_coordinate.isValid();
53 _coordinate = coordinate;
62void EditPositionDialogController::initValues()
64 if (!_coordinate.isValid()) {
68 _latitudeFact->setRawValue(_coordinate.latitude());
69 _longitudeFact->setRawValue(_coordinate.longitude());
71 double easting, northing;
73 if ((zone >= 1) && (zone <= 60)) {
74 _zoneFact->setRawValue(zone);
75 _hemisphereFact->setRawValue(_coordinate.latitude() < 0);
76 _eastingFact->setRawValue(easting);
77 _northingFact->setRawValue(northing);
81 if (!mgrs.isEmpty()) {
82 _mgrsFact->setRawValue(mgrs);
86void EditPositionDialogController::setFromGeo()
88 QGeoCoordinate newCoordinate = _coordinate;
89 newCoordinate.setLatitude(_latitudeFact->rawValue().toDouble());
90 newCoordinate.setLongitude(_longitudeFact->rawValue().toDouble());
91 setCoordinate(newCoordinate);
94void EditPositionDialogController::setFromUTM()
96 qCDebug(EditPositionDialogControllerLog) << _eastingFact->rawValue().toDouble() << _northingFact->rawValue().toDouble() << _zoneFact->rawValue().toInt() << (_hemisphereFact->rawValue().toInt() == 1);
97 QGeoCoordinate newCoordinate;
98 if (
QGCGeo::convertUTMToGeo(_eastingFact->rawValue().toDouble(), _northingFact->rawValue().toDouble(), _zoneFact->rawValue().toInt(), _hemisphereFact->rawValue().toInt() == 1, newCoordinate)) {
99 qCDebug(EditPositionDialogControllerLog) << _eastingFact->rawValue().toDouble() << _northingFact->rawValue().toDouble() << _zoneFact->rawValue().toInt() << (_hemisphereFact->rawValue().toInt() == 1) << newCoordinate;
100 setCoordinate(newCoordinate);
106void EditPositionDialogController::setFromMGRS()
108 QGeoCoordinate newCoordinate;
110 setCoordinate(newCoordinate);
116void EditPositionDialogController::setFromVehicle()
118 setCoordinate(MultiVehicleManager::instance()->activeVehicle()->coordinate());
Geographic coordinate conversion utilities using GeographicLib.
#define QGC_LOGGING_CATEGORY(name, categoryStr)
void coordinateChanged(QGeoCoordinate coordinate)
A Fact is used to hold a single value within the system.
QString convertGeoToMGRS(const QGeoCoordinate &coord)
int convertGeoToUTM(const QGeoCoordinate &coord, double &easting, double &northing)
bool convertUTMToGeo(double easting, double northing, int zone, bool southhemi, QGeoCoordinate &coord)
bool convertMGRSToGeo(const QString &mgrs, QGeoCoordinate &coord)