2021-09-17 23:45:12 +02:00
|
|
|
#include "proj/mercator.h"
|
|
|
|
#include "proj/webmercator.h"
|
|
|
|
#include "proj/transversemercator.h"
|
|
|
|
#include "proj/lambertconic.h"
|
|
|
|
#include "proj/albersequal.h"
|
|
|
|
#include "proj/lambertazimuthal.h"
|
|
|
|
#include "proj/krovak.h"
|
|
|
|
#include "proj/polarstereographic.h"
|
|
|
|
#include "proj/obliquestereographic.h"
|
|
|
|
#include "proj/polyconic.h"
|
2018-01-08 23:47:45 +01:00
|
|
|
#include "datum.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
|
|
|
|
|
|
|
|
2021-06-17 21:58:25 +02:00
|
|
|
Projection::Projection(const PCS &pcs)
|
2023-04-13 08:39:33 +02:00
|
|
|
: _gcs(pcs.gcs()), _ct(0), _units(pcs.conversion().units()),
|
2024-03-11 23:12:51 +01:00
|
|
|
_cs(pcs.conversion().cs())
|
2018-01-08 23:47:45 +01:00
|
|
|
{
|
2021-06-17 21:58:25 +02:00
|
|
|
const Ellipsoid &ellipsoid = _gcs.datum().ellipsoid();
|
2024-03-19 22:39:42 +01:00
|
|
|
const Conversion::Setup &setup = pcs.conversion().setup();
|
2020-04-21 23:26:35 +02:00
|
|
|
|
2023-04-13 08:39:33 +02:00
|
|
|
switch (pcs.conversion().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;
|
2019-02-15 20:32:13 +01:00
|
|
|
case 9809:
|
|
|
|
_ct = new ObliqueStereographic(ellipsoid, setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.scale(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
|
|
|
break;
|
2020-12-04 00:25:57 +01:00
|
|
|
case 9818:
|
|
|
|
_ct = new Polyconic(ellipsoid, setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
|
|
|
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;
|
2019-01-08 21:42:28 +01:00
|
|
|
case 9829:
|
|
|
|
_ct = new PolarStereographic(ellipsoid, setup.latitudeOrigin(),
|
|
|
|
setup.longitudeOrigin(), setup.falseEasting(),
|
|
|
|
setup.falseNorthing());
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-17 21:58:25 +02:00
|
|
|
Projection::Projection(const GCS &gcs, const CoordinateSystem &cs)
|
2024-03-11 23:12:51 +01:00
|
|
|
: _gcs(gcs), _units(LinearUnits(9001)), _cs(cs)
|
2018-01-25 00:19:11 +01:00
|
|
|
{
|
2021-06-17 21:58:25 +02:00
|
|
|
_ct = new LatLon(gcs.angularUnits());
|
2018-01-25 00:19:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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-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)
|
|
|
|
{
|
2019-07-10 23:08:58 +02:00
|
|
|
if (this != &p) {
|
|
|
|
delete _ct;
|
2019-05-29 18:26:29 +02:00
|
|
|
|
2019-07-10 23:08:58 +02:00
|
|
|
_gcs = p._gcs;
|
|
|
|
_units = p._units;
|
|
|
|
_ct = p._ct ? p._ct->clone() : 0;
|
|
|
|
_cs = p._cs;
|
|
|
|
}
|
2018-01-25 00:19:11 +01:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2020-04-21 23:26:35 +02:00
|
|
|
bool Projection::operator==(const Projection &p) const
|
|
|
|
{
|
|
|
|
if (!isValid() || !p.isValid())
|
|
|
|
return false;
|
|
|
|
|
2021-06-17 21:58:25 +02:00
|
|
|
return (*_ct == *p._ct && _gcs == p._gcs && _units == p._units
|
2024-03-11 23:12:51 +01:00
|
|
|
&& _cs == p._cs);
|
2020-04-21 23:26:35 +02:00
|
|
|
}
|