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

Class for creating datum instances from EPSG codes. More...

#include <ossimEpsgDatumFactory.h>

Inheritance diagram for ossimEpsgDatumFactory:
ossimDatumFactoryInterface

Public Member Functions

virtual ~ossimEpsgDatumFactory ()
 Destructor. More...
 
virtual const ossimDatumcreate (const ossimString &epsg_spec) const
 Creates a datum instance given an EPSG spec in the form "EPSG:<datum_code>". More...
 
virtual const ossimDatumcreate (const ossimKeywordlist &kwl, const char *prefix=0) const
 Creates a datum instance given a KWL and prefix. More...
 
virtual void getList (std::vector< ossimString > &list) const
 Returns list of all datums supported, in the form of "EPSG:<code>, <datum_name>". More...
 
const ossimDatumcreate (ossim_uint32 epsg_code) const
 Specific to this factory only. Creates a datum instance given an EPSG integer code. More...
 
ossim_uint32 findEpsgCode (const ossimString &alpha_code) const
 Specific to this factory only. More...
 
ossimString findAlphaCode (ossim_uint32 epsg_code) const
 Specific to this factory only. More...
 
- Public Member Functions inherited from ossimDatumFactoryInterface
 ossimDatumFactoryInterface ()
 default constructor More...
 
virtual ~ossimDatumFactoryInterface ()
 virtual destructor More...
 

Static Public Member Functions

static ossimEpsgDatumFactoryinstance ()
 Singleton implementation. More...
 

Protected Member Functions

 ossimEpsgDatumFactory ()
 Hidden constructors for singleton implementation. More...
 

Protected Attributes

std::map< ossim_uint32, std::string > m_epsgToAlphaMap
 Presently implemented as a mapping from EPSG code to OSSIM/Geotrans alpha-codes found in ossimDatumFactory. More...
 

Detailed Description

Class for creating datum instances from EPSG codes.

Presently only a small subset of EPSG datums are supported. These are hardcoded here or, alternatively, the EPSG code is mapped to the OSSIM/Geotrans code and ossimDatumFactory is used to produce the final datum.

TO DO: Eventually we should have a disk-file based database lookup of datums with associated parameters similar to the EPSG projection factory and database.

Definition at line 31 of file ossimEpsgDatumFactory.h.

Constructor & Destructor Documentation

◆ ~ossimEpsgDatumFactory()

ossimEpsgDatumFactory::~ossimEpsgDatumFactory ( )
virtual

Destructor.

Definition at line 122 of file ossimEpsgDatumFactory.cpp.

123 {
124 }

◆ ossimEpsgDatumFactory()

ossimEpsgDatumFactory::ossimEpsgDatumFactory ( )
protected

Hidden constructors for singleton implementation.

Definition at line 47 of file ossimEpsgDatumFactory.cpp.

References m_epsgToAlphaMap.

48 {
49  m_epsgToAlphaMap.insert(std::make_pair(6135, std::string("OHI-M")));
50  m_epsgToAlphaMap.insert(std::make_pair(6139, std::string("PUR")));
51  m_epsgToAlphaMap.insert(std::make_pair(6152, std::string("NAR")));
52  m_epsgToAlphaMap.insert(std::make_pair(6154, std::string("EUR-M"))); // QUESTIONABLE
53  m_epsgToAlphaMap.insert(std::make_pair(6155, std::string("DAL")));
54  m_epsgToAlphaMap.insert(std::make_pair(6156, std::string("CCD")));
55  m_epsgToAlphaMap.insert(std::make_pair(6158, std::string("NAP")));
56  m_epsgToAlphaMap.insert(std::make_pair(6165, std::string("BID")));
57  m_epsgToAlphaMap.insert(std::make_pair(6169, std::string("AMA")));
58  m_epsgToAlphaMap.insert(std::make_pair(6175, std::string("SRL"))); // QUESTIONABLE
59  m_epsgToAlphaMap.insert(std::make_pair(6201, std::string("ADI-M")));
60  m_epsgToAlphaMap.insert(std::make_pair(6202, std::string("AUA")));
61  m_epsgToAlphaMap.insert(std::make_pair(6203, std::string("AUG")));
62  m_epsgToAlphaMap.insert(std::make_pair(6204, std::string("AIN-A"))); // QUESTIONABLE
63  m_epsgToAlphaMap.insert(std::make_pair(6205, std::string("AFG")));
64  m_epsgToAlphaMap.insert(std::make_pair(6209, std::string("ARF-M")));
65  m_epsgToAlphaMap.insert(std::make_pair(6210, std::string("ARS-M")));
66  m_epsgToAlphaMap.insert(std::make_pair(6216, std::string("BER")));
67  m_epsgToAlphaMap.insert(std::make_pair(6218, std::string("BOO"))); // QUESTIONABLE
68  m_epsgToAlphaMap.insert(std::make_pair(6219, std::string("BUR")));
69  m_epsgToAlphaMap.insert(std::make_pair(6221, std::string("CAI")));
70  m_epsgToAlphaMap.insert(std::make_pair(6222, std::string("CAP")));
71  m_epsgToAlphaMap.insert(std::make_pair(6223, std::string("CGE")));
72  m_epsgToAlphaMap.insert(std::make_pair(6224, std::string("CHU")));
73  m_epsgToAlphaMap.insert(std::make_pair(6236, std::string("HTN")));
74  m_epsgToAlphaMap.insert(std::make_pair(6238, std::string("IDN")));
75  m_epsgToAlphaMap.insert(std::make_pair(6239, std::string("INF-A"))); // QUESTIONABLE
76  m_epsgToAlphaMap.insert(std::make_pair(6240, std::string("INH-A"))); // QUESTIONABLE
77  m_epsgToAlphaMap.insert(std::make_pair(6244, std::string("KAN")));
78  m_epsgToAlphaMap.insert(std::make_pair(6245, std::string("KEA")));
79  m_epsgToAlphaMap.insert(std::make_pair(6248, std::string("PRP-M"))); // QUESTIONABLE
80  m_epsgToAlphaMap.insert(std::make_pair(6250, std::string("LEH")));
81  m_epsgToAlphaMap.insert(std::make_pair(6251, std::string("LIB")));
82  m_epsgToAlphaMap.insert(std::make_pair(6253, std::string("LUZ-A"))); // QUESTIONABLE
83  m_epsgToAlphaMap.insert(std::make_pair(6255, std::string("HEN")));
84  m_epsgToAlphaMap.insert(std::make_pair(6256, std::string("MIK")));
85  m_epsgToAlphaMap.insert(std::make_pair(6261, std::string("MER")));
86  m_epsgToAlphaMap.insert(std::make_pair(6262, std::string("MAS")));
87  m_epsgToAlphaMap.insert(std::make_pair(6263, std::string("MIN-A"))); // QUESTIONABLE
88  m_epsgToAlphaMap.insert(std::make_pair(6266, std::string("MPO")));
89  m_epsgToAlphaMap.insert(std::make_pair(6267, std::string("NAS-C")));
90  m_epsgToAlphaMap.insert(std::make_pair(6269, std::string("NAR-C")));
91  m_epsgToAlphaMap.insert(std::make_pair(6270, std::string("NAH-C"))); // QUESTIONABLE
92  m_epsgToAlphaMap.insert(std::make_pair(6282, std::string("PTN")));
93  m_epsgToAlphaMap.insert(std::make_pair(6284, std::string("PUK")));
94  m_epsgToAlphaMap.insert(std::make_pair(6285, std::string("QAT"))); // QUESTIONABLE
95  m_epsgToAlphaMap.insert(std::make_pair(6287, std::string("QUO")));
96  m_epsgToAlphaMap.insert(std::make_pair(6292, std::string("SAP")));
97  m_epsgToAlphaMap.insert(std::make_pair(6293, std::string("SCK")));
98  m_epsgToAlphaMap.insert(std::make_pair(6297, std::string("TAN")));
99  m_epsgToAlphaMap.insert(std::make_pair(6298, std::string("TIL")));
100  m_epsgToAlphaMap.insert(std::make_pair(6301, std::string("TOY-M")));
101  m_epsgToAlphaMap.insert(std::make_pair(6304, std::string("VOI"))); // QUESTIONABLE
102  m_epsgToAlphaMap.insert(std::make_pair(6307, std::string("NSD")));
103  m_epsgToAlphaMap.insert(std::make_pair(6309, std::string("YAC")));
104  m_epsgToAlphaMap.insert(std::make_pair(6311, std::string("ZAN")));
105  m_epsgToAlphaMap.insert(std::make_pair(6322, std::string("WGD")));
106  m_epsgToAlphaMap.insert(std::make_pair(6326, std::string("WGE")));
107  m_epsgToAlphaMap.insert(std::make_pair(6601, std::string("AIA")));
108  m_epsgToAlphaMap.insert(std::make_pair(6604, std::string("ASM")));
109  m_epsgToAlphaMap.insert(std::make_pair(6611, std::string("HKD"))); // QUESTIONABLE
110  m_epsgToAlphaMap.insert(std::make_pair(6613, std::string("GSE")));
111  m_epsgToAlphaMap.insert(std::make_pair(6615, std::string("POS")));
112  m_epsgToAlphaMap.insert(std::make_pair(6616, std::string("SGM")));
113  m_epsgToAlphaMap.insert(std::make_pair(6618, std::string("SAN-M")));
114  m_epsgToAlphaMap.insert(std::make_pair(6658, std::string("HJO")));
115  m_epsgToAlphaMap.insert(std::make_pair(6668, std::string("EUS")));
116  m_epsgToAlphaMap.insert(std::make_pair(6807, std::string("NTF")));
117 }
std::map< ossim_uint32, std::string > m_epsgToAlphaMap
Presently implemented as a mapping from EPSG code to OSSIM/Geotrans alpha-codes found in ossimDatumFa...

Member Function Documentation

◆ create() [1/3]

const ossimDatum * ossimEpsgDatumFactory::create ( const ossimString epsg_spec) const
virtual

Creates a datum instance given an EPSG spec in the form "EPSG:<datum_code>".

Creates given an EPSG spec in the form "EPSG:<datum_code>".

Implements ossimDatumFactoryInterface.

Definition at line 129 of file ossimEpsgDatumFactory.cpp.

References ossimString::after(), ossimString::before(), ossimString::contains(), ossimString::size(), and ossimString::toUInt32().

Referenced by create(), ossimEpsgProjectionDatabase::createProjFromFormatARecord(), and ossimWktProjectionFactory::doMapCommon().

130 {
131  if ( epsg_spec.size() )
132  {
133  ossim_uint32 gcs_code;
134  ossimString group; // assume we are working with EPSG codes
135  if (epsg_spec.contains(":"))
136  {
137  group = epsg_spec.before(":");
138  gcs_code = epsg_spec.after(":").toUInt32();
139  }
140  else
141  {
142  group = "EPSG"; // No group spec provided, assuming EPSG:
143  gcs_code = epsg_spec.toUInt32();
144  }
145  if ((group != "EPSG") || (gcs_code == 0))
146  return 0;
147 
148  return create(gcs_code);
149  }
150  return 0;
151 }
ossimString before(const ossimString &str, std::string::size_type pos=0) const
METHOD: before(str, pos) Returns string beginning at pos and ending one before the token str If strin...
bool contains(char aChar) const
Definition: ossimString.h:58
ossim_uint32 toUInt32() const
virtual const ossimDatum * create(const ossimString &epsg_spec) const
Creates a datum instance given an EPSG spec in the form "EPSG:<datum_code>".
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
ossimString after(const ossimString &str, std::string::size_type pos=0) const
METHOD: after(str, pos) Returns string immediately after the token str.

◆ create() [2/3]

const ossimDatum * ossimEpsgDatumFactory::create ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Creates a datum instance given a KWL and prefix.

Implements ossimDatumFactoryInterface.

Definition at line 157 of file ossimEpsgDatumFactory.cpp.

References create(), ossimString::empty(), ossimKeywordlist::find(), and ossimKeywordNames::GCS_CODE_KW.

158 {
159  ossimString lookup = kwl.find(prefix, ossimKeywordNames::GCS_CODE_KW);
160  if(!lookup.empty())
161  return create(lookup);
162  return 0;
163 
164 }
const char * find(const char *key) const
static const char * GCS_CODE_KW
virtual const ossimDatum * create(const ossimString &epsg_spec) const
Creates a datum instance given an EPSG spec in the form "EPSG:<datum_code>".
bool empty() const
Definition: ossimString.h:411

◆ create() [3/3]

const ossimDatum * ossimEpsgDatumFactory::create ( ossim_uint32  epsg_code) const

Specific to this factory only. Creates a datum instance given an EPSG integer code.

Creates given an EPSG spec in the form "EPSG:<datum_code>".

Definition at line 168 of file ossimEpsgDatumFactory.cpp.

References ossimDatumFactory::create(), ossimString::empty(), findAlphaCode(), and ossimDatumFactory::instance().

169 {
170  // Geographic coordinate system codes (4XXX) are sometimes used in place of their corresponding
171  // datum code (6XXX). Check for this possibility and transpose the code if so:
172  if ((datum_code >= 4135) && (datum_code <= 4807))
173  datum_code += 2000;
174 
175  // Find the datum code in the map in order to determine the corresponding OSSIM/Geotrans alpha
176  // code. Then use the datum factory to create the datum.
177  ossimString alphaCode = findAlphaCode(datum_code);
178  if (!alphaCode.empty())
179  return ossimDatumFactory::instance()->create(alphaCode);
180 
181  return 0;
182 }
virtual const ossimDatum * create(const ossimString &code) const
create method
ossimString findAlphaCode(ossim_uint32 epsg_code) const
Specific to this factory only.
static ossimDatumFactory * instance()
bool empty() const
Definition: ossimString.h:411

◆ findAlphaCode()

ossimString ossimEpsgDatumFactory::findAlphaCode ( ossim_uint32  epsg_code) const

Specific to this factory only.

Given an EPSG, returns equivalent alpha-code datum code or empty string if not found.

Definition at line 232 of file ossimEpsgDatumFactory.cpp.

References m_epsgToAlphaMap.

Referenced by create().

233 {
234  ossimString result("");
235  std::map<ossim_uint32, std::string>::const_iterator iter = m_epsgToAlphaMap.find(epsg_code);
236  if (iter != m_epsgToAlphaMap.end())
237  {
238  result = iter->second;
239  }
240  return result;
241 }
std::map< ossim_uint32, std::string > m_epsgToAlphaMap
Presently implemented as a mapping from EPSG code to OSSIM/Geotrans alpha-codes found in ossimDatumFa...

◆ findEpsgCode()

ossim_uint32 ossimEpsgDatumFactory::findEpsgCode ( const ossimString alpha_code) const

Specific to this factory only.

Given an alpha-code, returns equivalent EPSG datum code or 0 if not found.

Definition at line 216 of file ossimEpsgDatumFactory.cpp.

References m_epsgToAlphaMap, and ossimString::string().

Referenced by ossimDatum::ossimDatum().

217 {
218  std::map<ossim_uint32, std::string>::const_iterator iter = m_epsgToAlphaMap.begin();
219  while (iter != m_epsgToAlphaMap.end())
220  {
221  if (iter->second == alpha_code.string())
222  return iter->first;
223  ++iter;
224  }
225  return 0;
226 }
std::map< ossim_uint32, std::string > m_epsgToAlphaMap
Presently implemented as a mapping from EPSG code to OSSIM/Geotrans alpha-codes found in ossimDatumFa...
const std::string & string() const
Definition: ossimString.h:414

◆ getList()

void ossimEpsgDatumFactory::getList ( std::vector< ossimString > &  list) const
virtual

Returns list of all datums supported, in the form of "EPSG:<code>, <datum_name>".

Implements ossimDatumFactoryInterface.

Definition at line 187 of file ossimEpsgDatumFactory.cpp.

References ossimDatumFactory::create(), ossimDatumFactory::instance(), m_epsgToAlphaMap, ossimDatum::name(), ossimString::push_back(), and ossimString::toString().

188 {
190  const ossimDatum* datum;
191  std::map<ossim_uint32, std::string>::const_iterator iter = m_epsgToAlphaMap.begin();
192 
193  // Loop over all handled datum codes and instantiate the corresponding datum in order to
194  // get the corresponding OSSIM/Geotrans name. Eventually the datum info (including its name as
195  // it appears in the EPSG database) will be read directly from the Db without using
196  // ossimDatumFactory.
197  while(iter != m_epsgToAlphaMap.end())
198  {
199  datum = df->create(iter->second);
200  if (datum)
201  {
202  ossimString entry ("EPSG:");
203  entry += ossimString::toString(iter->first);
204  entry += ",";
205  entry += datum->name();
206  list.push_back(entry);
207  }
208  ++iter;
209  }
210 }
virtual const ossimDatum * create(const ossimString &code) const
create method
static ossimString toString(bool aValue)
Numeric to string methods.
virtual const ossimString & name() const
Definition: ossimDatum.h:58
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
std::map< ossim_uint32, std::string > m_epsgToAlphaMap
Presently implemented as a mapping from EPSG code to OSSIM/Geotrans alpha-codes found in ossimDatumFa...
static ossimDatumFactory * instance()

◆ instance()

ossimEpsgDatumFactory * ossimEpsgDatumFactory::instance ( )
static

Singleton implementation.

Definition at line 31 of file ossimEpsgDatumFactory.cpp.

Referenced by ossimEpsgProjectionDatabase::createProjFromFormatARecord(), ossimWktProjectionFactory::doMapCommon(), ossimDatum::ossimDatum(), and ossimDatumFactoryRegistry::ossimDatumFactoryRegistry().

32 {
33  static ossimEpsgDatumFactory inst;
34 
35  return &inst;
36  // if(!m_instance)
37  // m_instance = new ossimEpsgDatumFactory;
38  // return m_instance;
39 }
Class for creating datum instances from EPSG codes.

Member Data Documentation

◆ m_epsgToAlphaMap

std::map<ossim_uint32, std::string> ossimEpsgDatumFactory::m_epsgToAlphaMap
protected

Presently implemented as a mapping from EPSG code to OSSIM/Geotrans alpha-codes found in ossimDatumFactory.

Eventually should be independent (and deprecate) ossimDatumFactory.

Definition at line 66 of file ossimEpsgDatumFactory.h.

Referenced by findAlphaCode(), findEpsgCode(), getList(), and ossimEpsgDatumFactory().


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