PIGeoPosition as PIVariant support
This commit is contained in:
@@ -308,8 +308,7 @@ PIVariant::Type PIVariant::typeFromID(uint type_id) {
|
||||
|
||||
uint PIVariant::typeIDFromName(const PIString & tname) {
|
||||
PIVariant::Type t = typeFromName(tname);
|
||||
if (t == pivInvalid) return 0;
|
||||
if (t == pivCustom) return tname.hash();
|
||||
if (t == pivCustom || t == pivInvalid) return tname.hash();
|
||||
return typeIDFromType(t);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "piconstchars.h"
|
||||
#include "pidatetime.h"
|
||||
#include "pigeoposition.h"
|
||||
#include "piline.h"
|
||||
#include "pimathmatrix.h"
|
||||
#include "pinetworkaddress.h"
|
||||
@@ -1113,6 +1114,29 @@ REGISTER_VARIANT(PIMathMatrixd)
|
||||
REGISTER_VARIANT(PIVariantMap);
|
||||
REGISTER_VARIANT(PIVariantVector);
|
||||
|
||||
REGISTER_VARIANT(PIGeoPosition);
|
||||
REGISTER_VARIANT_CAST(PIGeoPosition, PIString) {
|
||||
PIGeoPosition g(v);
|
||||
g.setEllipsoidModel(PIEllipsoidModel::WGS84Ellipsoid());
|
||||
g.transformTo(PIGeoPosition::Geodetic);
|
||||
return PIString::fromNumber(g.latitudeGeodetic(), 'f', 8) + ", " + PIString::fromNumber(g.longitude(), 'f', 8) + ", " +
|
||||
PIString::fromNumber(g.height(), 'f', 2);
|
||||
};
|
||||
|
||||
REGISTER_VARIANT_CAST(PIString, PIGeoPosition) {
|
||||
PIStringList sl = v.split(",");
|
||||
if (sl.size() == 2) sl << "0";
|
||||
if (sl.size() >= 3) {
|
||||
return PIGeoPosition({sl[0].toDouble(), sl[1].toDouble(), sl[2].toDouble()}, PIGeoPosition::Geodetic);
|
||||
}
|
||||
sl = v.split(";");
|
||||
if (sl.size() == 2) sl << "0";
|
||||
if (sl.size() >= 3) {
|
||||
return PIGeoPosition({sl[0].toDouble(), sl[1].toDouble(), sl[2].toDouble()}, PIGeoPosition::Geodetic);
|
||||
}
|
||||
return PIGeoPosition({0., 0., 0.}, PIGeoPosition::Geodetic);
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PIBinaryStream
|
||||
//! \~english Store operator.
|
||||
|
||||
Reference in New Issue
Block a user