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

#include <ossimGeoref.h>

Public Member Functions

 ossimGeoref (const ossimString &georefString, long precision)
 
 ossimGeoref (const ossimGpt &groundPt)
 
 ossimGeoref ()
 
ossimString toString (long precision)
 

Private Member Functions

long Convert_Geodetic_To_GEOREF (double Latitude, double Longitude, long Precision, char *georef)
 
long Convert_GEOREF_To_Geodetic (char *georef, double *Latitude, double *Longitude)
 

Private Attributes

ossimGpt thePt
 

Detailed Description

Definition at line 6 of file ossimGeoref.h.

Constructor & Destructor Documentation

◆ ossimGeoref() [1/3]

ossimGeoref::ossimGeoref ( const ossimString georefString,
long  precision 
)

Definition at line 25 of file ossimGeoref.cpp.

References ossimString::c_str(), Convert_GEOREF_To_Geodetic(), GEOREF_NO_ERROR, ossimGpt::latr(), ossimGpt::lonr(), and thePt.

27 {
28  double lat, lon;
29 
30  long result = Convert_GEOREF_To_Geodetic(const_cast<char*>(georefString.c_str()),
31  &lat,
32  &lon);
33  if(result == GEOREF_NO_ERROR)
34  {
35  thePt.latr(lat);
36  thePt.lonr(lon);
37  }
38 }
ossimGpt thePt
Definition: ossimGeoref.h:31
double lonr() const
Returns the longitude in radian measure.
Definition: ossimGpt.h:76
double latr() const
latr().
Definition: ossimGpt.h:66
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
#define GEOREF_NO_ERROR
Definition: ossimGeoref.cpp:14
long Convert_GEOREF_To_Geodetic(char *georef, double *Latitude, double *Longitude)

◆ ossimGeoref() [2/3]

ossimGeoref::ossimGeoref ( const ossimGpt groundPt)

Definition at line 40 of file ossimGeoref.cpp.

References thePt.

41 {
42  thePt = groundPt;
43 }
ossimGpt thePt
Definition: ossimGeoref.h:31

◆ ossimGeoref() [3/3]

ossimGeoref::ossimGeoref ( )

Definition at line 45 of file ossimGeoref.cpp.

46 {
47 }

Member Function Documentation

◆ Convert_Geodetic_To_GEOREF()

long ossimGeoref::Convert_Geodetic_To_GEOREF ( double  Latitude,
double  Longitude,
long  Precision,
char *  georef 
)
private

This function converts Geodetic (latitude and longitude in radians) coordinates to a GEOREF coordinate string. Precision specifies the number of digits in the GEOREF string for latitude and longitude: 0 for nearest degree 1 for nearest 10 minutes 2 for nearest minute 3 for nearest tenth of a minute 4 for nearest hundredth of a minute 5 for nearest thousandth of a minute

Latitude : Latitude in radians (input) Longitude : Longitude in radians (input) Precision : level of precision specified by the user (input) ossimGeoref : GEOREF coordinate string (output)

Definition at line 288 of file ossimGeoref.cpp.

References Convert_Minutes_To_String(), GEOREF_LAT_ERROR, GEOREF_LETTERS, GEOREF_LON_ERROR, GEOREF_NO_ERROR, GEOREF_PRECISION_ERROR, LATITUDE_HIGH, LATITUDE_LOW, LETTER_A_OFFSET, LETTER_I, LETTER_M, LETTER_O, LETTER_Q, LETTER_Z, LONGITUDE_HIGH, LONGITUDE_LOW, MAX_PRECISION, MIN_PER_DEG, QUAD, RADIAN_TO_DEGREE, and ROUND_ERROR.

Referenced by toString().

292 { /* BEGIN Convert_Geodetic_To_GEOREF */
293 /*
294  * This function converts Geodetic (latitude and longitude in radians)
295  * coordinates to a GEOREF coordinate string. Precision specifies the
296  * number of digits in the GEOREF string for latitude and longitude:
297  * 0 for nearest degree
298  * 1 for nearest ten minutes
299  * 2 for nearest minute
300  * 3 for nearest tenth of a minute
301  * 4 for nearest hundredth of a minute
302  * 5 for nearest thousandth of a minute
303  *
304  * latitude : Latitude in radians. (input)
305  * longitude : Longitude in radians. (input)
306  * precision : Precision specified by the user. (input)
307  * georef : GEOREF coordinate string. (output)
308  *
309  * CALLS THE FOLLOWING FUNCTIONS:
310  *
311  * Convert_Minutes_To_String
312  */
313 
314  double long_min; /* GEOREF longitude minute part */
315  double lat_min; /* GEOREF latitude minute part */
316  double origin_long; /* Origin longitude (-180 degrees)*/
317  double origin_lat; /* Origin latitude (-90 degrees) */
318  long letter_number[GEOREF_LETTERS + 1]; /* GEOREF letters */
319  char long_min_str[MAX_PRECISION + 1]; /* Longitude minute string */
320  char lat_min_str[MAX_PRECISION + 1]; /* Latitude minute string */
321  long i; /* counter in for loop */
322  long error_code = GEOREF_NO_ERROR;
323 
324  latitude = latitude * RADIAN_TO_DEGREE;
325  longitude = longitude * RADIAN_TO_DEGREE;
326  if ((latitude < (double)LATITUDE_LOW)
327  || (latitude > (double)LATITUDE_HIGH))
328  error_code |= GEOREF_LAT_ERROR;
329  if ((longitude < (double)LONGITUDE_LOW)
330  || (longitude > (double)LONGITUDE_HIGH))
331  error_code |= GEOREF_LON_ERROR;
332  if ((precision < 0) || (precision > MAX_PRECISION))
333  error_code |= GEOREF_PRECISION_ERROR;
334  if (!error_code)
335  {
336  if (longitude > 180)
337  longitude -= 360;
338  origin_long = (double)LONGITUDE_LOW;
339  origin_lat = (double)LATITUDE_LOW;
340  letter_number[0] = (long)((longitude-origin_long) / QUAD + ROUND_ERROR);
341  longitude = longitude - ((double)letter_number[0] * QUAD + origin_long);
342  letter_number[2] = (long)(longitude + ROUND_ERROR);
343  long_min = (longitude - (double)letter_number[2]) * (double)MIN_PER_DEG;
344  letter_number[1] = (long)((latitude - origin_lat) / QUAD + ROUND_ERROR);
345  latitude = latitude - ((double)letter_number[1] * QUAD + origin_lat);
346  letter_number[3] = (long)(latitude + ROUND_ERROR);
347  lat_min = (latitude - (double)letter_number[3]) * (double)MIN_PER_DEG;
348  for (i = 0;i < 4; i++)
349  {
350  if (letter_number[i] >= LETTER_I)
351  letter_number[i] += 1;
352  if (letter_number[i] >= LETTER_O)
353  letter_number[i] += 1;
354  }
355 
356  if (letter_number[0] == 26)
357  { /* longitude of 180 degrees */
358  letter_number[0] = LETTER_Z;
359  letter_number[2] = LETTER_Q;
360  long_min = 59.999;
361  }
362  if (letter_number[1] == 13)
363  { /* latitude of 90 degrees */
364  letter_number[1] = LETTER_M;
365  letter_number[3] = LETTER_Q;
366  lat_min = 59.999;
367  }
368 
369  for (i=0;i<4;i++)
370  georef[i] = (char)(letter_number[i] + LETTER_A_OFFSET);
371  georef[4] = 0;
372  Convert_Minutes_To_String(long_min,precision,long_min_str);
373  Convert_Minutes_To_String(lat_min,precision,lat_min_str);
374  strcat(georef,long_min_str);
375  strcat(georef,lat_min_str);
376  }
377  return (error_code);
378 } /* END OF Convert_Geodetic_To_GEOREF */
#define LONGITUDE_HIGH
Definition: ossimGeoref.cpp:75
#define GEOREF_LON_ERROR
Definition: ossimGeoref.cpp:16
#define LETTER_O
Definition: ossimGeoref.cpp:83
#define GEOREF_LETTERS
Definition: ossimGeoref.cpp:79
#define GEOREF_PRECISION_ERROR
Definition: ossimGeoref.cpp:22
#define LETTER_Z
Definition: ossimGeoref.cpp:85
#define LATITUDE_LOW
Definition: ossimGeoref.cpp:72
#define RADIAN_TO_DEGREE
Definition: ossimGeoref.cpp:90
#define LONGITUDE_LOW
Definition: ossimGeoref.cpp:74
#define LETTER_I
Definition: ossimGeoref.cpp:81
#define ROUND_ERROR
Definition: ossimGeoref.cpp:92
#define LATITUDE_HIGH
Definition: ossimGeoref.cpp:73
#define LETTER_A_OFFSET
Definition: ossimGeoref.cpp:86
void Convert_Minutes_To_String(double minutes, long precision, char *str)
#define QUAD
Definition: ossimGeoref.cpp:91
#define LETTER_Q
Definition: ossimGeoref.cpp:84
#define MAX_PRECISION
Definition: ossimGeoref.cpp:80
#define MIN_PER_DEG
Definition: ossimGeoref.cpp:76
#define LETTER_M
Definition: ossimGeoref.cpp:82
#define GEOREF_NO_ERROR
Definition: ossimGeoref.cpp:14
#define GEOREF_LAT_ERROR
Definition: ossimGeoref.cpp:15

◆ Convert_GEOREF_To_Geodetic()

long ossimGeoref::Convert_GEOREF_To_Geodetic ( char *  georef,
double *  Latitude,
double *  Longitude 
)
private

This function converts a GEOREF coordinate string to Geodetic (latitude and longitude in radians) coordinates.

ossimGeoref : GEOREF coordinate string (input) Latitude : Latitude in radians (output) Longitude : Longitude in radians (output)

Definition at line 230 of file ossimGeoref.cpp.

References DEGREE_TO_RADIAN, Extract_Degrees(), Extract_Minutes(), GEOREF_LETTERS, GEOREF_MAXIMUM, GEOREF_MINIMUM, GEOREF_NO_ERROR, GEOREF_STR_ERROR, GEOREF_STR_LAT_MIN_ERROR, GEOREF_STR_LON_MIN_ERROR, LATITUDE_LOW, LONGITUDE_LOW, and MIN_PER_DEG.

Referenced by ossimGeoref().

233 { /* BEGIN Convert_GEOREF_To_Geodetic */
234 /*
235  * This function converts a GEOREF coordinate string to Geodetic (latitude
236  * and longitude in radians) coordinates.
237  *
238  * georef : GEOREF coordinate string. (input)
239  * latitude : Latitude in radians. (output)
240  * longitude : Longitude in radians. (output)
241  *
242  * CALLS THE FOLLOWING FUNCTIONS:
243  *
244  * Extract_Degrees
245  * Extract_Minutes
246  */
247  long start; /* Position in the GEOREF string */
248  long minutes_length; /* length of minutes in the GEOREF string */
249  long georef_length; /* length of GEOREF string */
250  double origin_long; /* Origin longitude */
251  double origin_lat; /* Origin latitude */
252  double long_minutes; /* Longitude minute part of GEOREF */
253  double lat_minutes; /* Latitude minute part of GEOREF */
254  long error_code = GEOREF_NO_ERROR;
255 
256  origin_long = (double)LONGITUDE_LOW;
257  origin_lat = (double)LATITUDE_LOW;
258  georef_length = (long)strlen(georef);
259  if ((georef_length < GEOREF_MINIMUM) || (georef_length > GEOREF_MAXIMUM)
260  || ((georef_length % 2) != 0))
261  {
262  error_code |= GEOREF_STR_ERROR;
263  }
264  if (!error_code)
265  {
266  error_code |= Extract_Degrees(georef,latitude,longitude);
267  start = GEOREF_LETTERS;
268  minutes_length = (georef_length - start) / 2;
269  if (!error_code)
270  {
271  error_code |= Extract_Minutes(georef, start, minutes_length,
272  GEOREF_STR_LON_MIN_ERROR, &long_minutes);
273  if (!error_code)
274  {
275  error_code |= Extract_Minutes(georef, (start+minutes_length),
276  minutes_length, GEOREF_STR_LAT_MIN_ERROR, &lat_minutes);
277  *latitude = *latitude + origin_lat + lat_minutes / (double)MIN_PER_DEG;
278  *longitude = *longitude + origin_long + long_minutes / (double)MIN_PER_DEG;
279  *latitude = *latitude * DEGREE_TO_RADIAN;
280  *longitude = *longitude * DEGREE_TO_RADIAN;
281  }
282  }
283  }
284  return (error_code);
285 } /* END OF Convert_GEOREF_To_Geodetic */
long Extract_Minutes(char *georef, long start, long length, long ERROR_TYPE, double *minutes)
#define GEOREF_LETTERS
Definition: ossimGeoref.cpp:79
#define LATITUDE_LOW
Definition: ossimGeoref.cpp:72
#define LONGITUDE_LOW
Definition: ossimGeoref.cpp:74
#define DEGREE_TO_RADIAN
Definition: ossimGeoref.cpp:89
long Extract_Degrees(char *georef, double *latitude, double *longitude)
#define GEOREF_STR_ERROR
Definition: ossimGeoref.cpp:17
#define GEOREF_STR_LON_MIN_ERROR
Definition: ossimGeoref.cpp:21
#define GEOREF_STR_LAT_MIN_ERROR
Definition: ossimGeoref.cpp:20
#define GEOREF_MINIMUM
Definition: ossimGeoref.cpp:77
#define MIN_PER_DEG
Definition: ossimGeoref.cpp:76
#define GEOREF_MAXIMUM
Definition: ossimGeoref.cpp:78
#define GEOREF_NO_ERROR
Definition: ossimGeoref.cpp:14

◆ toString()

ossimString ossimGeoref::toString ( long  precision)

This function converts Geodetic (latitude and longitude in radians) coordinates to a GEOREF coordinate string. Precision specifies the number of digits in the GEOREF string for latitude and longitude: 0 for nearest degree 1 for nearest 10 minutes 2 for nearest minute 3 for nearest tenth of a minute 4 for nearest hundredth of a minute 5 for nearest thousandth of a minute

Precision : level of precision specified by the user (input) ossimGeoref : GEOREF coordinate string (return)

Definition at line 49 of file ossimGeoref.cpp.

References Convert_Geodetic_To_GEOREF(), GEOREF_NO_ERROR, ossimGpt::latr(), ossimGpt::lonr(), and thePt.

50 {
51  char resultString[100];
52 
53  long result = Convert_Geodetic_To_GEOREF(thePt.latr(),
54  thePt.lonr(),
55  precision,
56  resultString);
57  if(result == GEOREF_NO_ERROR)
58  {
59  return ossimString(resultString);
60  }
61 
62  return ossimString("");
63 }
ossimGpt thePt
Definition: ossimGeoref.h:31
long Convert_Geodetic_To_GEOREF(double Latitude, double Longitude, long Precision, char *georef)
double lonr() const
Returns the longitude in radian measure.
Definition: ossimGpt.h:76
double latr() const
latr().
Definition: ossimGpt.h:66
#define GEOREF_NO_ERROR
Definition: ossimGeoref.cpp:14

Member Data Documentation

◆ thePt

ossimGpt ossimGeoref::thePt
private

Definition at line 31 of file ossimGeoref.h.

Referenced by ossimGeoref(), and toString().


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