2018-01-08 23:47:45 +01:00
|
|
|
#include "datum.h"
|
2018-05-13 00:40:03 +02:00
|
|
|
#include "mercator.h"
|
2018-05-12 22:38:42 +02:00
|
|
|
#include "webmercator.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
#include "transversemercator.h"
|
|
|
|
#include "lambertconic.h"
|
|
|
|
#include "albersequal.h"
|
|
|
|
#include "lambertazimuthal.h"
|
2018-05-29 00:17:20 +02:00
|
|
|
#include "krovak.h"
|
2018-01-25 00:19:11 +01:00
|
|
|
#include "latlon.h"
|
|
|
|
#include "gcs.h"
|
2018-04-05 20:38:23 +02:00
|
|
|
#include "pcs.h"
|
2018-01-08 23:47:45 +01:00
|
|
|
#include "projection.h"
|
2017-11-26 18:54:03 +01:00
|
|
|
|
|
|
|
|
2018-01-08 23:47:45 +01:00
|
|
|
Projection::Method::Method(int id)
|
2017-11-26 18:54:03 +01:00
|
|
|
{
|
2018-01-08 23:47:45 +01:00
|
|
|
switch (id) {
|
|
|
|
case 1024:
|
2018-05-29 00:17:20 +02:00
|
|
|
case 1041:
|
2018-01-08 23:47:45 +01:00
|
|
|
case 9801:
|
|
|
|
case 9802:
|
2018-05-13 08:52:20 +02:00
|
|
|
case 9804:
|
2018-01-08 23:47:45 +01:00
|
|
|
case 9807:
|
2018-03-11 01:10:24 +01:00
|
|
|
case 9815:
|
2018-05-29 00:17:20 +02:00
|
|
|
case 9819:
|
2018-01-08 23:47:45 +01:00
|
|
|
case 9820:
|
|
|
|
case 9822:
|
|
|
|
_id = id;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
_id = 0;
|
2017-11-26 18:54:03 +01:00
|
|
|
}
|
2018-01-08 23:47:45 +01:00
|
|
|
}
|
|
|
|
|
2018-04-05 20:38:23 +02:00
|
|
|
Projection::Projection(const PCS *pcs) : _gcs(pcs->gcs()), _units(pcs->units()),
|
2018-04-07 18:42:25 +02:00
|
|
|
_cs(pcs->coordinateSystem()), _geographic(false)
|
2018-01-08 23:47:45 +01:00
|
|
|
{
|
2018-01-25 00:19:11 +01:00
|
|
|
const Ellipsoid *ellipsoid = _gcs->datum().ellipsoid();
|
2018-04-05 20:38:23 +02:00
|
|
|
const Projection::Setup &setup = pcs->setup();
|
2017-11-26 18:54:03 +01:00
|
|
|
|
2018-04-05 20:38:23 +02:00
|
|
|
switch (pcs->method().id()) {
|
2018-01-08 23:47:45 +01:00
|
|
|
case 1024:
|
2018-05-12 22:38:42 +02:00
|
|
|
_ct = new WebMercator();
|
2018-01-25 00:19:11 +01:00
|
|
|
break;
|
2018-05-29 00:17:20 +02:00
|
|
|
case 1041:
|
2018-05-29 21:54:25 +02:00
|
|
|
_ct = new KrovakNE(ellipsoid, setup.standardParallel1(),
|
2018-05-29 00:17:20 +02:00
|
|
|
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
2018-05-29 21:54:25 +02:00
|
|
|
setup.falseNorthing());
|
2018-05-29 00:17:20 +02:00
|
|
|
break;
|
2018-03-11 01:10:24 +01:00
|
|
|
case 9801:
|
|
|
|
case 9815: // Oblique mercator aproximation using LCC1
|
|
|
|
_ct = new LambertConic1(ellipsoid, setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.scale(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
|
|
|
break;
|
2018-01-08 23:47:45 +01:00
|
|
|
case 9802:
|
2018-01-25 00:19:11 +01:00
|
|
|
_ct = new LambertConic2(ellipsoid, setup.standardParallel1(),
|
2018-01-08 23:47:45 +01:00
|
|
|
setup.standardParallel2(), setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
2018-05-13 00:40:03 +02:00
|
|
|
break;
|
2018-05-13 08:52:20 +02:00
|
|
|
case 9804:
|
2018-05-13 00:40:03 +02:00
|
|
|
_ct = new Mercator(ellipsoid, setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
2018-01-25 00:19:11 +01:00
|
|
|
break;
|
2018-03-11 01:10:24 +01:00
|
|
|
case 9807:
|
|
|
|
_ct = new TransverseMercator(ellipsoid, setup.latitudeOrigin(),
|
2018-01-08 23:47:45 +01:00
|
|
|
setup.longitudeOrigin(), setup.scale(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
2018-01-25 00:19:11 +01:00
|
|
|
break;
|
2018-05-29 00:17:20 +02:00
|
|
|
case 9819:
|
|
|
|
_ct = new Krovak(ellipsoid, setup.standardParallel1(),
|
|
|
|
setup.standardParallel2(), setup.scale(), setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
2018-05-29 21:54:25 +02:00
|
|
|
setup.falseNorthing());
|
2018-05-29 00:17:20 +02:00
|
|
|
break;
|
2018-01-08 23:47:45 +01:00
|
|
|
case 9820:
|
2018-01-25 00:19:11 +01:00
|
|
|
_ct = new LambertAzimuthal(ellipsoid, setup.latitudeOrigin(),
|
2018-01-08 23:47:45 +01:00
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
2018-01-25 00:19:11 +01:00
|
|
|
break;
|
2018-01-08 23:47:45 +01:00
|
|
|
case 9822:
|
2018-01-25 00:19:11 +01:00
|
|
|
_ct = new AlbersEqual(ellipsoid, setup.standardParallel1(),
|
2018-01-08 23:47:45 +01:00
|
|
|
setup.standardParallel2(), setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
2018-01-25 00:19:11 +01:00
|
|
|
break;
|
2018-01-08 23:47:45 +01:00
|
|
|
default:
|
2018-01-25 00:19:11 +01:00
|
|
|
_ct = 0;
|
2017-11-26 18:54:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-07 18:42:25 +02:00
|
|
|
Projection::Projection(const GCS *gcs, const CoordinateSystem &cs)
|
|
|
|
: _gcs(gcs), _units(LinearUnits(9001)), _cs(cs), _geographic(true)
|
2018-01-25 00:19:11 +01:00
|
|
|
{
|
|
|
|
_ct = new LatLon(gcs->angularUnits());
|
|
|
|
}
|
|
|
|
|
|
|
|
Projection::Projection(const Projection &p)
|
|
|
|
{
|
|
|
|
_gcs = p._gcs;
|
|
|
|
_units = p._units;
|
2018-03-11 09:24:04 +01:00
|
|
|
_ct = p._ct ? p._ct->clone() : 0;
|
2018-02-22 21:02:56 +01:00
|
|
|
_geographic = p._geographic;
|
2018-04-07 18:42:25 +02:00
|
|
|
_cs = p._cs;
|
2018-01-25 00:19:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Projection::~Projection()
|
|
|
|
{
|
|
|
|
delete _ct;
|
|
|
|
}
|
|
|
|
|
|
|
|
Projection &Projection::operator=(const Projection &p)
|
|
|
|
{
|
|
|
|
_gcs = p._gcs;
|
|
|
|
_units = p._units;
|
2018-03-11 09:24:04 +01:00
|
|
|
_ct = p._ct ? p._ct->clone() : 0;
|
2018-02-22 21:02:56 +01:00
|
|
|
_geographic = p._geographic;
|
2018-04-07 18:42:25 +02:00
|
|
|
_cs = p._cs;
|
2018-01-25 00:19:11 +01:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-04-15 16:27:47 +02:00
|
|
|
PointD Projection::ll2xy(const Coordinates &c) const
|
2018-01-25 00:19:11 +01:00
|
|
|
{
|
2018-05-16 18:52:48 +02:00
|
|
|
Q_ASSERT(isValid());
|
|
|
|
return _units.fromMeters(_ct->ll2xy(_gcs->fromWGS84(c)));
|
2018-01-25 00:19:11 +01:00
|
|
|
}
|
|
|
|
|
2018-04-15 16:27:47 +02:00
|
|
|
Coordinates Projection::xy2ll(const PointD &p) const
|
2018-01-25 00:19:11 +01:00
|
|
|
{
|
2018-05-16 18:52:48 +02:00
|
|
|
Q_ASSERT(isValid());
|
|
|
|
return _gcs->toWGS84(_ct->xy2ll(_units.toMeters(p)));
|
2018-01-25 00:19:11 +01:00
|
|
|
}
|
|
|
|
|
2018-02-13 23:03:18 +01:00
|
|
|
#ifndef QT_NO_DEBUG
|
2018-01-08 23:47:45 +01:00
|
|
|
QDebug operator<<(QDebug dbg, const Projection::Setup &setup)
|
|
|
|
{
|
|
|
|
dbg.nospace() << "Setup(" << setup.latitudeOrigin() << ", "
|
|
|
|
<< setup.longitudeOrigin() << ", " << setup.scale() << ", "
|
|
|
|
<< setup.falseEasting() << ", " << setup.falseNorthing() << ", "
|
|
|
|
<< setup.standardParallel1() << ", " << setup.standardParallel2() << ")";
|
2018-01-21 11:19:46 +01:00
|
|
|
return dbg.space();
|
2018-01-08 23:47:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QDebug operator<<(QDebug dbg, const Projection::Method &method)
|
2017-11-26 18:54:03 +01:00
|
|
|
{
|
2018-01-08 23:47:45 +01:00
|
|
|
dbg.nospace() << "Method(" << method.id() << ")";
|
2018-01-21 11:19:46 +01:00
|
|
|
return dbg.space();
|
2017-11-26 18:54:03 +01:00
|
|
|
}
|
2018-02-13 23:03:18 +01:00
|
|
|
#endif // QT_NO_DEBUG
|