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

#include <ossimEllipsoidFactory.h>

Public Member Functions

virtual ~ossimEllipsoidFactory ()
 
const ossimEllipsoidcreate (const ossimString &code) const
 
const ossimEllipsoidwgs84 () const
 
const ossimEllipsoidwgs72 () const
 
ossim_uint32 findEpsgCode (const ossimString &alpha_code) const
 Given an alpha code (for example "WE" for WGS84), returns the corresponding EPSG code or 0 if not found. More...
 

Static Public Member Functions

static ossimEllipsoidFactoryinstance ()
 

Private Types

typedef std::map< std::string, ossimEllipsoid * > TableType
 
typedef std::map< ossim_uint32, std::string > EpsgTableType
 

Private Member Functions

 ossimEllipsoidFactory ()
 
void initializeTable ()
 
void deleteAll ()
 

Private Attributes

ossimEllipsoidtheWgs84Ellipsoid
 
ossimEllipsoidtheWgs72Ellipsoid
 
TableType theEllipsoidTable
 
EpsgTableType theEpsgTable
 

Detailed Description

Definition at line 25 of file ossimEllipsoidFactory.h.

Member Typedef Documentation

◆ EpsgTableType

typedef std::map<ossim_uint32, std::string> ossimEllipsoidFactory::EpsgTableType
private

Definition at line 41 of file ossimEllipsoidFactory.h.

◆ TableType

typedef std::map<std::string, ossimEllipsoid*> ossimEllipsoidFactory::TableType
private

Definition at line 40 of file ossimEllipsoidFactory.h.

Constructor & Destructor Documentation

◆ ~ossimEllipsoidFactory()

ossimEllipsoidFactory::~ossimEllipsoidFactory ( )
virtual

Definition at line 40 of file ossimEllipsoidFactory.cpp.

References deleteAll().

41 {
42  deleteAll();
43 }

◆ ossimEllipsoidFactory()

ossimEllipsoidFactory::ossimEllipsoidFactory ( )
private

Definition at line 36 of file ossimEllipsoidFactory.cpp.

37 {
38 }

Member Function Documentation

◆ create()

const ossimEllipsoid * ossimEllipsoidFactory::create ( const ossimString code) const

Definition at line 45 of file ossimEllipsoidFactory.cpp.

References ossimString::empty(), ossimNotify(), ossimNotifyLevel_WARN, theEllipsoidTable, theEpsgTable, and ossimString::toUInt32().

Referenced by ossimNgaProjectionFactory::createProjection(), and ossimEllipsoid::loadState().

46 {
47  // Can be 2-letter code or EPSG integer code for ellipsoids (7000-series). Make sure it is alpha:
48  if ( code.empty() )
49  {
50  return 0;
51  }
52 
53  const ossimEllipsoid* ellipsoid = 0;
54  ossimString alphaCode = code;
55 
56  // Check if the code passed in was actually numeric EPSG (vs. two char alpha code):
57  ossim_uint32 epsg_code = code.toUInt32();
58  if (epsg_code)
59  {
60  // EPSG was specified, fetch the equivalent alpha code from the map:
61  EpsgTableType::const_iterator iter = theEpsgTable.find(epsg_code);
62  if (iter != theEpsgTable.end())
63  alphaCode = (*iter).second;
64  }
65 
66  // Established two-letter code. Now fetch the ellipsoid instance:
67  TableType::const_iterator iter = theEllipsoidTable.find(alphaCode);
68  if(iter != theEllipsoidTable.end())
69  ellipsoid = iter->second;
70  else
71  {
72  ossimNotify(ossimNotifyLevel_WARN) << "ossimEllipsoidFactory::create WARNING:"
73  << "\nDid not create ellipsoid for code: " << code << std::endl;
74  }
75 
76  return ellipsoid;
77 }
ossim_uint32 toUInt32() const
unsigned int ossim_uint32
bool empty() const
Definition: ossimString.h:411
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ deleteAll()

void ossimEllipsoidFactory::deleteAll ( )
private

Definition at line 197 of file ossimEllipsoidFactory.cpp.

References theEllipsoidTable, theEpsgTable, theWgs72Ellipsoid, and theWgs84Ellipsoid.

Referenced by ~ossimEllipsoidFactory().

198 {
199  TableType::const_iterator ellipsoid = theEllipsoidTable.begin();
200 
201  while(ellipsoid != theEllipsoidTable.end())
202  {
203  delete (*ellipsoid).second;
204  ++ellipsoid;
205  }
206 
207  theEllipsoidTable.clear();
208  theEpsgTable.clear();
209 
210  if (theWgs84Ellipsoid)
211  {
212  delete theWgs84Ellipsoid;
213  theWgs84Ellipsoid = 0;
214  }
215  if (theWgs72Ellipsoid)
216  {
217  delete theWgs72Ellipsoid;
218  theWgs72Ellipsoid = 0;
219  }
220 }
ossimEllipsoid * theWgs72Ellipsoid
ossimEllipsoid * theWgs84Ellipsoid

◆ findEpsgCode()

ossim_uint32 ossimEllipsoidFactory::findEpsgCode ( const ossimString alpha_code) const

Given an alpha code (for example "WE" for WGS84), returns the corresponding EPSG code or 0 if not found.

Definition at line 226 of file ossimEllipsoidFactory.cpp.

References ossimString::empty(), ossimString::string(), and theEpsgTable.

Referenced by ossimEllipsoid::getEpsgCode(), and ossimEllipsoid::ossimEllipsoid().

227 {
228  ossim_uint32 epsg_code = 0;
229  if (alpha_code.empty())
230  return 0;
231 
232  EpsgTableType::const_iterator iter = theEpsgTable.begin();
233  while ((iter != theEpsgTable.end()) && (epsg_code == 0))
234  {
235  if (iter->second == alpha_code.string())
236  {
237  epsg_code = iter->first;
238  }
239  iter++;
240  }
241  return epsg_code;
242 }
unsigned int ossim_uint32
bool empty() const
Definition: ossimString.h:411
const std::string & string() const
Definition: ossimString.h:414

◆ initializeTable()

void ossimEllipsoidFactory::initializeTable ( )
private

Definition at line 79 of file ossimEllipsoidFactory.cpp.

References theEllipsoidTable, theEpsgTable, theWgs72Ellipsoid, and theWgs84Ellipsoid.

Referenced by instance().

80 {
81  // Do nothing if tables were already initialized:
82  if (!theEllipsoidTable.empty())
83  {
84  return;
85  }
86 
87  // This table bridges between EPSG 7000-series codes to two-letter code:
88  theEpsgTable.insert(std::make_pair(7001, std::string("AA")));
89  theEpsgTable.insert(std::make_pair(7002, std::string("AM")));
90  theEpsgTable.insert(std::make_pair(7003, std::string("AN")));
91  theEpsgTable.insert(std::make_pair(7004, std::string("BR")));
92  theEpsgTable.insert(std::make_pair(7006, std::string("BN")));
93  theEpsgTable.insert(std::make_pair(7008, std::string("CC")));
94  theEpsgTable.insert(std::make_pair(7012, std::string("CD")));
95  theEpsgTable.insert(std::make_pair(7011, std::string("CE")));
96  theEpsgTable.insert(std::make_pair(7015, std::string("EA")));
97  theEpsgTable.insert(std::make_pair(7016, std::string("EB")));
98  theEpsgTable.insert(std::make_pair(7044, std::string("EC")));
99  theEpsgTable.insert(std::make_pair(7056, std::string("ED")));
100  theEpsgTable.insert(std::make_pair(7018, std::string("EE")));
101  theEpsgTable.insert(std::make_pair(7019, std::string("RF")));
102  theEpsgTable.insert(std::make_pair(7020, std::string("HE")));
103  theEpsgTable.insert(std::make_pair(7053, std::string("HO")));
104  theEpsgTable.insert(std::make_pair(7021, std::string("ID")));
105  theEpsgTable.insert(std::make_pair(7022, std::string("IN")));
106  theEpsgTable.insert(std::make_pair(7024, std::string("KA")));
107  theEpsgTable.insert(std::make_pair(7003, std::string("SA"))); // Same as "AN"
108  theEpsgTable.insert(std::make_pair(7043, std::string("WD")));
109  theEpsgTable.insert(std::make_pair(7030, std::string("WE")));
110  theEpsgTable.insert(std::make_pair(7059, std::string("PV")));
111 
112  theEllipsoidTable.insert(std::make_pair(std::string("AA"),
113  new ossimEllipsoid(std::string("Airy"), std::string("AA"),
114  6377563.396, 6356256.9090, 7001)));
115  theEllipsoidTable.insert(std::make_pair(std::string("AM"),
116  new ossimEllipsoid(std::string("Modified Airy"), std::string("AM"),
117  6377340.189, 6356034.448, 7002)));
118  theEllipsoidTable.insert(std::make_pair(std::string("AN"),
119  new ossimEllipsoid(std::string("Australian National"), std::string("AN"),
120  6378160.000, 6356774.7190, 7003)));
121  theEllipsoidTable.insert(std::make_pair(std::string("BR"),
122  new ossimEllipsoid(std::string("Bessel 1841"), std::string("BR"),
123  6377397.155, 6356078.9630, 7004)));
124  theEllipsoidTable.insert(std::make_pair(std::string("BN"),
125  new ossimEllipsoid(std::string("Bessel 1841(Namibia)"), std::string("BN"),
126  6377483.865, 6356165.3830, 7006)));
127  theEllipsoidTable.insert(std::make_pair(std::string("CC"),
128  new ossimEllipsoid(std::string("Clarke 1866"), std::string("CC"),
129  6378206.400, 6356583.8000, 7008)));
130  theEllipsoidTable.insert(std::make_pair(std::string("CD"),
131  new ossimEllipsoid(std::string("Clarke 1880"), std::string("CD"),
132  6378249.145, 6356514.8700, 7012)));
133  theEllipsoidTable.insert(std::make_pair(std::string("CE"),
134  new ossimEllipsoid(std::string("Clarke 1880 (IGN)EPSG 7011"), std::string("CE"),
135  6378249.200, 6356515.0000, 7011)));
136  theEllipsoidTable.insert(std::make_pair(std::string("EA"),
137  new ossimEllipsoid(std::string("Everest"), std::string("EA"),
138  6377276.345, 6356075.4130, 7015)));
139  theEllipsoidTable.insert(std::make_pair(std::string("EB"),
140  new ossimEllipsoid(std::string("Everest (E. Malasia, Brunei)"), std::string("EB"),
141  6377298.556, 6356097.55, 7016)));
142  theEllipsoidTable.insert(std::make_pair(std::string("EC"),
143  new ossimEllipsoid(std::string("Everest 1956 (India)"), std::string("EC"),
144  6377301.243, 6356100.228, 7044)));
145  theEllipsoidTable.insert(std::make_pair(std::string("ED"),
146  new ossimEllipsoid(std::string("Everest 1969 (West Malasia)"), std::string("ED"),
147  6377295.664, 6356094.668, 7056)));
148  theEllipsoidTable.insert(std::make_pair(std::string("EE"),
149  new ossimEllipsoid(std::string("Everest 1948(W.Mals. & Sing.)"), std::string("EE"),
150  6377304.063, 6356103.039, 7018)));
151 
152  // No codes for next two:
153  theEllipsoidTable.insert(std::make_pair(std::string("EF"),
154  new ossimEllipsoid(std::string("Everest (Pakistan)"), std::string("EF"),
155  6377309.613, 6356109.571, 0)));
156  theEllipsoidTable.insert(std::make_pair(std::string("FA"),
157  new ossimEllipsoid(std::string("Mod. Fischer 1960(South Asia)"), std::string("FA"),
158  6378155.0, 6356773.32, 0)));
159 
160  theEllipsoidTable.insert(std::make_pair(std::string("RF"),
161  new ossimEllipsoid(std::string("GRS 80"), std::string("RF"),
162  6378137.0, 6356752.3141, 7019)));
163  theEllipsoidTable.insert(std::make_pair(std::string("HE"),
164  new ossimEllipsoid(std::string("Helmert 1906"), std::string("HE"),
165  6378200.0, 6356818.17, 7020)));
166  theEllipsoidTable.insert(std::make_pair(std::string("HO"),
167  new ossimEllipsoid(std::string("Hough"), std::string("HO"),
168  6378270.0, 6356794.3430, 7053)));
169  theEllipsoidTable.insert(std::make_pair(std::string("ID"),
170  new ossimEllipsoid(std::string("Indonesian 1974"), std::string("ID"),
171  6378160.0, 6356774.504, 7021)));
172  theEllipsoidTable.insert(std::make_pair(std::string("IN"),
173  new ossimEllipsoid(std::string("International 1924"), std::string("IN"),
174  6378388.0, 6356911.946, 7022)));
175  theEllipsoidTable.insert(std::make_pair(std::string("KA"),
176  new ossimEllipsoid(std::string("Krassovsky"), std::string("KA"),
177  6378245.0, 6356863.0190, 7024)));
178  theEllipsoidTable.insert(std::make_pair(std::string("SA"),
179  new ossimEllipsoid(std::string("South American 1969"),std::string("SA"),
180  6378160.0, 6356774.719, 7003)));
181  theEllipsoidTable.insert(std::make_pair(std::string("WD"),
182  new ossimEllipsoid(std::string("WGS 72"), std::string("WD"),
183  6378135.000, 6356750.5200, 7043)));
184  theEllipsoidTable.insert(std::make_pair(std::string("WE"),
185  new ossimEllipsoid(std::string("WGS 84"), std::string("WE"),
186  6378137.000, 6356752.3142, 7030)));
187  theEllipsoidTable.insert(std::make_pair(std::string("PV"),
188  new ossimEllipsoid(std::string("Popular Visualization Sphere"), std::string("7059"),
189  6378137.000, 6378137.000, 7059)));
190 
191  theWgs84Ellipsoid = new ossimEllipsoid(std::string("WGS 84"), std::string("WE"),
192  6378137.000, 6356752.3142, 7030);
193  theWgs72Ellipsoid = new ossimEllipsoid(std::string("WGS 72"), std::string("WD"),
194  6378135.000, 6356750.5200, 7043);
195 }
ossimEllipsoid * theWgs72Ellipsoid
ossimEllipsoid * theWgs84Ellipsoid

◆ instance()

ossimEllipsoidFactory * ossimEllipsoidFactory::instance ( )
static

Definition at line 17 of file ossimEllipsoidFactory.cpp.

References initializeTable().

Referenced by ossimNgaProjectionFactory::createProjection(), ossimEllipsoid::getEpsgCode(), ossimEllipsoid::loadState(), ossimDatumFactory::ossimDatumFactory(), ossimEllipsoid::ossimEllipsoid(), ossimWgs72Datum::shiftFromWgs84(), and ossimWgs72Datum::shiftToWgs84().

18 {
19  static ossimEllipsoidFactory inst;
20 
21  //---
22  // Boolean test here is necessary to avoid infinite loop from Ellipsoid
23  // classes calling this factory's instance() method. Leave this convoluted
24  // code as is. (OLK 09/14)
25  //---
26  static bool testInst = false;
27  if(!testInst)
28  {
29  testInst = true;
30  inst.initializeTable();
31  }
32 
33  return &inst;
34 }

◆ wgs72()

const ossimEllipsoid* ossimEllipsoidFactory::wgs72 ( ) const
inline

◆ wgs84()

const ossimEllipsoid* ossimEllipsoidFactory::wgs84 ( ) const
inline

Member Data Documentation

◆ theEllipsoidTable

TableType ossimEllipsoidFactory::theEllipsoidTable
private

Definition at line 46 of file ossimEllipsoidFactory.h.

Referenced by create(), deleteAll(), and initializeTable().

◆ theEpsgTable

EpsgTableType ossimEllipsoidFactory::theEpsgTable
private

Definition at line 47 of file ossimEllipsoidFactory.h.

Referenced by create(), deleteAll(), findEpsgCode(), and initializeTable().

◆ theWgs72Ellipsoid

ossimEllipsoid* ossimEllipsoidFactory::theWgs72Ellipsoid
private

Definition at line 45 of file ossimEllipsoidFactory.h.

Referenced by deleteAll(), and initializeTable().

◆ theWgs84Ellipsoid

ossimEllipsoid* ossimEllipsoidFactory::theWgs84Ellipsoid
private

Definition at line 44 of file ossimEllipsoidFactory.h.

Referenced by deleteAll(), and initializeTable().


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