OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ossimMercatorProjection Class Reference

#include <ossimMercatorProjection.h>

Inheritance diagram for ossimMercatorProjection:
ossimMapProjection ossimProjection ossimObject ossimErrorStatusInterface ossimReferenced

Public Member Functions

 ossimMercatorProjection (const ossimEllipsoid &ellipsoid=ossimEllipsoid(), const ossimGpt &origin=ossimGpt())
 
 ossimMercatorProjection (const ossimEllipsoid &ellipsoid, const ossimGpt &origin, double falseEasting, double falseNorthing, double scaleFactor)
 
 ~ossimMercatorProjection ()
 
virtual ossimObjectdup () const
 
virtual ossimGpt inverse (const ossimDpt &eastingNorthing) const
 Will take a point in meters and convert it to ground. More...
 
virtual ossimDpt forward (const ossimGpt &latLon) const
 All map projections will convert the world coordinate to an easting northing (Meters). More...
 
virtual void update ()
 
void setFalseEasting (double falseEasting)
 
void setFalseNorthing (double falseNorthing)
 
void setFalseEastingNorthing (double falseEasting, double falseNorthing)
 
void setScaleFactor (double scaleFactor)
 
void setParameters (double falseEasting, double falseNorthing, double scaleFactor)
 
void setDefaults ()
 
double getFalseEasting () const
 
double getFalseNorthing () const
 
double getScaleFactor () const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual bool operator== (const ossimProjection &projection) const
 Returns TRUE if principal parameters are within epsilon tolerance. More...
 
- Public Member Functions inherited from ossimMapProjection
 ossimMapProjection (const ossimEllipsoid &ellipsoid=ossimEllipsoid(), const ossimGpt &origin=ossimGpt())
 
 ossimMapProjection (const ossimMapProjection &src)
 
virtual ossimGpt origin () const
 
virtual ossimDpt worldToLineSample (const ossimGpt &worldPoint) const
 
virtual void worldToLineSample (const ossimGpt &worldPoint, ossimDpt &lineSample) const
 
virtual ossimGpt lineSampleToWorld (const ossimDpt &projectedPoint) const
 
virtual void lineSampleToWorld (const ossimDpt &projectedPoint, ossimGpt &gpt) const
 
virtual void lineSampleHeightToWorld (const ossimDpt &lineSampPt, const double &heightAboveEllipsoid, ossimGpt &worldPt) const
 This is the pure virtual that projects the image point to the given elevation above ellipsoid, thereby bypassing reference to a DEM. More...
 
virtual void lineSampleToEastingNorthing (const ossimDpt &liineSample, ossimDpt &eastingNorthing) const
 
virtual void eastingNorthingToLineSample (const ossimDpt &eastingNorthing, ossimDpt &lineSample) const
 
virtual void eastingNorthingToWorld (const ossimDpt &eastingNorthing, ossimGpt &worldPt) const
 
virtual double getStandardParallel1 () const
 Derived classes should implement as needed. More...
 
virtual double getStandardParallel2 () const
 Derived classes should implement as needed. More...
 
virtual void setPcsCode (ossim_uint32 pcsCode)
 
virtual ossim_uint32 getPcsCode () const
 Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection. More...
 
virtual ossimString getProjectionName () const
 Returns the projection name. More...
 
virtual double getA () const
 ACCESS METHODS: More...
 
virtual double getB () const
 
virtual double getF () const
 
virtual ossimDpt getMetersPerPixel () const
 
virtual const ossimDptgetDecimalDegreesPerPixel () const
 Returns decimal degrees per pixel as an ossimDpt with "x" representing longitude and "y" representing latitude. More...
 
virtual const ossimDptgetUlEastingNorthing () const
 
virtual const ossimGptgetUlGpt () const
 
virtual const ossimDatumgetDatum () const
 
const ossimEllipsoidgetEllipsoid () const
 
const ossimGptgetOrigin () const
 
virtual bool isGeographic () const
 
virtual void applyScale (const ossimDpt &scale, bool recenterTiePoint)
 Applies scale to theDeltaLonPerPixel, theDeltaLatPerPixel and theMetersPerPixel data members (eg: theDeltaLonPerPixel *= scale.x). More...
 
virtual void setEllipsoid (const ossimEllipsoid &ellipsoid)
 SET METHODS: More...
 
virtual void setAB (double a, double b)
 
virtual void setDatum (const ossimDatum *datum)
 Sets theDatum to datum. More...
 
virtual void setOrigin (const ossimGpt &origin)
 Sets theOrigin to origin. More...
 
virtual void setMetersPerPixel (const ossimDpt &gsd)
 
virtual void setDecimalDegreesPerPixel (const ossimDpt &gsd)
 
virtual void setUlTiePoints (const ossimGpt &gpt)
 
virtual void setUlTiePoints (const ossimDpt &eastingNorthing)
 
virtual void setUlEastingNorthing (const ossimDpt &ulEastingNorthing)
 
virtual void setUlGpt (const ossimGpt &ulGpt)
 
virtual void assign (const ossimProjection &aProjection)
 
virtual std::ostream & print (std::ostream &out) const
 Prints data members to stream. More...
 
virtual void computeDegreesPerPixel ()
 Computes the approximate resolution in degrees/pixel. More...
 
virtual void computeMetersPerPixel ()
 This will go from the ground point and give you an approximate meters per pixel. More...
 
void setMatrix (double rotation, const ossimDpt &scale, const ossimDpt &translation)
 
void setMatrixScale (const ossimDpt &scale)
 
void setMatrixRotation (double rotation)
 
void setMatrixTranslation (const ossimDpt &translation)
 
void snapTiePointTo (ossim_float64 multiple, ossimUnitType unitType)
 Utility method to snap the tie point to some multiple. More...
 
void snapTiePointToOrigin ()
 
void setElevationLookupFlag (bool flag)
 
bool getElevationLookupFlag () const
 
ossimUnitType getModelTransformUnitType () const
 
void setModelTransformUnitType (ossimUnitType unit)
 
bool hasModelTransform () const
 
virtual bool isAffectedByElevation () const
 Implementation of pure virtual ossimProjection::isAffectedByElevation method. More...
 
void setProjectionUnits (ossimUnitType units)
 
ossimUnitType getProjectionUnits () const
 OSSIM considers all map projection coordinates (including false eastings and northings) to be in meters. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
- Public Member Functions inherited from ossimProjection
 ossimProjection ()
 
virtual ~ossimProjection ()
 
virtual void getRoundTripError (const ossimDpt &imagePoint, ossimDpt &errorResult) const
 
virtual void getRoundTripError (const ossimGpt &groundPoint, ossimDpt &errorResult) const
 
virtual void getGroundClipPoints (ossimGeoPolygon &gpts) const
 
virtual bool operator!= (const ossimProjection &projection) const
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 

Private Member Functions

long Set_Mercator_Parameters (double a, double f, double Origin_Latitude, double Central_Meridian, double False_Easting, double False_Northing, double *Scale_Factor)
 
void Get_Mercator_Parameters (double *a, double *f, double *Origin_Latitude, double *Central_Meridian, double *False_Easting, double *False_Northing, double *Scale_Factor) const
 
long Convert_Geodetic_To_Mercator (double Latitude, double Longitude, double *Easting, double *Northing) const
 
long Convert_Mercator_To_Geodetic (double Easting, double Northing, double *Latitude, double *Longitude) const
 

Private Attributes

double Merc_a
 
double Merc_f
 
double Merc_e
 
double Merc_es
 
double Merc_Origin_Lat
 
double Merc_Origin_Long
 
double Merc_False_Northing
 
double Merc_False_Easting
 
double Merc_Scale_Factor
 
double Merc_ab
 
double Merc_bb
 
double Merc_cb
 
double Merc_db
 
double Merc_Delta_Easting
 
double Merc_Delta_Northing
 
bool theSphericalFlag
 

Additional Inherited Members

- Protected Member Functions inherited from ossimMapProjection
virtual ~ossimMapProjection ()
 
void updateFromTransform ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Attributes inherited from ossimMapProjection
ossimEllipsoid theEllipsoid
 This method verifies that the projection parameters match the current pcs code. More...
 
ossimGpt theOrigin
 
const ossimDatumtheDatum
 This is only set if we want to have built in datum shifting. More...
 
ossimDpt theMetersPerPixel
 Holds the number of meters per pixel. More...
 
ossimDpt theDegreesPerPixel
 Hold the decimal degrees per pixel. More...
 
ossimGpt theUlGpt
 Hold tie point in decimal degrees. More...
 
ossimDpt theUlEastingNorthing
 Hold tie point as easting northing. More...
 
ossimDpt theFalseEastingNorthing
 Hold the false easting northing. More...
 
ossim_uint32 thePcsCode
 Projection Coordinate System(PCS) code. More...
 
bool theElevationLookupFlag
 
ossimMatrix4x4 theModelTransform
 
ossimMatrix4x4 theInverseModelTransform
 
ossimUnitType theModelTransformUnitType
 
ossimUnitType theProjectionUnits
 Linear units of the projection as indicated in the projection's specification: More...
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Detailed Description

Definition at line 18 of file ossimMercatorProjection.h.

Constructor & Destructor Documentation

◆ ossimMercatorProjection() [1/2]

ossimMercatorProjection::ossimMercatorProjection ( const ossimEllipsoid ellipsoid = ossimEllipsoid(),
const ossimGpt origin = ossimGpt() 
)

Definition at line 40 of file ossimMercatorProjection.cpp.

References setDefaults(), and update().

42  :ossimMapProjection(ellipsoid, origin)
43 {
44  setDefaults();
45  update();
46 }
virtual ossimGpt origin() const
ossimMapProjection(const ossimEllipsoid &ellipsoid=ossimEllipsoid(), const ossimGpt &origin=ossimGpt())

◆ ossimMercatorProjection() [2/2]

ossimMercatorProjection::ossimMercatorProjection ( const ossimEllipsoid ellipsoid,
const ossimGpt origin,
double  falseEasting,
double  falseNorthing,
double  scaleFactor 
)

Definition at line 48 of file ossimMercatorProjection.cpp.

References Merc_False_Easting, Merc_False_Northing, Merc_Scale_Factor, setDefaults(), and update().

53  :ossimMapProjection(ellipsoid, origin)
54 {
55  setDefaults();
56  Merc_False_Easting = falseEasting;
57  Merc_False_Northing = falseNorthing;
58  Merc_Scale_Factor = scaleFactor;
59 
60  update();
61 }
virtual ossimGpt origin() const
ossimMapProjection(const ossimEllipsoid &ellipsoid=ossimEllipsoid(), const ossimGpt &origin=ossimGpt())

◆ ~ossimMercatorProjection()

ossimMercatorProjection::~ossimMercatorProjection ( )
inline

Definition at line 30 of file ossimMercatorProjection.h.

30 {}

Member Function Documentation

◆ Convert_Geodetic_To_Mercator()

long ossimMercatorProjection::Convert_Geodetic_To_Mercator ( double  Latitude,
double  Longitude,
double *  Easting,
double *  Northing 
) const
private

The function Convert_Geodetic_To_Mercator converts geodetic (latitude and longitude) coordinates to Mercator projection easting, and northing coordinates, according to the current ellipsoid and Mercator projection parameters. If any errors occur, the error code(s) are returned by the function, otherwise MERC_NO_ERROR is returned.

Latitude : Latitude (phi) in radians (input) Longitude : Longitude (lambda) in radians (input) Easting : Easting (X) in meters (output) Northing : Northing (Y) in meters (output)

Definition at line 373 of file ossimMercatorProjection.cpp.

References MAX_LAT, Merc_a, Merc_e, Merc_False_Easting, Merc_False_Northing, MERC_LAT_ERROR, MERC_NO_ERROR, Merc_Origin_Long, Merc_Scale_Factor, and PI.

Referenced by forward(), and Set_Mercator_Parameters().

377 { /* BEGIN Convert_Geodetic_To_Mercator */
378  long Error_Code = MERC_NO_ERROR;
379 /*
380  * The function Convert_Geodetic_To_Mercator converts geodetic (latitude and
381  * longitude) coordinates to Mercator projection (easting and northing)
382  * coordinates, according to the current ellipsoid and Mercator projection
383  * parameters. If any errors occur, the error code(s) are returned by the
384  * function, otherwise MERC_NO_ERROR is returned.
385  *
386  * Latitude : Latitude (phi) in radians (input)
387  * Longitude : Longitude (lambda) in radians (input)
388  * Easting : Easting (X) in meters (output)
389  * Northing : Northing (Y) in meters (output)
390  */
391 
392  double ctanz2; /* Cotangent of z/2 - z - Isometric colatitude */
393  double e_x_sinlat; /* e * sin(Latitude) */
394  double Delta_Long; /* Difference in origin longitude and longitude */
395  double tan_temp;
396  double pow_temp;
397 
398 
399  if ((Latitude < -MAX_LAT) || (Latitude > MAX_LAT))
400  { /* Latitude out of range */
401  Error_Code |= MERC_LAT_ERROR;
402  }
403 // if ((Longitude < -PI) || (Longitude > (2*PI)))
404 // { /* Longitude out of range */
405 // Error_Code |= MERC_LON_ERROR;
406 // }
407  if (!Error_Code)
408  { /* no errors */
409  if (Longitude > PI)
410  Longitude -= (2*PI);
411  e_x_sinlat = Merc_e * sin(Latitude);
412  tan_temp = tan(PI / 4.e0 + Latitude / 2.e0);
413  pow_temp = pow( ((1.e0 - e_x_sinlat) / (1.e0 + e_x_sinlat)),
414  (Merc_e / 2.e0) );
415  ctanz2 = tan_temp * pow_temp;
416  *Northing = Merc_Scale_Factor * Merc_a * log(ctanz2) + Merc_False_Northing;
417  Delta_Long = Longitude - Merc_Origin_Long;
418 // if (Delta_Long > PI)
419 // Delta_Long -= (2 * PI);
420 // if (Delta_Long < -PI)
421 // Delta_Long += (2 * PI);
422  *Easting = Merc_Scale_Factor * Merc_a * Delta_Long
424  }
425 
426  return (Error_Code);
427 } /* END OF Convert_Geodetic_To_Mercator */
#define MAX_LAT
#define MERC_NO_ERROR
#define PI
#define MERC_LAT_ERROR

◆ Convert_Mercator_To_Geodetic()

long ossimMercatorProjection::Convert_Mercator_To_Geodetic ( double  Easting,
double  Northing,
double *  Latitude,
double *  Longitude 
) const
private

The function Convert_Mercator_To_Geodetic converts Mercator projection easting and northing coordinates to geodetic (latitude and longitude) coordinates, according to the current ellipsoid and Mercator projection coordinates. If any errors occur, the error code(s) are returned by the function, otherwise MERC_NO_ERROR is returned.

Easting : Easting (X) in meters (input) Northing : Northing (Y) in meters (input) Latitude : Latitude (phi) in radians (output) Longitude : Longitude (lambda) in radians (output)

Definition at line 430 of file ossimMercatorProjection.cpp.

References M_PI, Merc_a, Merc_ab, Merc_bb, Merc_cb, Merc_db, Merc_False_Easting, Merc_False_Northing, MERC_NO_ERROR, Merc_Origin_Long, Merc_Scale_Factor, PI, and theSphericalFlag.

Referenced by inverse().

434 { /* BEGIN Convert_Mercator_To_Geodetic */
435 /*
436  * The function Convert_Mercator_To_Geodetic converts Mercator projection
437  * (easting and northing) coordinates to geodetic (latitude and longitude)
438  * coordinates, according to the current ellipsoid and Mercator projection
439  * coordinates. If any errors occur, the error code(s) are returned by the
440  * function, otherwise MERC_NO_ERROR is returned.
441  *
442  * Easting : Easting (X) in meters (input)
443  * Northing : Northing (Y) in meters (input)
444  * Latitude : Latitude (phi) in radians (output)
445  * Longitude : Longitude (lambda) in radians (output)
446  */
447 
448  double dx; /* Delta easting - Difference in easting (easting-FE) */
449  double dy; /* Delta northing - Difference in northing (northing-FN) */
450  double xphi; /* Isometric latitude */
451  long Error_Code = MERC_NO_ERROR;
452 
453 #if 0
454  if(theSphericalFlag)
455  {
456  *Latitude = M_PI*.5 - 2.0 * atan(exp(-Easting / Merc_a));
457  *Longitude = Easting/Merc_a;
458 
459  return Error_Code;
460  }
461 #endif
462 // if ((Easting < (Merc_False_Easting - Merc_Delta_Easting))
463 // || (Easting > (Merc_False_Easting + Merc_Delta_Easting)))
464 // { /* Easting out of range */
465 // Error_Code |= MERC_EASTING_ERROR;
466 // }
467 // if ((Northing < (Merc_False_Northing - Merc_Delta_Northing))
468 // || (Northing > (Merc_False_Northing + Merc_Delta_Northing)))
469 // { /* Northing out of range */
470 // Error_Code |= MERC_NORTHING_ERROR;
471 // }
472  if (!Error_Code)
473  { /* no errors */
474  dy = Northing - Merc_False_Northing;
475  dx = Easting - Merc_False_Easting;
476  *Longitude = Merc_Origin_Long + dx / (Merc_Scale_Factor * Merc_a);
477  xphi = PI / 2.e0
478  - 2.e0 * atan(1.e0 / exp(dy / (Merc_Scale_Factor * Merc_a)));
479  *Latitude = xphi + Merc_ab * sin(2.e0 * xphi) + Merc_bb * sin(4.e0 * xphi)
480  + Merc_cb * sin(6.e0 * xphi) + Merc_db * sin(8.e0 * xphi);
481 // if (*Longitude > PI)
482 // *Longitude -= (2 * PI);
483 // if (*Longitude < -PI)
484 // *Longitude += (2 * PI);
485  }
486  return (Error_Code);
487 } /* END OF Convert_Mercator_To_Geodetic */
#define MERC_NO_ERROR
#define M_PI
#define PI

◆ dup()

virtual ossimObject* ossimMercatorProjection::dup ( ) const
inlinevirtual

Implements ossimProjection.

Definition at line 31 of file ossimMercatorProjection.h.

31 {return new ossimMercatorProjection(*this);}
ossimMercatorProjection(const ossimEllipsoid &ellipsoid=ossimEllipsoid(), const ossimGpt &origin=ossimGpt())

◆ forward()

ossimDpt ossimMercatorProjection::forward ( const ossimGpt worldPoint) const
virtual

All map projections will convert the world coordinate to an easting northing (Meters).

Implements ossimMapProjection.

Definition at line 154 of file ossimMercatorProjection.cpp.

References ossimGpt::changeDatum(), ossimDatum::code(), Convert_Geodetic_To_Mercator(), ossimGpt::datum(), ossimGpt::latd(), ossimGpt::latr(), ossimGpt::lond(), ossimGpt::lonr(), M_PI, ossimDpt::makeNan(), Merc_a, MERC_NO_ERROR, ossimMapProjection::theDatum, and theSphericalFlag.

155 {
156  double easting = 0.0;
157  double northing = 0.0;
158  ossimGpt gpt = latLon;
159  ossimDpt result;
160  if (theDatum)
161  {
162  if (theDatum->code() != latLon.datum()->code())
163  {
164  gpt.changeDatum(theDatum); // Shift to our datum.
165  }
166  }
167  if(theSphericalFlag)
168  {
169  double lat = latLon.latd();
170  double lon = latLon.lond();
171  double shift = M_PI * Merc_a;
172  easting = lon * shift / 180.0;
173  northing = log( tan((90 + lat) * M_PI / 360.0 )) / (M_PI / 180.0);
174 
175  northing = northing * shift / 180.0;
176  result = ossimDpt(easting, northing);
177  }
178  else
179  {
180  long errorCode = Convert_Geodetic_To_Mercator(gpt.latr(),
181  gpt.lonr(),
182  &easting,
183  &northing);
184  if(errorCode!=MERC_NO_ERROR)
185  {
186  result.makeNan();
187  }
188  else
189  {
190  result = ossimDpt(easting, northing);
191  }
192  }
193 
194 
195  return result;
196 }
virtual const ossimString & code() const
Definition: ossimDatum.h:57
#define MERC_NO_ERROR
void changeDatum(const ossimDatum *datum)
This will actually perform a shift.
Definition: ossimGpt.cpp:316
#define M_PI
long Convert_Geodetic_To_Mercator(double Latitude, double Longitude, double *Easting, double *Northing) const
double lonr() const
Returns the longitude in radian measure.
Definition: ossimGpt.h:76
double latr() const
latr().
Definition: ossimGpt.h:66
void makeNan()
Definition: ossimDpt.h:65
const ossimDatum * theDatum
This is only set if we want to have built in datum shifting.

◆ Get_Mercator_Parameters()

void ossimMercatorProjection::Get_Mercator_Parameters ( double *  a,
double *  f,
double *  Origin_Latitude,
double *  Central_Meridian,
double *  False_Easting,
double *  False_Northing,
double *  Scale_Factor 
) const
private

The function Get_Mercator_Parameters returns the current ellipsoid parameters, Mercator projection parameters, and scale factor.

a : Semi-major axis of ellipsoid, in meters (output) f : Flattening of ellipsoid (output) Origin_Latitude : Latitude in radians at which the (output) point scale factor is 1.0 Central_Meridian : Longitude in radians at the center of (output) the projection False_Easting : A coordinate value in meters assigned to the central meridian of the projection. (output) False_Northing : A coordinate value in meters assigned to the origin latitude of the projection (output) Scale_Factor : Multiplier which reduces distances in the projection to the actual distance on the ellipsoid (output)

Definition at line 334 of file ossimMercatorProjection.cpp.

References Merc_a, Merc_f, Merc_False_Easting, Merc_False_Northing, Merc_Origin_Lat, Merc_Origin_Long, and Merc_Scale_Factor.

341 { /* BEGIN Get_Mercator_Parameters */
342 /*
343  * The function Get_Mercator_Parameters returns the current ellipsoid
344  * parameters, Mercator projection parameters, and scale factor.
345  *
346  * a : Semi-major axis of ellipsoid, in meters (output)
347  * f : Flattening of ellipsoid (output)
348  * Origin_Latitude : Latitude in radians at which the (output)
349  * point scale factor is 1.0
350  * Central_Meridian : Longitude in radians at the center of (output)
351  * the projection
352  * False_Easting : A coordinate value in meters assigned to the
353  * central meridian of the projection. (output)
354  * False_Northing : A coordinate value in meters assigned to the
355  * origin latitude of the projection (output)
356  * Scale_Factor : Multiplier which reduces distances in the
357  * projection to the actual distance on the
358  * ellipsoid (output)
359  */
360 
361  *a = Merc_a;
362  *f = Merc_f;
363  *Origin_Latitude = Merc_Origin_Lat;
364  *Central_Meridian = Merc_Origin_Long;
365  *False_Easting = Merc_False_Easting;
366  *False_Northing = Merc_False_Northing;
367  *Scale_Factor = Merc_Scale_Factor;
368 
369  return;
370 } /* END OF Get_Mercator_Parameters */

◆ getFalseEasting()

double ossimMercatorProjection::getFalseEasting ( ) const
inlinevirtual
Returns
The false easting.

Reimplemented from ossimMapProjection.

Definition at line 70 of file ossimMercatorProjection.h.

◆ getFalseNorthing()

double ossimMercatorProjection::getFalseNorthing ( ) const
inlinevirtual
Returns
The false northing.

Reimplemented from ossimMapProjection.

Definition at line 71 of file ossimMercatorProjection.h.

◆ getScaleFactor()

double ossimMercatorProjection::getScaleFactor ( ) const
inline

Definition at line 72 of file ossimMercatorProjection.h.

◆ inverse()

ossimGpt ossimMercatorProjection::inverse ( const ossimDpt projectedPoint) const
virtual

Will take a point in meters and convert it to ground.

Implements ossimMapProjection.

Definition at line 126 of file ossimMercatorProjection.cpp.

References Convert_Mercator_To_Geodetic(), M_PI, ossim::radiansToDegrees(), ossimMapProjection::theDatum, theSphericalFlag, ossimDpt::x, and ossimDpt::y.

127 {
128  double lat = 0.0;
129  double lon = 0.0;
130 
131  if(theSphericalFlag)
132  {
133  double shift = M_PI * 6378137.0;
134  lon = (eastingNorthing.x / shift) * 180.0;
135  lat = (eastingNorthing.y / shift) * 180.0;
136 
137  lat = 180 / M_PI * (2 * atan( exp( lat * M_PI / 180.0)) - M_PI / 2.0);
138  }
139  else
140  {
141  Convert_Mercator_To_Geodetic(eastingNorthing.x,
142  eastingNorthing.y,
143  &lat,
144  &lon);
145  lat = ossim::radiansToDegrees(lat);
146  lon = ossim::radiansToDegrees(lon);
147  }
148 
149 
150 
151  return ossimGpt(lat, lon, 0.0, theDatum);
152 }
double radiansToDegrees(double x)
Definition: ossimCommon.h:257
#define M_PI
long Convert_Mercator_To_Geodetic(double Easting, double Northing, double *Latitude, double *Longitude) const
const ossimDatum * theDatum
This is only set if we want to have built in datum shifting.

◆ loadState()

bool ossimMercatorProjection::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of an object from a keyword list. Return true if ok or false on error.

Reimplemented from ossimMapProjection.

Definition at line 209 of file ossimMercatorProjection.cpp.

References ossimKeywordlist::find(), ossimMapProjection::loadState(), Merc_False_Easting, Merc_False_Northing, Merc_Scale_Factor, ossimKeywordNames::SCALE_FACTOR_KW, setDefaults(), STATIC_TYPE_NAME, ossimMapProjection::theFalseEastingNorthing, ossimString::toDouble(), ossimKeywordNames::TYPE_KW, update(), ossimDpt::x, and ossimDpt::y.

211 {
212  bool flag = ossimMapProjection::loadState(kwl, prefix);
213 
214  const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
215  const char* scaleFactor = kwl.find(prefix, ossimKeywordNames::SCALE_FACTOR_KW);
216 
217  setDefaults();
218 
220  {
223 
224  if(scaleFactor)
225  {
226  Merc_Scale_Factor = ossimString(scaleFactor).toDouble();
227  }
228  }
229  update();
230 
231  return flag;
232 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
const char * find(const char *key) const
double y
Definition: ossimDpt.h:165
static const char * TYPE_KW
#define STATIC_TYPE_NAME(T)
Definition: ossimRtti.h:325
double toDouble() const
double x
Definition: ossimDpt.h:164
static const char * SCALE_FACTOR_KW
ossimDpt theFalseEastingNorthing
Hold the false easting northing.

◆ operator==()

bool ossimMercatorProjection::operator== ( const ossimProjection projection) const
virtual

Returns TRUE if principal parameters are within epsilon tolerance.

Reimplemented from ossimMapProjection.

Definition at line 492 of file ossimMercatorProjection.cpp.

References ossim::almostEqual(), and Merc_Scale_Factor.

493 {
494  if (!ossimMapProjection::operator==(proj))
495  return false;
496 
497  const ossimMercatorProjection* p = dynamic_cast<const ossimMercatorProjection*>(&proj);
498  if (!p) return false;
499 
501 
502  return true;
503 }
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
Definition: ossimCommon.h:53

◆ saveState()

bool ossimMercatorProjection::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Method to save the state of an object to a keyword list. Return true if ok or false on error.

Reimplemented from ossimMapProjection.

Definition at line 199 of file ossimMercatorProjection.cpp.

References ossimKeywordlist::add(), Merc_Scale_Factor, ossimMapProjection::saveState(), and ossimKeywordNames::SCALE_FACTOR_KW.

200 {
201  kwl.add(prefix,
204  true);
205 
206  return ossimMapProjection::saveState(kwl, prefix);
207 }
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
static const char * SCALE_FACTOR_KW

◆ Set_Mercator_Parameters()

long ossimMercatorProjection::Set_Mercator_Parameters ( double  a,
double  f,
double  Origin_Latitude,
double  Central_Meridian,
double  False_Easting,
double  False_Northing,
double *  Scale_Factor 
)
private

The function Set_Mercator_Parameters receives the ellipsoid parameters and Mercator projcetion parameters as inputs, and sets the corresponding state variables. It calculates and returns the scale factor. If any errors occur, the error code(s) are returned by the function, otherwise MERC_NO_ERROR is returned.

a : Semi-major axis of ellipsoid, in meters (input) f : Flattening of ellipsoid (input) Origin_Latitude : Latitude in radians at which the (input) point scale factor is 1.0 Central_Meridian : Longitude in radians at the center of (input) the projection False_Easting : A coordinate value in meters assigned to the central meridian of the projection. (input) False_Northing : A coordinate value in meters assigned to the origin latitude of the projection (input) Scale_Factor : Multiplier which reduces distances in the projection to the actual distance on the ellipsoid (output)

Definition at line 241 of file ossimMercatorProjection.cpp.

References ossim::almostEqual(), Convert_Geodetic_To_Mercator(), MAX_LAT, Merc_a, Merc_ab, Merc_bb, Merc_cb, Merc_db, Merc_Delta_Easting, Merc_Delta_Northing, Merc_e, Merc_es, Merc_f, Merc_False_Easting, Merc_False_Northing, MERC_NO_ERROR, Merc_Origin_Lat, Merc_Origin_Long, Merc_Scale_Factor, PI, and theSphericalFlag.

Referenced by update().

248 { /* BEGIN Set_Mercator_Parameters */
249 /*
250  * The function Set_Mercator_Parameters receives the ellipsoid parameters and
251  * Mercator projection parameters as inputs, and sets the corresponding state
252  * variables. It calculates and returns the scale factor. If any errors
253  * occur, the error code(s) are returned by the function, otherwise Merc_NO_ERROR
254  * is returned.
255  *
256  * a : Semi-major axis of ellipsoid, in meters (input)
257  * f : Flattening of ellipsoid (input)
258  * Origin_Latitude : Latitude in radians at which the (input)
259  * point scale factor is 1.0
260  * Central_Meridian : Longitude in radians at the center of (input)
261  * the projection
262  * False_Easting : A coordinate value in meters assigned to the
263  * central meridian of the projection. (input)
264  * False_Northing : A coordinate value in meters assigned to the
265  * origin latitude of the projection (input)
266  * Scale_Factor : Multiplier which reduces distances in the
267  * projection to the actual distance on the
268  * ellipsoid (output)
269  */
270 
271  double es2; /* Eccentricity squared of ellipsoid to the second power */
272  double es3; /* Eccentricity squared of ellipsoid to the third power */
273  double es4; /* Eccentricity squared of ellipsoid to the fourth power */
274  double sin_olat; /* sin(Origin_Latitude), temp variable */
275 // double inv_f = 1 / f;
276  long Error_Code = MERC_NO_ERROR;
277 
279 
280 // if (a <= 0.0)
281 // { /* Semi-major axis must be greater than zero */
282 // Error_Code |= MERC_A_ERROR;
283 // }
284 // if ((inv_f < 250) || (inv_f > 350))
285 // { /* Inverse flattening must be between 250 and 350 */
286 // Error_Code |= MERC_INV_F_ERROR;
287 // }
288 // if ((Origin_Latitude < -MAX_LAT) || (Origin_Latitude > MAX_LAT))
289 // { /* origin latitude out of range */
290 // Error_Code |= MERC_ORIGIN_LAT_ERROR;
291 // }
292 // if ((Central_Meridian < -PI) || (Central_Meridian > (2*PI)))
293 // { /* origin longitude out of range */
294 // Error_Code |= MERC_CENT_MER_ERROR;
295 // }
296  if (!Error_Code)
297  { /* no errors */
298  Merc_a = a;
299  Merc_f = f;
300  Merc_Origin_Lat = Origin_Latitude;
301 // if (Central_Meridian > PI)
302 // Central_Meridian -= (2*PI);
303  Merc_Origin_Long = Central_Meridian;
304  Merc_False_Northing = False_Northing;
305  Merc_False_Easting = False_Easting;
306  Merc_es = 2 * Merc_f - Merc_f * Merc_f;
307  Merc_e = sqrt(Merc_es);
308  sin_olat = sin(Origin_Latitude);
309  Merc_Scale_Factor = 1.0 / ( sqrt(1.e0 - Merc_es * sin_olat * sin_olat)
310  / cos(Origin_Latitude) );
311  es2 = Merc_es * Merc_es;
312  es3 = es2 * Merc_es;
313  es4 = es3 * Merc_es;
314  Merc_ab = Merc_es / 2.e0 + 5.e0 * es2 / 24.e0 + es3 / 12.e0
315  + 13.e0 * es4 / 360.e0;
316  Merc_bb = 7.e0 * es2 / 48.e0 + 29.e0 * es3 / 240.e0
317  + 811.e0 * es4 / 11520.e0;
318  Merc_cb = 7.e0 * es3 / 120.e0 + 81.e0 * es4 / 1120.e0;
319  Merc_db = 4279.e0 * es4 / 161280.e0;
320  *Scale_Factor = Merc_Scale_Factor;
323  if (Merc_Delta_Easting < 0)
325  Merc_Delta_Easting *= 1.01;
327  Merc_Delta_Northing *= 1.01;
329  } /* END OF if(!Error_Code) */
330  return (Error_Code);
331 } /* END OF Set_Mercator_Parameters */
#define MAX_LAT
bool almostEqual(T x, T y, T tolerance=FLT_EPSILON)
Definition: ossimCommon.h:53
#define MERC_NO_ERROR
long Convert_Geodetic_To_Mercator(double Latitude, double Longitude, double *Easting, double *Northing) const
#define PI

◆ setDefaults()

void ossimMercatorProjection::setDefaults ( )

◆ setFalseEasting()

void ossimMercatorProjection::setFalseEasting ( double  falseEasting)

SetFalseEasting. The value is in meters. Update is then called so we can pre-compute paramters

Definition at line 80 of file ossimMercatorProjection.cpp.

References Merc_False_Easting, and update().

81 {
82  Merc_False_Easting = falseEasting;
83  update();
84 }

◆ setFalseEastingNorthing()

void ossimMercatorProjection::setFalseEastingNorthing ( double  falseEasting,
double  falseNorthing 
)

Sets both false easting and northing values. The values are expected to be in meters. Update is then called so we can pre-compute paramters

Definition at line 98 of file ossimMercatorProjection.cpp.

References Merc_False_Easting, Merc_False_Northing, and update().

100 {
101  Merc_False_Easting = falseEasting;
102  Merc_False_Northing = falseNorthing;
103  update();
104 }

◆ setFalseNorthing()

void ossimMercatorProjection::setFalseNorthing ( double  falseNorthing)

SetFalseNorthing. The value is in meters. Update is then called so we can pre-compute paramters

Definition at line 86 of file ossimMercatorProjection.cpp.

References Merc_False_Northing, and update().

87 {
88  Merc_False_Northing = falseNorthing;
89  update();
90 }

◆ setParameters()

void ossimMercatorProjection::setParameters ( double  falseEasting,
double  falseNorthing,
double  scaleFactor 
)

Allows one to set all parameters for this projections. parallels are in degrees and easting northings are in meters. Update is then called so we can pre-compute paramters.

Definition at line 106 of file ossimMercatorProjection.cpp.

References Merc_False_Easting, Merc_False_Northing, Merc_Scale_Factor, and update().

109 {
110  Merc_False_Easting = falseEasting;
111  Merc_False_Northing = falseNorthing;
112  Merc_Scale_Factor = scaleFactor;
113 
114  update();
115 }

◆ setScaleFactor()

void ossimMercatorProjection::setScaleFactor ( double  scaleFactor)

sets the scale.

Definition at line 92 of file ossimMercatorProjection.cpp.

References Merc_Scale_Factor, and update().

Referenced by ossimWktProjectionFactory::doMercator().

93 {
94  Merc_Scale_Factor = scaleFactor;
95  update();
96 }

◆ update()

void ossimMercatorProjection::update ( )
virtual

Reimplemented from ossimMapProjection.

Definition at line 63 of file ossimMercatorProjection.cpp.

References ossimEllipsoid::getA(), ossimEllipsoid::getFlattening(), ossimGpt::latr(), ossimGpt::lonr(), Merc_False_Easting, Merc_False_Northing, Merc_Scale_Factor, Set_Mercator_Parameters(), ossimMapProjection::theEllipsoid, ossimMapProjection::theFalseEastingNorthing, ossimMapProjection::theOrigin, ossimMapProjection::update(), ossimDpt::x, and ossimDpt::y.

Referenced by loadState(), ossimMercatorProjection(), setFalseEasting(), setFalseEastingNorthing(), setFalseNorthing(), setParameters(), and setScaleFactor().

64 {
65 
68  theOrigin.latr(),
69  theOrigin.lonr(),
73 
76 
78 }
double y
Definition: ossimDpt.h:165
long Set_Mercator_Parameters(double a, double f, double Origin_Latitude, double Central_Meridian, double False_Easting, double False_Northing, double *Scale_Factor)
const double & getA() const
double lonr() const
Returns the longitude in radian measure.
Definition: ossimGpt.h:76
double x
Definition: ossimDpt.h:164
double latr() const
latr().
Definition: ossimGpt.h:66
const double & getFlattening() const
ossimEllipsoid theEllipsoid
This method verifies that the projection parameters match the current pcs code.
ossimDpt theFalseEastingNorthing
Hold the false easting northing.

Member Data Documentation

◆ Merc_a

double ossimMercatorProjection::Merc_a
mutableprivate

◆ Merc_ab

double ossimMercatorProjection::Merc_ab
mutableprivate

◆ Merc_bb

double ossimMercatorProjection::Merc_bb
mutableprivate

◆ Merc_cb

double ossimMercatorProjection::Merc_cb
mutableprivate

◆ Merc_db

double ossimMercatorProjection::Merc_db
mutableprivate

◆ Merc_Delta_Easting

double ossimMercatorProjection::Merc_Delta_Easting
mutableprivate

Definition at line 114 of file ossimMercatorProjection.h.

Referenced by Set_Mercator_Parameters(), and setDefaults().

◆ Merc_Delta_Northing

double ossimMercatorProjection::Merc_Delta_Northing
mutableprivate

Definition at line 115 of file ossimMercatorProjection.h.

Referenced by Set_Mercator_Parameters(), and setDefaults().

◆ Merc_e

double ossimMercatorProjection::Merc_e
mutableprivate

◆ Merc_es

double ossimMercatorProjection::Merc_es
mutableprivate

Definition at line 97 of file ossimMercatorProjection.h.

Referenced by Set_Mercator_Parameters().

◆ Merc_f

double ossimMercatorProjection::Merc_f
mutableprivate

Definition at line 95 of file ossimMercatorProjection.h.

Referenced by Get_Mercator_Parameters(), and Set_Mercator_Parameters().

◆ Merc_False_Easting

double ossimMercatorProjection::Merc_False_Easting
mutableprivate

◆ Merc_False_Northing

double ossimMercatorProjection::Merc_False_Northing
mutableprivate

◆ Merc_Origin_Lat

double ossimMercatorProjection::Merc_Origin_Lat
mutableprivate

Definition at line 100 of file ossimMercatorProjection.h.

Referenced by Get_Mercator_Parameters(), and Set_Mercator_Parameters().

◆ Merc_Origin_Long

double ossimMercatorProjection::Merc_Origin_Long
mutableprivate

◆ Merc_Scale_Factor

double ossimMercatorProjection::Merc_Scale_Factor
mutableprivate

◆ theSphericalFlag

bool ossimMercatorProjection::theSphericalFlag
private

The documentation for this class was generated from the following files: