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

#include <ossimBngProjection.h>

Inheritance diagram for ossimBngProjection:
ossimMapProjection ossimProjection ossimObject ossimErrorStatusInterface ossimReferenced

Public Member Functions

 ossimBngProjection ()
 
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 ()
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
- 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 getFalseEasting () const
 
virtual double getFalseNorthing () 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 bool operator== (const ossimProjection &projection) const
 Compares this to arg projection and returns TRUE if the same. 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
 

Protected Member Functions

long Find_Index (char letter, const char *letter_Array, long *index) const
 
long Round_BNG (double value) const
 
long Make_BNG_String (char ltrnum[4], long Easting, long Northing, char *BNG, long Precision) const
 
long Break_BNG_String (char *BNG, char Letters[3], double *Easting, double *Northing, long *Precision) const
 
long Check_Out_Of_Area (char BNG500, char BNG100) const
 
long Set_BNG_Parameters (char *Ellipsoid_Code)
 
void Get_BNG_Parameters (char *Ellipsoid_Code)
 
long Convert_Geodetic_To_BNG (double Latitude, double Longitude, long Precision, char *BNG) const
 
long Convert_BNG_To_Geodetic (char *BNG, double *Latitude, double *Longitude) const
 
long Convert_Transverse_Mercator_To_BNG (double Easting, double Northing, long Precision, char *BNG) const
 
long Convert_BNG_To_Transverse_Mercator (char *BNG, double *Easting, double *Northing) const
 
- Protected Member Functions inherited from ossimMapProjection
virtual ~ossimMapProjection ()
 
void updateFromTransform ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

double BNG_a
 
double BNG_f
 
double BNG_Origin_Lat
 
double BNG_Origin_Long
 
double BNG_False_Northing
 
double BNG_False_Easting
 
double BNG_Scale_Factor
 
long string_Broken
 
- 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 11 of file ossimBngProjection.h.

Constructor & Destructor Documentation

◆ ossimBngProjection()

ossimBngProjection::ossimBngProjection ( )

Definition at line 49 of file ossimBngProjection.cpp.

References ossimDatumFactory::create(), ossimDatumFactory::instance(), string_Broken, ossimMapProjection::theDatum, and update().

51  ossimGpt(49.0, -2.0, ossim::nan(),
52  ossimDatumFactory::instance()->create(ossimString("OGB-M"))))
53 {
54  string_Broken = 0;
56  update();
57 }
virtual const ossimDatum * create(const ossimString &code) const
create method
static ossimEllipsoidFactory * instance()
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
ossimMapProjection(const ossimEllipsoid &ellipsoid=ossimEllipsoid(), const ossimGpt &origin=ossimGpt())
static ossimDatumFactory * instance()
const ossimDatum * theDatum
This is only set if we want to have built in datum shifting.

Member Function Documentation

◆ Break_BNG_String()

long ossimBngProjection::Break_BNG_String ( char *  BNG,
char  Letters[3],
double *  Easting,
double *  Northing,
long *  Precision 
) const
protected

Definition at line 259 of file ossimBngProjection.cpp.

References BNG_NO_ERROR, BNG_STRING_ERROR, and n.

Referenced by Convert_BNG_To_Geodetic(), and Convert_BNG_To_Transverse_Mercator().

265 { /* Break_BNG_String */
266  long i = 0;
267  long j;
268  long num_digits = 0;
269  long num_letters;
270  long temp_error = 0;
271  long length = (long)strlen(BNG);
272  long error_code = BNG_NO_ERROR;
273 
274  string_Broken = 1;
275  while (BNG[i] == ' ')
276  i++; /* skip any leading blanks */
277  j = i;
278  while (isalpha(BNG[i]))
279  i++;
280  num_letters = i - j;
281  if (num_letters == 2)
282  {
283  /* get letters */
284  Letters[0] = (char)toupper(BNG[j]);
285  Letters[1] = (char)toupper(BNG[j+1]);
286  Letters[2] = 0;
287  }
288  else
289  error_code |= BNG_STRING_ERROR;
290  if (!error_code)
291  {
292  error_code |= Check_Out_Of_Area(Letters[0], Letters[1]);
293  while (BNG[i] == ' ')
294  i++;
295  j = i;
296  if (BNG[length-1] == ' ')
297  length --;
298  while ((i < length) && (!temp_error))
299  {
300  if (isdigit(BNG[i]))
301  i++;
302  else
303  {
304  temp_error = BNG_STRING_ERROR;
305  }
306  }
307  if (temp_error)
308  error_code |= temp_error;
309  if (!error_code)
310  {
311  num_digits = i - j;
312  if ((num_digits <= 10) && (num_digits%2 == 0))
313  {
314  long n;
315  char east_string[6];
316  char north_string[6];
317  long east;
318  long north;
319  double multiplier;
320 
321  /* get easting & northing */
322  n = num_digits / 2;
323  *Precision = n;
324  if (n > 0)
325  {
326  strncpy (east_string, BNG+j, n);
327  east_string[n] = 0;
328  sscanf (east_string, "%ld", &east);
329  strncpy (north_string, BNG+j+n, n);
330  north_string[n] = 0;
331  sscanf (north_string, "%ld", &north);
332  multiplier = pow ((double)10.0,(double)( 5 - n));
333  *Easting = east * multiplier;
334  *Northing = north * multiplier;
335  }
336  else
337  {
338  *Easting = 0.0;
339  *Northing = 0.0;
340  }
341  }
342  else
343  error_code |= BNG_STRING_ERROR;
344  }
345  }
346  return (error_code);
347 } /* Break_BNG_String */
long Check_Out_Of_Area(char BNG500, char BNG100) const
#define BNG_NO_ERROR
os2<< "> n<< " > nendobj n
#define BNG_STRING_ERROR

◆ Check_Out_Of_Area()

long ossimBngProjection::Check_Out_Of_Area ( char  BNG500,
char  BNG100 
) const
protected

Definition at line 349 of file ossimBngProjection.cpp.

References BNG_INVALID_AREA_ERROR, and BNG_NO_ERROR.

352 { /* BEGIN Check_Out_Of_Area */
353 /*
354  * The function Check_Out_Of_Area checks if the 500,000 and
355  * 100,000 unit square identifications are within the valid area. If
356  * they are not, an error code is returned, otherwise BNG_NO_ERROR
357  * is returned.
358  *
359  * BNG500 : 500,000 square unit identification
360  * BNG100 : 100,000 square unit identification
361  */
362 
363  long Error_Code = BNG_NO_ERROR;
364 
365  switch (BNG500)
366  {
367  case 'S':
368  switch (BNG100)
369  {
370  case 'A':
371  case 'F':
372  case 'L':
373  Error_Code |= BNG_INVALID_AREA_ERROR;
374  break;
375  default:
376  break;
377  }
378  break;
379  case 'N':
380  switch (BNG100)
381  {
382  case 'V':
383  Error_Code |= BNG_INVALID_AREA_ERROR;
384  break;
385  default:
386  break;
387  }
388  break;
389 
390  case 'H':
391  if (BNG100 < 'L')
392  Error_Code |= BNG_INVALID_AREA_ERROR;
393  break;
394  case 'T':
395  switch (BNG100)
396  {
397  case 'D':
398  case 'E':
399  case 'J':
400  case 'K':
401  case 'O':
402  case 'P':
403  case 'T':
404  case 'U':
405  case 'X':
406  case 'Y':
407  case 'Z':
408  Error_Code |= BNG_INVALID_AREA_ERROR;
409  break;
410  default:
411  break;
412  }
413  break;
414  case 'O':
415  switch (BNG100)
416  {
417  case 'C':
418  case 'D':
419  case 'E':
420  case 'J':
421  case 'K':
422  case 'O':
423  case 'P':
424  case 'T':
425  case 'U':
426  case 'Y':
427  case 'Z':
428  Error_Code |= BNG_INVALID_AREA_ERROR;
429  break;
430  default:
431  break;
432  }
433  break;
434  case 'J':
435  switch (BNG100)
436  {
437  case 'L':
438  case 'M':
439  case 'Q':
440  case 'R':
441  case 'V':
442  case 'W':
443  Error_Code = BNG_NO_ERROR;
444  break;
445  default:
446  Error_Code |= BNG_INVALID_AREA_ERROR;
447  break;
448  }
449  break;
450  default:
451  Error_Code |= BNG_INVALID_AREA_ERROR;
452  break;
453  }
454  return Error_Code;
455 } /* END OF Check_Out_Of_Area */
#define BNG_INVALID_AREA_ERROR
#define BNG_NO_ERROR

◆ Convert_BNG_To_Geodetic()

long ossimBngProjection::Convert_BNG_To_Geodetic ( char *  BNG,
double *  Latitude,
double *  Longitude 
) const
protected

The function Convert_BNG_To_Geodetic converts a BNG coordinate string to geodetic (latitude and longitude) coordinates, according to the current ellipsoid parameters. If any errors occur, the error code(s) are returned by the function, otherwise BNG_NO_ERROR is returned.

BNG : British National Grid coordinate string (input) Latitude : Latitude, in radians (output) Longitude : Longitude, in radians (output)

Definition at line 553 of file ossimBngProjection.cpp.

References BNG_NO_ERROR, and Break_BNG_String().

Referenced by inverse().

557 { /* Convert_BNG_To_Geodetic */
558 /*
559  * The function Convert_BNG_To_Geodetic converts a BNG coordinate string
560  * to geodetic (latitude and longitude) coordinates, according to the current
561  * ellipsoid parameters. If any errors occur, the error code(s) are returned
562  * by the function, otherwise BNG_NO_ERROR is returned.
563  *
564  * BNG : British National Grid coordinate string (input)
565  * Latitude : Latitude, in radians (output)
566  * Longitude : Longitude, in radians (output)
567  *
568  */
569 
570  double TMEasting, TMNorthing;
571  long in_Precision;
572  long temp_Error = 0;
573  long Error_Code = BNG_NO_ERROR;
574 
575  Error_Code |= Break_BNG_String(BNG, BNG_Letters, &BNG_Easting, &BNG_Northing, &in_Precision);
576 
577  if(!Error_Code)
578  {
579  Error_Code |= Convert_BNG_To_Transverse_Mercator(BNG, &TMEasting, &TMNorthing);
580 
581  if ((TMEasting < BNG_Min_Easting) || (TMEasting > BNG_Max_Easting))
582  Error_Code |= BNG_INVALID_AREA_ERROR;
583  if ((TMNorthing < BNG_Min_Northing) || (TMNorthing > BNG_Max_Northing))
584  Error_Code |= BNG_INVALID_AREA_ERROR;
585 
586  if(!Error_Code)
587  {
588  temp_Error |= Convert_Transverse_Mercator_To_Geodetic(TMEasting, TMNorthing, Latitude, Longitude);
589 
590  if (temp_Error & TRANMERC_EASTING_ERROR)
591  Error_Code |= BNG_EASTING_ERROR;
592  if (temp_Error & TRANMERC_NORTHING_ERROR)
593  Error_Code |= BNG_NORTHING_ERROR;
594 
595  if ((*Latitude < MIN_LAT) || (*Latitude > MAX_LAT))
596  Error_Code|= BNG_INVALID_AREA_ERROR;
597  if ((*Longitude < MIN_LON) || (*Longitude > MAX_LON))
598  Error_Code|= BNG_INVALID_AREA_ERROR;
599  }
600  }
601  return Error_Code;
602 } /* END OF Convert_BNG_To_Geodetic */
long Convert_BNG_To_Transverse_Mercator(char *BNG, double *Easting, double *Northing) const
#define BNG_INVALID_AREA_ERROR
#define MAX_LAT
#define BNG_NO_ERROR
#define MAX_LON
#define BNG_EASTING_ERROR
long Break_BNG_String(char *BNG, char Letters[3], double *Easting, double *Northing, long *Precision) const
#define MIN_LAT
#define BNG_NORTHING_ERROR
#define TRANMERC_NORTHING_ERROR
Definition: ossimTranmerc.h:95
long Convert_Transverse_Mercator_To_Geodetic(double Easting, double Northing, double *Latitude, double *Longitude)
#define TRANMERC_EASTING_ERROR
Definition: ossimTranmerc.h:94
#define MIN_LON

◆ Convert_BNG_To_Transverse_Mercator()

long ossimBngProjection::Convert_BNG_To_Transverse_Mercator ( char *  BNG,
double *  Easting,
double *  Northing 
) const
protected

The function Convert_BNG_To_Transverse_Mercator converts a BNG coordinate string to Transverse Mercator projection (easting and northing) coordinates according to the current ellipsoid parameters. If any errors occur, the error code(s) are returned by the function, otherwise BNG_NO_ERROR is returned.

BNG : British National Grid coordinate string (input) Easting : Easting (X), in meters (output) Northing : Northing (Y), in meters (output)

Definition at line 693 of file ossimBngProjection.cpp.

References BNG_NO_ERROR, Break_BNG_String(), and string_Broken.

Referenced by forward().

697 { /* Convert_BNG_To_Transverse_Mercator */
698 /*
699  * The function Convert_BNG_To_Transverse_Mercator converts a BNG coordinate string
700  * to Transverse Mercator projection (easting and northing) coordinates
701  * according to the current ellipsoid parameters. If any errors occur,
702  * the error code(s) are returned by the function, otherwise BNG_NO_ERROR
703  * is returned.
704  *
705  * BNG : British National Grid coordinate string (input)
706  * Easting : Easting (X), in meters (output)
707  * Northing : Northing (Y), in meters (output)
708  */
709  long northing_Offset, easting_Offset;
710  long i = 0;
711  long j = 0;
712  long in_Precision;
713  long Error_Code = BNG_NO_ERROR;
714 
715  if (!string_Broken)
716  {
717  Error_Code |= Break_BNG_String(BNG, BNG_Letters, &BNG_Easting, &BNG_Northing, &in_Precision);
718  }
719  if (!Error_Code)
720  {
721  Error_Code |= Find_Index(BNG_Letters[0], BNG500GRID, &i);
722  if (!Error_Code)
723  {
724  northing_Offset = 500000 * (i / 2);
725  easting_Offset = 500000 * (i % 2);
726 
727  Error_Code |= Find_Index(BNG_Letters[1], BNG100GRID, &j);
728  if (!Error_Code)
729  {
730  northing_Offset += 100000 * (j / 5);
731  easting_Offset += 100000 * (j % 5);
732 
733  *Easting = BNG_Easting + easting_Offset;
734  *Northing = BNG_Northing + northing_Offset;
735  }
736  }
737  }
738  return Error_Code;
739 } /* END OF Convert_BNG_To_Transverse_Mercator */
#define BNG_NO_ERROR
#define BNG100GRID
long Break_BNG_String(char *BNG, char Letters[3], double *Easting, double *Northing, long *Precision) const
long Find_Index(char letter, const char *letter_Array, long *index) const
#define BNG500GRID

◆ Convert_Geodetic_To_BNG()

long ossimBngProjection::Convert_Geodetic_To_BNG ( double  Latitude,
double  Longitude,
long  Precision,
char *  BNG 
) const
protected

The function Convert_Geodetic_To_BNG converts geodetic (latitude and longitude) coordinates to a BNG coordinate string, according to the current ellipsoid parameters. If any errors occur, the error code(s)
are returned by the function, otherwise BNG_NO_ERROR is returned.

Latitude : Latitude, in radians (input) Longitude : Longitude, in radians (input) Precision : Precision level of BNG string (input) BNG : British National Grid coordinate string (output)

Definition at line 502 of file ossimBngProjection.cpp.

References BNG_LAT_ERROR, BNG_LON_ERROR, BNG_NO_ERROR, Convert_Geodetic_To_Transverse_Mercator(), MAX_LAT, MAX_LON, MIN_LAT, and MIN_LON.

Referenced by forward().

507 { /* BEGIN Convert_Geodetic_To_BNG */
508 /*
509  * The function Convert_Geodetic_To_BNG converts geodetic (latitude and
510  * longitude) coordinates to a BNG coordinate string, according to the
511  * current ellipsoid parameters. If any errors occur, the error code(s)
512  * are returned by the function, otherwise BNG_NO_ERROR is returned.
513  *
514  * Latitude : Latitude, in radians (input)
515  * Longitude : Longitude, in radians (input)
516  * Precision : Precision level of BNG string (input)
517  * BNG : British National Grid coordinate string (output)
518  *
519  */
520  double TMEasting, TMNorthing;
521  long Error_Code = BNG_NO_ERROR;
522 
523  if ((Latitude < MIN_LAT) || (Latitude > MAX_LAT))
524  { /* Latitude out of range */
525  Error_Code|= BNG_LAT_ERROR;
526  }
527  if ((Longitude < MIN_LON) || (Longitude > MAX_LON))
528  { /* Longitude out of range */
529  Error_Code|= BNG_LON_ERROR;
530  }
531 
532  if (!Error_Code)
533  { /* no errors */
534 
535  Error_Code |= Convert_Geodetic_To_Transverse_Mercator(Latitude, Longitude, &TMEasting, &TMNorthing);
536 
537  if ((TMEasting < 0.0) && (TMEasting > -2.0))
538  TMEasting = 0.0;
539  if ((TMNorthing < 0.0) && (TMNorthing > -2.0))
540  TMNorthing = 0.0;
541 
542  if ((TMEasting < BNG_Min_Easting) || (TMEasting > BNG_Max_Easting))
543  Error_Code |= BNG_INVALID_AREA_ERROR;
544  if ((TMNorthing < BNG_Min_Northing) || (TMNorthing > BNG_Max_Northing))
545  Error_Code |= BNG_INVALID_AREA_ERROR;
546 
547  if (!Error_Code)
548  Error_Code |= Convert_Transverse_Mercator_To_BNG(TMEasting, TMNorthing, Precision, BNG);
549  }
550  return Error_Code;
551 } /* END OF Convert_Geodetic_To_BNG */
#define BNG_INVALID_AREA_ERROR
#define MAX_LAT
#define BNG_LAT_ERROR
#define BNG_NO_ERROR
#define MAX_LON
#define MIN_LAT
long Convert_Transverse_Mercator_To_BNG(double Easting, double Northing, long Precision, char *BNG) const
#define MIN_LON
#define BNG_LON_ERROR
long Convert_Geodetic_To_Transverse_Mercator(double Latitude, double Longitude, double *Easting, double *Northing)

◆ Convert_Transverse_Mercator_To_BNG()

long ossimBngProjection::Convert_Transverse_Mercator_To_BNG ( double  Easting,
double  Northing,
long  Precision,
char *  BNG 
) const
protected

The function Convert_Transverse_Mercator_To_BNG converts Transverse Mercator (easting and northing) coordinates to a BNG coordinate string, according to the current ellipsoid parameters. If any errors occur, the error code(s) are returned by the function, otherwise BNG_NO_ERROR is returned.

Easting : Easting (X), in meters (input) Northing : Northing (Y), in meters (input) Precision : Precision level of BNG string (input) BNG : British National Grid coordinate string (output)

Definition at line 605 of file ossimBngProjection.cpp.

References BNG_NO_ERROR, x, and y.

Referenced by inverse().

610 {/* BEGIN Convert_Transverse_Mercator_To_BNG */
611 /*
612  * The function Convert_Transverse_Mercator_To_BNG converts Transverse Mercator
613  * (easting and northing) coordinates to a BNG coordinate string, according
614  * to the current ellipsoid parameters. If any errors occur, the error code(s)
615  * are returned by the function, otherwise BNG_NO_ERROR is returned.
616  *
617  * Easting : Easting (X), in meters (input)
618  * Northing : Northing (Y), in meters (input)
619  * Precision : Precision level of BNG string (input)
620  * BNG : British National Grid coordinate string (output)
621  */
622 
623  char letters[4];
624  long x, y;
625  long index;
626  long temp_Easting, temp_Northing;
627  long Error_Code = BNG_NO_ERROR;
628 
629  if ((Easting < BNG_Min_Easting) || (Easting > BNG_Max_Easting))
630  { /* Easting out of range */
631  Error_Code |= BNG_EASTING_ERROR;
632  }
633  if ((Northing < BNG_Min_Northing) || (Northing > BNG_Max_Northing))
634  { /* Northing out of range */
635  Error_Code |= BNG_NORTHING_ERROR;
636  }
637 
638  if (!Error_Code)
639  { /* no errors */
640  temp_Easting = Round_BNG(Easting);
641  temp_Northing = Round_BNG(Northing);
642 
643  temp_Easting += 1000000;
644  temp_Northing += 500000;
645 
646  x = temp_Easting / 500000;
647  y = temp_Northing / 500000;
648 
649  index = y * 5 + x;
650  if ((index >= 0) && (index < 25))
651  {
652  letters[0] = BNG100GRID[index];
653  temp_Easting %= 500000;
654  temp_Northing %= 500000;
655  x = temp_Easting / 100000;
656  y = temp_Northing / 100000;
657  index = y * 5 + x;
658  if ((index >= 0) && (index < 25))
659  {
660  letters[1] = BNG100GRID[index];
661  Error_Code |= Check_Out_Of_Area(letters[0], letters[1]);
662  if (!Error_Code)
663  {
664  letters[2] = ' ';
665  letters[3] = 0;
666  temp_Easting %= 100000;
667  temp_Northing %= 100000;
668  Make_BNG_String(letters, temp_Easting, temp_Northing, BNG, Precision);
669  }
670  }
671  else
672  {
673  long five_y = 5 * y;
674  if ((x >= (25 - five_y)) || (x < -five_y))
675  Error_Code |= BNG_EASTING_ERROR;
676  if ((five_y >= (25 - x)) || (five_y < -x))
677  Error_Code |= BNG_NORTHING_ERROR;
678  }
679  }
680  else
681  {
682  long five_y = 5 * y;
683  if ((x >= (25 - five_y)) || (x < -five_y))
684  Error_Code |= BNG_EASTING_ERROR;
685  if ((five_y >= (25 - x)) || (five_y < -x))
686  Error_Code |= BNG_NORTHING_ERROR;
687  }
688  }
689  return Error_Code;
690 } /* END OF Convert_Transverse_Mercator_To_BNG */
ossim_uint32 x
long Round_BNG(double value) const
long Check_Out_Of_Area(char BNG500, char BNG100) const
ossim_uint32 y
long Make_BNG_String(char ltrnum[4], long Easting, long Northing, char *BNG, long Precision) const
#define BNG_NO_ERROR
#define BNG_EASTING_ERROR
#define BNG100GRID
#define BNG_NORTHING_ERROR

◆ dup()

virtual ossimObject* ossimBngProjection::dup ( ) const
inlinevirtual

Implements ossimProjection.

Definition at line 16 of file ossimBngProjection.h.

17  {
18  return new ossimBngProjection(*this);
19  }

◆ Find_Index()

long ossimBngProjection::Find_Index ( char  letter,
const char *  letter_Array,
long *  index 
) const
protected

Definition at line 171 of file ossimBngProjection.cpp.

References BNG_NO_ERROR, and BNG_STRING_ERROR.

174 {
175 /*
176  * The function Find_Index searches for a given letter in an array.
177  * It returns the index of the letter in the array if the letter is found.
178  * If the letter is not found, an error code is returned, otherwise
179  * BNG_NO_ERROR is returned.
180  *
181  * letter : Letter being searched for
182  * letter_Array : Array being searched
183  * index : Index of letter in array
184  */
185  ossim_uint32 i = 0;
186  ossim_uint32 not_Found = 1;
187  ossim_uint32 length = (ossim_uint32)strlen(letter_Array);
188  ossim_uint32 Error_Code = BNG_NO_ERROR;
189 
190  while ((i < length) && (not_Found))
191  {
192  if (letter == letter_Array[i])
193  {
194  *index = i;
195  not_Found = 0;
196  }
197  i++;
198  }
199  if (not_Found)
200  Error_Code = BNG_STRING_ERROR;
201 
202  return Error_Code;
203 }
#define BNG_NO_ERROR
unsigned int ossim_uint32
#define BNG_STRING_ERROR

◆ forward()

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

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

Implements ossimMapProjection.

Definition at line 85 of file ossimBngProjection.cpp.

References BNG_a, BNG_f, BNG_False_Easting, BNG_False_Northing, BNG_Origin_Lat, BNG_Origin_Long, BNG_Scale_Factor, Convert_BNG_To_Transverse_Mercator(), Convert_Geodetic_To_BNG(), ossimGpt::latr(), ossimGpt::lonr(), Set_Transverse_Mercator_Parameters(), and string_Broken.

86 {
87  char BNG[100];
88 
89  string_Broken = 0;
93 
94  Convert_Geodetic_To_BNG (latLon.latr(),
95  latLon.lonr(),
96  5,
97  BNG);
98 
99  ossimDpt en;
100 
102  &en.x,
103  &en.y);
104 
105  return en;
106 }
long Set_Transverse_Mercator_Parameters(double a, double f, double Origin_Latitude, double Central_Meridian, double False_Easting, double False_Northing, double Scale_Factor)
long Convert_BNG_To_Transverse_Mercator(char *BNG, double *Easting, double *Northing) const
long Convert_Geodetic_To_BNG(double Latitude, double Longitude, long Precision, char *BNG) const

◆ Get_BNG_Parameters()

void ossimBngProjection::Get_BNG_Parameters ( char *  Ellipsoid_Code)
protected

Definition at line 487 of file ossimBngProjection.cpp.

489 { /* BEGIN Get_BNG_Parameters */
490 /*
491  * The function Get_BNG_Parameters returns the current ellipsoid
492  * code.
493  *
494  * Ellipsoid_Code : 2-letter code for ellipsoid (output)
495  */
496 
497  strcpy(Ellipsoid_Code, BNG_Ellipsoid_Code);
498 
499  return;
500 } /* END OF Get_BNG_Parameters */

◆ inverse()

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

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

Implements ossimMapProjection.

Definition at line 60 of file ossimBngProjection.cpp.

References BNG_a, BNG_f, BNG_False_Easting, BNG_False_Northing, BNG_Origin_Lat, BNG_Origin_Long, BNG_Scale_Factor, Convert_BNG_To_Geodetic(), Convert_Transverse_Mercator_To_BNG(), ossimGpt::latr(), ossimGpt::lonr(), ossim::nan(), Set_Transverse_Mercator_Parameters(), string_Broken, ossimMapProjection::theDatum, ossimDpt::x, and ossimDpt::y.

61 {
62  char s[100];
63  double lat;
64  double lon;
65 
66  string_Broken = 0;
70 
71  Convert_Transverse_Mercator_To_BNG(eastingNorthing.x,
72  eastingNorthing.y,
73  5,
74  s);
76  &lat,
77  &lon);
78  ossimGpt result(49, -2, ossim::nan(),theDatum);
79  result.latr(lat);
80  result.lonr(lon);
81 
82  return result;
83 }
long Set_Transverse_Mercator_Parameters(double a, double f, double Origin_Latitude, double Central_Meridian, double False_Easting, double False_Northing, double Scale_Factor)
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
long Convert_BNG_To_Geodetic(char *BNG, double *Latitude, double *Longitude) const
long Convert_Transverse_Mercator_To_BNG(double Easting, double Northing, long Precision, char *BNG) const
const ossimDatum * theDatum
This is only set if we want to have built in datum shifting.

◆ loadState()

bool ossimBngProjection::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 159 of file ossimBngProjection.cpp.

References ossimMapProjection::loadState(), and update().

161 {
162 
163  ossimMapProjection::loadState(kwl, prefix);
164 
165  update();
166 
167  return true;
168 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.

◆ Make_BNG_String()

long ossimBngProjection::Make_BNG_String ( char  ltrnum[4],
long  Easting,
long  Northing,
char *  BNG,
long  Precision 
) const
protected

Definition at line 218 of file ossimBngProjection.cpp.

References BNG_NO_ERROR, and Round_BNG().

224 { /* Make_BNG_String */
225 /* Construct a BNG string from its component parts */
226  double divisor;
227  long east;
228  long north;
229  long i;
230  long j;
231  double unitInterval;
232  long error_code = BNG_NO_ERROR;
233 
234  i = 0;
235  for (j = 0; j < 3; j++)
236  {
237  BNG[i++] = ltrnum[j];
238  }
239 
240  divisor = pow ((double)10.0,(double) (5 - Precision));
241  unitInterval = pow ((double)10.0, (double)Precision);
242  east = Round_BNG (Easting/divisor);
243  if (east == unitInterval)
244  east -= 1;
245  if ((Precision == 0) && (east == 1))
246  east = 0;
247  i += sprintf (BNG + i, "%*.*ld",(int) Precision,(int) Precision, east);
248 
249  north = Round_BNG (Northing/divisor);
250  if (north == unitInterval)
251  north -= 1;
252  if ((Precision == 0) && (north == 1))
253  north = 0;
254  i += sprintf (BNG + i, "%*.*ld",(int) Precision,(int) Precision, north);
255 
256  return (error_code);
257 } /* Make_BNG_String */
long Round_BNG(double value) const
#define BNG_NO_ERROR

◆ Round_BNG()

long ossimBngProjection::Round_BNG ( double  value) const
protected

Definition at line 205 of file ossimBngProjection.cpp.

Referenced by Make_BNG_String().

207 { /* Round_BNG */
208  double ivalue;
209  long ival;
210  double fraction = modf (value, &ivalue);
211  ival = (long)(ivalue);
212  if ((fraction > 0.5) || ((fraction == 0.5) && (ival%2 == 1)))
213  ival++;
214 
215  return (ival);
216 }

◆ saveState()

bool ossimBngProjection::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 139 of file ossimBngProjection.cpp.

References ossimKeywordlist::add(), BNG_Scale_Factor, ossimObject::getClassName(), ossimMapProjection::saveState(), ossimKeywordNames::SCALE_FACTOR_KW, and ossimKeywordNames::TYPE_KW.

141 {
142  kwl.add(prefix,
144  getClassName(),
145  true);
146 
147  kwl.add(prefix,
150  true);
151 
152  return ossimMapProjection::saveState(kwl, prefix);
153 }
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
static const char * TYPE_KW
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_BNG_Parameters()

long ossimBngProjection::Set_BNG_Parameters ( char *  Ellipsoid_Code)
protected

Definition at line 457 of file ossimBngProjection.cpp.

References BNG_NO_ERROR.

459 { /* BEGIN Set_BNG_Parameters */
460 /*
461  * The function Set_BNG_Parameters receives the ellipsoid code and sets
462  * the corresponding state variables. If any errors occur, the error code(s)
463  * are returned by the function, otherwise BNG_NO_ERROR is returned.
464  *
465  * Ellipsoid_Code : 2-letter code for ellipsoid (input)
466  */
467 
468  long Error_Code = BNG_NO_ERROR;
469 
470  if (strcmp(Ellipsoid_Code, Airy) != 0)
471  { /* Ellipsoid must be Airy */
472  Error_Code |= BNG_ELLIPSOID_ERROR;
473  }
474 
475  if (!Error_Code)
476  { /* no errors */
477  strcpy(BNG_Ellipsoid_Code, Ellipsoid_Code);
478  string_Broken = 0;
479 
483  }
484  return (Error_Code);
485 } /* END of Set_BNG_Parameters */
long Set_Transverse_Mercator_Parameters(double a, double f, double Origin_Latitude, double Central_Meridian, double False_Easting, double False_Northing, double Scale_Factor)
#define BNG_NO_ERROR
#define BNG_ELLIPSOID_ERROR

◆ update()

void ossimBngProjection::update ( )
virtual

Reimplemented from ossimMapProjection.

Definition at line 108 of file ossimBngProjection.cpp.

References BNG_a, BNG_f, BNG_False_Easting, BNG_False_Northing, BNG_Origin_Lat, BNG_Origin_Long, BNG_Scale_Factor, M_PI, ossim::nan(), ossimMapProjection::theDatum, ossimMapProjection::theFalseEastingNorthing, ossimMapProjection::theOrigin, ossimMapProjection::update(), ossimDpt::x, and ossimDpt::y.

Referenced by loadState(), and ossimBngProjection().

109 {
110  BNG_Origin_Lat = (49.0 * M_PI / 180.0);
111  BNG_Origin_Long = (-2.0 * M_PI / 180.0);
112  BNG_False_Northing = -100000.0;
113  BNG_False_Easting = 400000.0;
114  BNG_Scale_Factor = .9996012717;
115  BNG_a = 6377563.396;
116  BNG_f = 1 / 299.324964600;
117 
118  // ossimString code = theDatum->code();
119  // if(code.upcase().contains("OGB"))
120  // {
121 
122  theOrigin = ossimGpt(49.0, -2.0, ossim::nan(), theDatum);
125 
126  // }
127  // else
128 // {
129 // theOrigin = ossimGpt(49.0, -2.0, ossim::nan(), ossimDatumFactory::instance()->create("OGB-7"));
130 // }
131 
133 }
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
double y
Definition: ossimDpt.h:165
#define M_PI
double x
Definition: ossimDpt.h:164
ossimDpt theFalseEastingNorthing
Hold the false easting northing.
const ossimDatum * theDatum
This is only set if we want to have built in datum shifting.

Member Data Documentation

◆ BNG_a

double ossimBngProjection::BNG_a
protected

Definition at line 41 of file ossimBngProjection.h.

Referenced by forward(), inverse(), and update().

◆ BNG_f

double ossimBngProjection::BNG_f
protected

Definition at line 42 of file ossimBngProjection.h.

Referenced by forward(), inverse(), and update().

◆ BNG_False_Easting

double ossimBngProjection::BNG_False_Easting
protected

Definition at line 48 of file ossimBngProjection.h.

Referenced by forward(), inverse(), and update().

◆ BNG_False_Northing

double ossimBngProjection::BNG_False_Northing
protected

Definition at line 47 of file ossimBngProjection.h.

Referenced by forward(), inverse(), and update().

◆ BNG_Origin_Lat

double ossimBngProjection::BNG_Origin_Lat
protected

Definition at line 45 of file ossimBngProjection.h.

Referenced by forward(), inverse(), and update().

◆ BNG_Origin_Long

double ossimBngProjection::BNG_Origin_Long
protected

Definition at line 46 of file ossimBngProjection.h.

Referenced by forward(), inverse(), and update().

◆ BNG_Scale_Factor

double ossimBngProjection::BNG_Scale_Factor
protected

Definition at line 49 of file ossimBngProjection.h.

Referenced by forward(), inverse(), saveState(), and update().

◆ string_Broken

long ossimBngProjection::string_Broken
mutableprotected

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