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

Projection Factory for coded projections defined in database. More...

#include <ossimEpsgProjectionFactory.h>

Inheritance diagram for ossimEpsgProjectionFactory:
ossimProjectionFactoryBase ossimObjectFactory ossimObject ossimReferenced

Public Member Functions

virtual ossimProjectioncreateProjection (const ossimFilename &filename, ossim_uint32 entryIdx) const
 STUB. Not implemented. More...
 
virtual ossimProjectioncreateProjection (const ossimString &name) const
 This is the principal factory method. More...
 
virtual ossimProjectioncreateProjection (const ossimKeywordlist &kwl, const char *prefix=0) const
 Looks for presence of "pcs_code" keyword with the value in the format <group>:, for example "EPSG:32615" (EPSG and AUTO–see above– are presently supported). More...
 
virtual ossimObjectcreateObject (const ossimString &typeName) const
 
virtual ossimObjectcreateObject (const ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual void getTypeNameList (std::vector< ossimString > &typeList) const
 This returns the type name of all objects in all factories. More...
 
- Public Member Functions inherited from ossimProjectionFactoryBase
virtual ossimProjectioncreateProjection (ossimImageHandler *handler) const
 
- Public Member Functions inherited from ossimObjectFactory
virtual ~ossimObjectFactory ()
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
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 bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) 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
 

Static Public Member Functions

static ossimEpsgProjectionFactoryinstance ()
 Implements singleton pattern. More...
 

Protected Member Functions

 ossimEpsgProjectionFactory ()
 Constructor loads all SRS CSV files specified in the ossim prefs. More...
 
ossimMapProjectioncreateProjFromAutoCode (const std::vector< ossimString > &spec) const
 When the CRS is specified with the "AUTO:<spec>" code format, this method is invoked to parse the <spec> and produce a projection (or NULL if spec invalid): This really shouldn't be in this class but nobody else is parsing for it, so leave it here for now. More...
 
- Protected Member Functions inherited from ossimProjectionFactoryBase
ossimProjectioncreateProjectionFromGeometryFile (const ossimFilename &imageFile, ossim_uint32 entryIdx) const
 This method takes the filename and tries to find an external ".geom" file. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Projection Factory for coded projections defined in database.

These are projections that are fully defined in database files and specified via a projection coordinate system (PCS) code, such as EPSG codes.

Definition at line 27 of file ossimEpsgProjectionFactory.h.

Constructor & Destructor Documentation

◆ ossimEpsgProjectionFactory()

ossimEpsgProjectionFactory::ossimEpsgProjectionFactory ( )
protected

Constructor loads all SRS CSV files specified in the ossim prefs.

Protected as part of singleton implementation.

Definition at line 41 of file ossimEpsgProjectionFactory.cpp.

42 {
43 }

Member Function Documentation

◆ createObject() [1/2]

ossimObject * ossimEpsgProjectionFactory::createObject ( const ossimString typeName) const
virtual

Creates an object given a type name.

Implements ossimObjectFactory.

Definition at line 176 of file ossimEpsgProjectionFactory.cpp.

References createProjection().

177 {
178  return createProjection(typeName);
179 }
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
STUB. Not implemented.

◆ createObject() [2/2]

ossimObject * ossimEpsgProjectionFactory::createObject ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Creates and object given a keyword list.

Implements ossimObjectFactory.

Definition at line 182 of file ossimEpsgProjectionFactory.cpp.

References createProjection().

184 {
185  return createProjection(kwl, prefix);
186 }
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
STUB. Not implemented.

◆ createProjection() [1/3]

ossimProjection * ossimEpsgProjectionFactory::createProjection ( const ossimFilename filename,
ossim_uint32  entryIdx 
) const
virtual

◆ createProjection() [2/3]

ossimProjection * ossimEpsgProjectionFactory::createProjection ( const ossimString name) const
virtual

This is the principal factory method.

It accepts a string in one of three formats:

  1. <group>:, for example "EPSG:32615"
  2. , for example "32615", this is the CRS code ID for the projerection.
  3. AUTO:<comma-separated spec>, for specifying custom user-defined codes.

Both projected and geographic (Platte Carre) codes are handled.

Implements ossimProjectionFactoryBase.

Definition at line 96 of file ossimEpsgProjectionFactory.cpp.

References ossimString::after(), createProjFromAutoCode(), ossimString::explode(), ossimEpsgProjectionDatabase::findProjection(), ossimEpsgProjectionDatabase::instance(), and ossimString::trim().

97 {
98  std::vector<ossimString> split_line;
99 
100  // Intercept custom codes here before resorting to the database. This really shouldn't be in this
101  // class but nobody else is parsing for it, so leave it here for now.
102  if (ossimString(spec).downcase().contains("auto"))
103  {
104  split_line = spec.after(":").explode(",");
105  return createProjFromAutoCode(split_line);
106  }
107 
108  // Strip commonly found or bar '|' from end if present.
109  ossimString s = spec;
110  s.trim(ossimString("|"));
111 
112  // Otherwise, pass along the request to the database object for record search:
114 }
ossimMapProjection * createProjFromAutoCode(const std::vector< ossimString > &spec) const
When the CRS is specified with the "AUTO:<spec>" code format, this method is invoked to parse the <sp...
static ossimEpsgProjectionDatabase * instance()
Instantiates singleton instance of this class:
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
ossimProjection * findProjection(const ossimString &proj_spec) const
Returns a projection corresponding to the projection specified, or NULL if no entry found...

◆ createProjection() [3/3]

ossimProjection * ossimEpsgProjectionFactory::createProjection ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Looks for presence of "pcs_code" keyword with the value in the format <group>:, for example "EPSG:32615" (EPSG and AUTO–see above– are presently supported).

From keywordlist.

If only an integer is specified, EPSG code is assumed.

Implements ossimProjectionFactoryBase.

Definition at line 48 of file ossimEpsgProjectionFactory.cpp.

References ossimKeywordlist::addList(), createProjection(), ossimString::empty(), ossimKeywordlist::find(), ossimProjection::loadState(), ossimKeywordNames::PCS_CODE_KW, ossimKeywordNames::PIXEL_SCALE_UNITS_KW, ossimKeywordNames::PIXEL_SCALE_XY_KW, ossimKeywordNames::PROJECTION_KW, ossimKeywordlist::remove(), ossimProjection::saveState(), ossimKeywordNames::TIE_POINT_UNITS_KW, and ossimKeywordNames::TIE_POINT_XY_KW.

50 {
51  ossimProjection* proj = 0;
52 
53  // Look for a PCS (Projected Coordinate System) code entry and construct the basic projection.
54  // This is the bootstrap for creating the fully-initialized proj:
55  ossimString proj_spec = keywordList.find(prefix, ossimKeywordNames::PCS_CODE_KW);
56  if(!proj_spec.empty())
57  proj = createProjection(proj_spec);
58 
59  if (!proj)
60  {
61  // An alternate way of specifying an EPSG projection is by its database name:
62  proj_spec = keywordList.find(prefix, ossimKeywordNames::PROJECTION_KW);
63  proj = createProjection(proj_spec);
64  }
65 
66  if (!proj)
67  return NULL;
68 
69  // The tie points and perhaps other params might still be in the KWL, so pass the KWL on to the
70  // new projection after it has been amended with the default proj info extracted from the
71  // EPSG code (i.e., sans tiepoints and gsd):
72  ossimKeywordlist proj_kwl;
73  proj->saveState(proj_kwl, prefix);
78  proj_kwl.addList(keywordList, false); // false: do not override existing items
79  proj->loadState(proj_kwl, prefix);
80 
81  return proj;
82 }
static const char * PROJECTION_KW
Represents serializable keyword/value map.
void addList(const ossimKeywordlist &src, bool overwrite=true)
static const char * PIXEL_SCALE_XY_KW
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
static const char * TIE_POINT_XY_KW
static const char * PCS_CODE_KW
bool empty() const
Definition: ossimString.h:411
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
STUB. Not implemented.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
void remove(const char *key)
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
Definition: ossimString.h:753
static const char * PIXEL_SCALE_UNITS_KW
static const char * TIE_POINT_UNITS_KW

◆ createProjFromAutoCode()

ossimMapProjection * ossimEpsgProjectionFactory::createProjFromAutoCode ( const std::vector< ossimString > &  spec) const
protected

When the CRS is specified with the "AUTO:<spec>" code format, this method is invoked to parse the <spec> and produce a projection (or NULL if spec invalid): This really shouldn't be in this class but nobody else is parsing for it, so leave it here for now.

When the CRS is specified with the "AUTO:<spec>" code format, this method is invoked to parse the <spec> and produce a projection (or NULL if spec invalid):

Definition at line 121 of file ossimEpsgProjectionFactory.cpp.

References ossimGpt::latd(), ossimGpt::lond(), ossimTransMercatorProjection::setFalseNorthing(), ossimUtmProjection::setHemisphere(), ossimUtmProjection::setOrigin(), ossimEquDistCylProjection::setOrigin(), ossimMapProjection::setOrigin(), ossimTransMercatorProjection::setScaleFactor(), ossimUtmProjection::setZone(), ossimUtmProjection::update(), ossimTransMercatorProjection::update(), ossimOrthoGraphicProjection::update(), and ossimEquDistCylProjection::update().

Referenced by createProjection().

122 {
123  if (spec.size() < 3)
124  return 0;
125 
126  ossim_uint32 code = spec[0].toUInt32();
127  ossimGpt origin (spec[2].toDouble(), spec[1].toDouble()) ;
128 
129  // Only a few AUTO codes are considered:
130  switch(code)
131  {
132  case 42001:
133  {
135  utm->setZone(origin);
136  utm->setHemisphere(origin);
137  utm->setOrigin(origin);
138  utm->update();
139  //utm->setPcsCode(42001);
140  return utm;
141  }
142 
143  case 42002:
144  {
146  transMerc->setFalseNorthing(origin.latd()>=0.0?0.0:10000000.0);
147  transMerc->setOrigin(ossimGpt(0.0, origin.lond()));
148  transMerc->setScaleFactor(.9996);
149  transMerc->update();
150  // transMerc->setPcsCode(42002);
151  return transMerc;
152  }
153 
154  case 42003:
155  {
157  ortho->setOrigin(origin);
158  ortho->update();
159  //ortho->setPcsCode(42003);
160  return ortho;
161  }
162 
163  case 42004:
164  {
166  geographic->setOrigin(origin);
167  geographic->update();
168  //geographic->setPcsCode(42004);
169  return geographic;
170  }
171  }
172  return 0;
173 }
virtual void setOrigin(const ossimGpt &origin)
Sets theOrigin to origin.
virtual void setOrigin(const ossimGpt &origin)
This will set the utm zone and utm origin base on origin passed in.
unsigned int ossim_uint32
void setFalseNorthing(double falseNorthing)
virtual void setOrigin(const ossimGpt &origin)
void setZone(const ossimGpt &ground)
void setHemisphere(const ossimGpt &ground)

◆ getTypeNameList()

void ossimEpsgProjectionFactory::getTypeNameList ( std::vector< ossimString > &  typeList) const
virtual

This returns the type name of all objects in all factories.

This is the name used to construct the objects dynamically and this name must be unique.

Implements ossimObjectFactory.

Definition at line 201 of file ossimEpsgProjectionFactory.cpp.

References ossimEpsgProjectionDatabase::getProjectionsList(), and ossimEpsgProjectionDatabase::instance().

202 {
204  return;
205 }
void getProjectionsList(std::vector< ossimString > &typeList) const
Populates caller&#39;s list with all projections currently represented in the database.
static ossimEpsgProjectionDatabase * instance()
Instantiates singleton instance of this class:

◆ instance()

ossimEpsgProjectionFactory * ossimEpsgProjectionFactory::instance ( )
static

Implements singleton pattern.

METHOD: instance() Instantiates singleton instance of this class:

Definition at line 27 of file ossimEpsgProjectionFactory.cpp.

Referenced by ossimPointCloudImageHandler::getImageGeometry(), ossimGpkgTileEntry::getNewMapProjection(), ossimGpkgWriter::getNewOutputProjection(), ossimTiffInfo::getPcsCode(), ossimFgdcXmlDoc::getProjection(), ossimGeoPdfReader::getVPGeoProjection(), ossimProjectionFactoryRegistry::initializeDefaults(), and ossimGeoTiff::parsePcsCode().

28 {
29  static ossimEpsgProjectionFactory inst;
30 
31  return &inst;
32 
33  //if(!m_instance)
34  // m_instance = new ossimEpsgProjectionFactory;
35  //return m_instance;
36 }
Projection Factory for coded projections defined in database.

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