70 lines
1.8 KiB
C++
Executable File
70 lines
1.8 KiB
C++
Executable File
/**
|
|
* CES Point Helpers
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QtCore/QPointF>
|
|
#include <QString>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
#include <Core/core.hpp>
|
|
|
|
namespace CentralEffectSimulation
|
|
{
|
|
|
|
inline QPointF geographic2Utm(double lon, double lat, int *zone = nullptr)
|
|
{
|
|
const int zoneToUse = zone ? *zone : -1;
|
|
auto utm = LtsCoordTrans::UtmCoordinate::fromGeographic(lon, lat, zoneToUse);
|
|
if (zone)
|
|
*zone = utm.zone;
|
|
return QPointF(utm.x, utm.y);
|
|
}
|
|
|
|
inline QPointF geographic2Utm(const Core::GeoPosition2D &geoPos, int *zone = nullptr)
|
|
{
|
|
const int zoneToUse = zone ? *zone : -1;
|
|
auto utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat(), zoneToUse);
|
|
if (zone)
|
|
*zone = utm.zone;
|
|
return QPointF(utm.x, utm.y);
|
|
}
|
|
|
|
inline QPointF geographic2Utm(const Core::GeoPosition &geoPos, int *zone = nullptr)
|
|
{
|
|
const int zoneToUse = zone ? *zone : -1;
|
|
auto utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat(), zoneToUse);
|
|
if (zone)
|
|
*zone = utm.zone;
|
|
return QPointF(utm.x, utm.y);
|
|
}
|
|
|
|
inline QString geographic2mgrs(const Core::GeoPosition2D &geoPos, int zone)
|
|
{
|
|
auto utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat(), zone);
|
|
return utm.mgrs();
|
|
}
|
|
|
|
inline QPointF geographic2Utm(const Core::GeoPosition2D &geoPos, int zone)
|
|
{
|
|
auto utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat(), zone);
|
|
return QPointF(utm.x, utm.y);
|
|
}
|
|
|
|
inline QString debug(const QPointF &p)
|
|
{
|
|
return QString::number(qRound(p.x())) + QLatin1Char('/') + QString::number(qRound(p.y()));
|
|
}
|
|
|
|
inline double getSquareDistance(const QPointF ¢erUtm, const QPointF &pointUtm)
|
|
{
|
|
QPointF p(pointUtm - centerUtm);
|
|
return p.x() * p.x() + p.y() * p.y();
|
|
} // getSquareDistance
|
|
|
|
}
|