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

#include <ossimNitfProjectionFactory.h>

Inheritance diagram for ossimNitfProjectionFactory:
ossimProjectionFactoryBase ossimObjectFactory ossimObject ossimReferenced

Public Member Functions

virtual ~ossimNitfProjectionFactory ()
 destructor More...
 
virtual ossimProjectioncreateProjection (const ossimFilename &filename, ossim_uint32 entryIdx) const
 
virtual ossimProjectioncreateProjection (const ossimString &name) const
 
virtual ossimProjectioncreateProjection (const ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual ossimProjectioncreateProjection (ossimImageHandler *handler) const
 
virtual ossimObjectcreateObject (const ossimString &typeName) const
 Creates an object given a type name. More...
 
virtual ossimObjectcreateObject (const ossimKeywordlist &kwl, const char *prefix=0) const
 Creates and object given a keyword list. More...
 
virtual void getTypeNameList (std::vector< ossimString > &typeList) const
 This should return the type name of all objects in all factories. More...
 
- 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 ossimNitfProjectionFactoryinstance ()
 METHOD: instance() More...
 

Private Member Functions

ossimProjectioncreateProjectionFromHeaders (ossimNitfFileHeader *fileHeader, ossimNitfImageHeader *imageHeader) const
 
ossimProjectionmakeGeographic (const ossimNitfImageHeader *hdr, const ossimString &coordinateSysetm) const
 
ossimProjectionmakeUtm (const ossimNitfImageHeader *hdr, const ossimString &coordinateSysetm) const
 
ossimProjectionmakeEuiDistant (const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
 
ossimProjectionmakeBilinear (const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
 
void parseGeographicString (const ossimString &geographicLocation, std::vector< ossimGpt > &gpts) const
 Parses geographic stream. More...
 
void parseDecimalDegreesString (const ossimString &geographicLocation, std::vector< ossimGpt > &gpts) const
 Parses Decimal degree stream. More...
 
void parseUtmString (const ossimString &utmLocation, ossim_uint32 &zone, std::vector< ossimDpt > &utmPoints) const
 
bool parseMgrsString (const ossimString &mgrsLocationString, ossim_uint32 &zone, char &hemisphere, std::vector< ossimDpt > &utmPoints) const
 Gets UTM points, zone and hemisphere from IGEOLO field when ICORDS files = U which is UTM expressed in MGRS. More...
 
void computeScaleInDecimalDegrees (const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts, ossimDpt &scale) const
 Computes the scale in decimal degrees with scale.x being longitude, y being latitude. More...
 
void computeScaleInMeters (const ossimNitfImageHeader *hdr, const std::vector< ossimDpt > &dpts, ossimDpt &scale) const
 Computes the scale in meters with scale.x being easting, y being northing. More...
 
bool isSkewed (const std::vector< ossimGpt > &gpts) const
 
bool isSkewed (const std::vector< ossimDpt > &gpts) const
 
bool getBlockaPoints (const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
 
bool getGeolobPoints (const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
 
 ossimNitfProjectionFactory ()
 Private constructor, users must go through instance() method. More...
 
 ossimNitfProjectionFactory (const ossimNitfProjectionFactory &obj)
 Private copy constructor to hide from use. More...
 
ossimNitfProjectionFactoryoperator= (const ossimNitfProjectionFactory &rhs)
 Private operator = to hide from use. More...
 
bool isNitf (const ossimFilename &filename) const
 

Static Private Attributes

static ossimNitfProjectionFactorytheInstance = 0
 

Additional Inherited Members

- 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

Definition at line 27 of file ossimNitfProjectionFactory.h.

Constructor & Destructor Documentation

◆ ~ossimNitfProjectionFactory()

ossimNitfProjectionFactory::~ossimNitfProjectionFactory ( )
virtual

destructor

Definition at line 41 of file ossimNitfProjectionFactory.cpp.

42 {
43 }

◆ ossimNitfProjectionFactory() [1/2]

ossimNitfProjectionFactory::ossimNitfProjectionFactory ( )
private

Private constructor, users must go through instance() method.

Definition at line 37 of file ossimNitfProjectionFactory.cpp.

Referenced by instance().

38 {
39 }

◆ ossimNitfProjectionFactory() [2/2]

ossimNitfProjectionFactory::ossimNitfProjectionFactory ( const ossimNitfProjectionFactory obj)
private

Private copy constructor to hide from use.

Definition at line 1113 of file ossimNitfProjectionFactory.cpp.

1114 {
1115 }

Member Function Documentation

◆ computeScaleInDecimalDegrees()

void ossimNitfProjectionFactory::computeScaleInDecimalDegrees ( const ossimNitfImageHeader hdr,
const std::vector< ossimGpt > &  gpts,
ossimDpt scale 
) const
private

Computes the scale in decimal degrees with scale.x being longitude, y being latitude.

Parameters
hdrThe nitf image header from the currently opened nitf file.
gptsFour geographic corner points.
scaleScale to initialize.
Note
scale will be set to nan's on failure.

Definition at line 828 of file ossimNitfProjectionFactory.cpp.

References ossimNitfImageHeader::getImageRect(), ossimIrect::height(), isSkewed(), ossimDpt::makeNan(), ossimIrect::width(), ossimDpt::x, and ossimDpt::y.

Referenced by makeEuiDistant().

832 {
833  if ( !hdr || isSkewed(gpts))
834  {
835  scale.makeNan();
836  return;
837  }
838  ossimIrect imageRect = hdr->getImageRect();
839 
840  //---
841  // Calculate the scale. This assumes that the corner points are for the
842  // edge of the corner pixels, not the center of the corner pixels.
843  //---
844  double longitudeSize = 0.0;
845  double latitudeSize = 0.0;
846  if ( (gpts[1].lond() < 0.0) && (gpts[0].lond() >= 0) )
847  {
848  //---
849  // Upper right negative(Western), upper left positive (Eastern).
850  // Crossing date line maybe???
851  //---
852  longitudeSize = (gpts[1].lond() + 360.0) - gpts[0].lond();
853  }
854  else
855  {
856  longitudeSize = gpts[1].lond() - gpts[0].lond();
857  }
858 
859  latitudeSize = gpts[0].latd() - gpts[2].latd();
860 
861  double rows = imageRect.height();
862  double cols = imageRect.width();
863 // double rows = hdr->getNumberOfRows();
864 // double cols = hdr->getNumberOfCols();
865 
866  if (!rows || !cols)
867  {
868  scale.makeNan();
869  return;
870  }
871  scale.y = latitudeSize / rows;
872  scale.x = longitudeSize / cols;
873 }
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimIrect getImageRect() const =0
ossim_uint32 width() const
Definition: ossimIrect.h:500
bool isSkewed(const std::vector< ossimGpt > &gpts) const
double x
Definition: ossimDpt.h:164
void makeNan()
Definition: ossimDpt.h:65

◆ computeScaleInMeters()

void ossimNitfProjectionFactory::computeScaleInMeters ( const ossimNitfImageHeader hdr,
const std::vector< ossimDpt > &  dpts,
ossimDpt scale 
) const
private

Computes the scale in meters with scale.x being easting, y being northing.

Parameters
hdrThe nitf image header from the currently opened nitf file.
dptsFour utm corner points.
scaleScale to initialize.
Note
scale will be set to nan's on failure.

Definition at line 875 of file ossimNitfProjectionFactory.cpp.

References ossimNitfImageHeader::getImageRect(), ossimIrect::height(), isSkewed(), ossimDpt::makeNan(), ossimIrect::width(), ossimDpt::x, x, ossimDpt::y, and y.

879 {
880  if ( !hdr || isSkewed(dpts))
881  {
882  scale.makeNan();
883  return;
884  }
885  ossimIrect imageRect = hdr->getImageRect();
886 
887  //---
888  // Calculate the scale. This assumes that the corner points are for the
889  // edge of the corner pixels, not the center of the corner pixels.
890  //---
891  double eastingSize = 0.0;
892  double northingSize = 0.0;
893 
894  eastingSize = fabs(dpts[1].x - dpts[0].x);
895  northingSize = fabs(dpts[0].y - dpts[3].y);
896 
897  double rows = imageRect.height();//hdr->getNumberOfRows();
898  double cols = imageRect.width();//hdr->getNumberOfCols();
899 
900  if (!rows || !cols)
901  {
902  scale.makeNan();
903  return;
904  }
905  scale.y = northingSize / rows;
906  scale.x = eastingSize / cols;
907 }
ossim_uint32 x
ossim_uint32 y
double y
Definition: ossimDpt.h:165
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimIrect getImageRect() const =0
ossim_uint32 width() const
Definition: ossimIrect.h:500
bool isSkewed(const std::vector< ossimGpt > &gpts) const
double x
Definition: ossimDpt.h:164
void makeNan()
Definition: ossimDpt.h:65

◆ createObject() [1/2]

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

Creates an object given a type name.

Returns
ossimObject on success or NULL if not handled.

Implements ossimObjectFactory.

Definition at line 130 of file ossimNitfProjectionFactory.cpp.

References createProjection().

131 {
132  return (ossimObject*)createProjection(typeName);
133 }
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const

◆ createObject() [2/2]

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

Creates and object given a keyword list.

Returns
ossimObject on success or NULL if not handled.

Implements ossimObjectFactory.

Definition at line 136 of file ossimNitfProjectionFactory.cpp.

References createProjection().

138 {
139  return createProjection(kwl, prefix);
140 }
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const

◆ createProjection() [1/4]

ossimProjection * ossimNitfProjectionFactory::createProjection ( const ossimFilename filename,
ossim_uint32  entryIdx 
) const
virtual
Parameters
filenameThis filename can be an image file or it can also be a ossim .geom file. It could be other forms of geom files as well. The factories job will be to determine what parser to use and return a projection if successful.
Returns
ossimProjection* on success or NULL if not handled.

Implements ossimProjectionFactoryBase.

Definition at line 56 of file ossimNitfProjectionFactory.cpp.

Referenced by createObject(), and createProjection().

58 {
59  static const char MODULE[]="ossimNitfProjectionFactory::createProjection";
60  if (traceDebug())
61  {
63  << MODULE << " DEBUG:"
64  << "\nfilename: " << filename
65  << "\nentryIdx: " << entryIdx
66  << std::endl;
67  }
68 
69  // See if there is an external geomtry.
70  ossimProjection* result = createProjectionFromGeometryFile(filename, entryIdx);
71  if (result)
72  {
73  return result;
74  }
75 
76  if(!isNitf(filename))
77  {
78  return result; // result is NULL
79  }
80 
82  if (!nitf->parseFile(filename))
83  {
84  return result; // result is NULL
85  }
86 
87  long imageIndex = static_cast<long>(entryIdx);
88  if ( imageIndex > (nitf->getHeader()->getNumberOfImages()-1) )
89  {
90  return result;
91  }
92 
93  ossimRefPtr<ossimNitfImageHeader> imageHeader = nitf->getNewImageHeader(imageIndex);
94  {
95  if (!imageHeader)
96  {
97  return result;
98  }
99  }
100 
101  result = createProjectionFromHeaders(nitf->getHeader(),
102  imageHeader.get());
103  if (traceDebug())
104  {
105  ossimString coordinateSystem = imageHeader->getCoordinateSystem();
107  << MODULE << " DEBUG:"
108  << "\ncoordinateSysetm: " << coordinateSystem
109  << std::endl;
110  }
111 
112  return result;
113 }
ossimProjection * createProjectionFromGeometryFile(const ossimFilename &imageFile, ossim_uint32 entryIdx) const
This method takes the filename and tries to find an external ".geom" file.
ossimNitfImageHeader * getNewImageHeader(ossim_uint32 imageNumber) const
virtual ossimString getCoordinateSystem() const =0
const ossimNitfFileHeader * getHeader() const
ossimProjection * createProjectionFromHeaders(ossimNitfFileHeader *fileHeader, ossimNitfImageHeader *imageHeader) const
bool isNitf(const ossimFilename &filename) const
bool parseFile(const ossimFilename &file)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossim_int32 getNumberOfImages() const =0

◆ createProjection() [2/4]

ossimProjection * ossimNitfProjectionFactory::createProjection ( const ossimString name) const
virtual
Parameters
nameThis would be a projection name.
Returns
ossimProjection* on success or NULL if not handled.

Implements ossimProjectionFactoryBase.

Definition at line 124 of file ossimNitfProjectionFactory.cpp.

125 {
126  return 0;
127 }

◆ createProjection() [3/4]

ossimProjection * ossimNitfProjectionFactory::createProjection ( const ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual
Parameters
kwlKeyword list to instantiate projection from.
Returns
ossimProjection* on success or NULL if not handled.

Implements ossimProjectionFactoryBase.

Definition at line 117 of file ossimNitfProjectionFactory.cpp.

119 {
120  return 0;
121 }

◆ createProjection() [4/4]

ossimProjection * ossimNitfProjectionFactory::createProjection ( ossimImageHandler handler) const
virtual

Reimplemented from ossimProjectionFactoryBase.

Definition at line 147 of file ossimNitfProjectionFactory.cpp.

References createProjection(), createProjectionFromHeaders(), ossimImageHandler::getCurrentEntry(), ossimNitfTileSource::getCurrentImageHeader(), ossimNitfTileSource::getFileHeader(), ossimImageHandler::getFilename(), and isNitf().

148 {
149  ossimNitfTileSource* nitfTileSource = dynamic_cast<ossimNitfTileSource*> (handler);
150  ossimProjection* result = 0;
151  if(nitfTileSource)
152  {
153  if(!result)
154  {
155  ossimNitfImageHeader* imageHeader = nitfTileSource->getCurrentImageHeader();
156  if(imageHeader)
157  {
158  result = createProjectionFromHeaders(nitfTileSource->getFileHeader(),imageHeader);
159  }
160  }
161  }
162  else if(isNitf(handler->getFilename()))
163  {
164  result = createProjection(handler->getFilename(), handler->getCurrentEntry());
165  }
166  return result;
167 }
virtual const ossimFilename & getFilename() const
Returns the filename.
virtual ossim_uint32 getCurrentEntry() const
ossimProjection * createProjectionFromHeaders(ossimNitfFileHeader *fileHeader, ossimNitfImageHeader *imageHeader) const
const ossimNitfImageHeader * getCurrentImageHeader() const
const ossimNitfFileHeader * getFileHeader() const
bool isNitf(const ossimFilename &filename) const
virtual ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const

◆ createProjectionFromHeaders()

ossimProjection * ossimNitfProjectionFactory::createProjectionFromHeaders ( ossimNitfFileHeader fileHeader,
ossimNitfImageHeader imageHeader 
) const
private

Definition at line 187 of file ossimNitfProjectionFactory.cpp.

References ossimNitfImageHeader::getCoordinateSystem(), ossimNitfFileHeader::getVersion(), makeGeographic(), and makeUtm().

Referenced by createProjection().

189 {
190  ossimProjection* result = 0;
191  ossimString version = fileHeader->getVersion();
192  ossimString coordinateSystem = imageHeader->getCoordinateSystem();
193 
194  // Note in version 2.0 ICORDS with 'N' == NONE. In 2.1 it is UTM North:
195  if (coordinateSystem == "G" || coordinateSystem == "D")
196  {
197  result = makeGeographic(imageHeader, coordinateSystem);
198  }
199  else if( (coordinateSystem == "S") || (coordinateSystem == "U") ||
200  ( version != "02.00" && (coordinateSystem == "N") ) )
201  {
202  result = makeUtm(imageHeader, coordinateSystem);
203  }
204  return result;
205 }
virtual const char * getVersion() const =0
virtual ossimString getCoordinateSystem() const =0
ossimProjection * makeGeographic(const ossimNitfImageHeader *hdr, const ossimString &coordinateSysetm) const
ossimProjection * makeUtm(const ossimNitfImageHeader *hdr, const ossimString &coordinateSysetm) const

◆ getBlockaPoints()

bool ossimNitfProjectionFactory::getBlockaPoints ( const ossimNitfImageHeader hdr,
std::vector< ossimGpt > &  gpts 
) const
private
Parameters
hdrThe nitf image header from the currently opened nitf file.
gptsGround points to initialize from BLOCKA tag. This should be an empty vector.
Returns
true if BLOCKA tag was parsed.

Definition at line 670 of file ossimNitfProjectionFactory.cpp.

References ossimNitfImageHeader::getTagData().

Referenced by makeGeographic().

673 {
674  if (!hdr)
675  {
676  return false;
677  }
678 
680  hdr->getTagData(ossimString("BLOCKA"));
681 
682  if (!tag)
683  {
684  if (traceDebug())
685  {
687  << "ossimNitfProjectionFactory::getBlockaPoints DEBUG:"
688  << "\nBLOCKA tag not found."
689  << std::endl;
690  }
691  return false;
692  }
693 
694  if (gpts.size())
695  {
696  gpts.clear();
697  }
698 
699  ossimNitfBlockaTag* blockaTag = PTR_CAST(ossimNitfBlockaTag, tag.get());
700  if (!blockaTag)
701  {
702  return false;
703  }
704 
705  ossimDpt dpt;
706  ossimGpt gpt;
707 
708  // Get the upper left or first row first column.
709  blockaTag->getFrfcLoc(dpt);
710  gpt.latd(dpt.y);
711  gpt.lond(dpt.x);
712  gpts.push_back(gpt);
713 
714  // Get the upper right or first row last column.
715  blockaTag->getFrlcLoc(dpt);
716  gpt.latd(dpt.y);
717  gpt.lond(dpt.x);
718  gpts.push_back(gpt);
719 
720  // Get the lower right or last row last column.
721  blockaTag->getLrlcLoc(dpt);
722  gpt.latd(dpt.y);
723  gpt.lond(dpt.x);
724  gpts.push_back(gpt);
725 
726  // Get the lower left or last row first column.
727  blockaTag->getLrfcLoc(dpt);
728  gpt.latd(dpt.y);
729  gpt.lond(dpt.x);
730  gpts.push_back(gpt);
731 
732  if (traceDebug())
733  {
735  << "ossimNitfProjectionFactory::getBlockaPoints DEBUG:"
736  << std::endl;
737  for (int i=0; i<4; ++i)
738  {
740  << "gpt[" << i << "] " << gpts[i] << std::endl;
741  }
742  }
743 
744  return true;
745 }
ossimString getFrlcLoc() const
ossimString getFrfcLoc() const
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
double y
Definition: ossimDpt.h:165
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
ossimString getLrfcLoc() const
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
ossimString getLrlcLoc() const
double x
Definition: ossimDpt.h:164
ossimRefPtr< ossimNitfRegisteredTag > getTagData(const ossimString &tagName)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getGeolobPoints()

bool ossimNitfProjectionFactory::getGeolobPoints ( const ossimNitfImageHeader hdr,
std::vector< ossimGpt > &  gpts 
) const
private
Parameters
hdrThe nitf image header from the currently opened nitf file.
gptsGround points to initialize from GEOLOB tag. This should be an empty vector.
Returns
true if GEOLOB tag was parsed.

Definition at line 747 of file ossimNitfProjectionFactory.cpp.

Referenced by makeGeographic().

750 {
751  static const char MODULE[] = "ossimNitfProjectionFactory::getGeolobPoints";
752  if (traceDebug())
753  {
755  << MODULE << " entered...\n";
756  }
757  bool result = false;
758 
759  gpts.clear();
760 
761  if ( hdr )
762  {
764  if ( tag.valid() )
765  {
766  ossimNitfGeolobTag* geolob = dynamic_cast<ossimNitfGeolobTag*>(tag.get());
767  if ( geolob )
768  {
769  ossimDpt gsd( geolob->getDegreesPerPixelLon(), geolob->getDegreesPerPixelLat() );
770  if ( (gsd.x > 0.0 ) && (gsd.y > 0.0) )
771  {
772  ossim_int32 rows = hdr->getNumberOfRows();
773  ossim_int32 cols = hdr->getNumberOfCols();
774  if ( (rows > 0) && (cols > 0) )
775  {
776  ossimGpt gpt(0.0, 0.0, 0.0);
777  ossimDpt origin( geolob->getLso(), geolob->getPso() );
778 
779  if (traceDebug())
780  {
782  << "origin: " << origin
783  << "\ngsd: " << gsd << "\n";
784  }
785 
786  // Note: Edge to edge here as origin is shifted makeEuiDistant method.
787  // UL:
788  gpt.latd(origin.y);
789  gpt.lond(origin.x);
790  gpts.push_back(gpt);
791 
792  // UR:
793  gpt.latd(origin.y);
794  gpt.lond(origin.x + cols*gsd.x);
795  gpts.push_back(gpt);
796 
797  // LR:
798  gpt.latd(origin.y - rows*gsd.y);
799  gpt.lond(origin.x + cols*gsd.x);
800  gpts.push_back(gpt);
801 
802  // LL:
803  gpt.latd(origin.y - rows*gsd.y);
804  gpt.lond(origin.x);
805  gpts.push_back(gpt);
806 
807  result = true;
808  }
809  }
810  }
811  }
812  else if (traceDebug())
813  {
815  << "No GEOLOB tag found.\n";
816  }
817  }
818 
819  if (traceDebug())
820  {
822  << MODULE << " exit status: " << (result?"true":"false") << "\n";
823  }
824 
825  return result;
826 }
virtual ossim_int32 getNumberOfRows() const =0
ossim_float64 getDegreesPerPixelLon() const
Gets degrees per pixel in lonitude direction from BRV field.
bool valid() const
Definition: ossimRefPtr.h:75
ossim_float64 getPso() const
Gets the PSO field(Latitude Origin).
virtual ossim_int32 getNumberOfCols() const =0
ossim_float64 getLso() const
Gets the LSO field(Longitude Origin).
ossimRefPtr< ossimNitfRegisteredTag > getTagData(const ossimString &tagName)
ossim_float64 getDegreesPerPixelLat() const
Gets degrees per pixel in latitude direction from BRV field.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ getTypeNameList()

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

This should return the type name of all objects in all factories.

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

Parameters
typeListList to append names to.

Implements ossimObjectFactory.

Definition at line 142 of file ossimNitfProjectionFactory.cpp.

143 {
144 
145 }

◆ instance()

ossimNitfProjectionFactory * ossimNitfProjectionFactory::instance ( )
static

METHOD: instance()

Returns
Singleton instance of this class.

Definition at line 45 of file ossimNitfProjectionFactory.cpp.

References ossimNitfProjectionFactory(), and theInstance.

Referenced by ossimProjectionFactoryRegistry::initializeDefaults().

46 {
47  if(!theInstance)
48  {
50  }
51 
52  return theInstance;
53 }
static ossimNitfProjectionFactory * theInstance
ossimNitfProjectionFactory()
Private constructor, users must go through instance() method.

◆ isNitf()

bool ossimNitfProjectionFactory::isNitf ( const ossimFilename filename) const
private

Definition at line 169 of file ossimNitfProjectionFactory.cpp.

References ossimString::c_str().

Referenced by createProjection().

170 {
171  std::ifstream in(filename.c_str(), ios::in|ios::binary);
172 
173  if(in)
174  {
175  char nitfFile[4];
176  in.read((char*)nitfFile, 4);
177  ossimString s(nitfFile, nitfFile+4);
178  if ( (s == "NITF") || (s == "NSIF") )
179  {
180  return true;
181  }
182  }
183 
184  return false;
185 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
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

◆ isSkewed() [1/2]

bool ossimNitfProjectionFactory::isSkewed ( const std::vector< ossimGpt > &  gpts) const
private
Returns
true if corner points are parallel to each other, else false.

Definition at line 649 of file ossimNitfProjectionFactory.cpp.

Referenced by computeScaleInDecimalDegrees(), and computeScaleInMeters().

651 {
652 
653  return !( (gpts[0].latd() == gpts[1].latd()) &&
654  (gpts[2].latd() == gpts[3].latd()) &&
655  (gpts[0].lond() == gpts[3].lond()) &&
656  (gpts[1].lond() == gpts[2].lond()) );
657 
658 }

◆ isSkewed() [2/2]

bool ossimNitfProjectionFactory::isSkewed ( const std::vector< ossimDpt > &  gpts) const
private
Returns
true if corner points are parallel to each other, else false.

Definition at line 660 of file ossimNitfProjectionFactory.cpp.

References x, and y.

662 {
663  return !( (dpts[0].y == dpts[1].y) &&
664  (dpts[2].y == dpts[3].y) &&
665  (dpts[0].x == dpts[3].x) &&
666  (dpts[1].x == dpts[2].x) );
667 
668 }
ossim_uint32 x
ossim_uint32 y

◆ makeBilinear()

ossimProjection * ossimNitfProjectionFactory::makeBilinear ( const ossimNitfImageHeader hdr,
const std::vector< ossimGpt > &  gpts 
) const
private
Returns
ossimBilinearProjection* or null if a problem is found.

Definition at line 617 of file ossimNitfProjectionFactory.cpp.

References ossimNitfImageHeader::getNumberOfCols(), ossimNitfImageHeader::getNumberOfRows(), and ossimRefPtr< T >::release().

620 {
621  double rows = hdr->getNumberOfRows();
622  double cols = hdr->getNumberOfCols();
623 
624  ossimDpt ul(0.0, 0.0);
625  ossimDpt ur(cols-1.0, 0.0);
626  ossimDpt lr(cols-1.0, rows-1.0);
627  ossimDpt ll(0.0, rows-1.0);
628 
630  try
631  {
632  proj = new ossimBilinearProjection(ul,
633  ur,
634  lr,
635  ll,
636  gpts[0],
637  gpts[1],
638  gpts[2],
639  gpts[3]);
640  }
641  catch(...)
642  {
643  proj = 0;
644  }
645 
646  return proj.release();
647 }
virtual ossim_int32 getNumberOfRows() const =0
virtual ossim_int32 getNumberOfCols() const =0
T * release()
Definition: ossimRefPtr.h:93

◆ makeEuiDistant()

ossimProjection * ossimNitfProjectionFactory::makeEuiDistant ( const ossimNitfImageHeader hdr,
const std::vector< ossimGpt > &  gpts 
) const
private
Parameters
hdrThe nitf image header.
gptsFour geographic corner points.
Returns
ossimEquDistCylProjection* or null if a problem is found.

Definition at line 570 of file ossimNitfProjectionFactory.cpp.

References ossim::acosd(), computeScaleInDecimalDegrees(), ossimMapProjection::getOrigin(), ossimDpt::hasNans(), ossimGpt::lat, ossimGpt::latd(), ossimGpt::lond(), ossimMapProjection::setDecimalDegreesPerPixel(), ossimEquDistCylProjection::setOrigin(), ossimMapProjection::setUlTiePoints(), ossimDpt::x, x, and ossimDpt::y.

573 {
574  ossimEquDistCylProjection* proj = 0;
575 
576  // Get the scale.
577  ossimDpt scale;
578  computeScaleInDecimalDegrees(hdr, gpts, scale);
579 
580  if (scale.hasNans())
581  {
582  return proj;
583  }
584  // Make the projection.
585  proj = new ossimEquDistCylProjection();
586 
587  if ( scale.x )
588  {
589  ossimGpt origin = proj->getOrigin();
590 
591  //---
592  // ossimEquDistCylProjection uses the origin_latitude for meters per pixel (gsd)
593  // computation. So is not set in tiff tags, compute to achieve the proper
594  // horizontal scaling.
595  //---
596  ossim_float64 x = (scale.y/scale.x);
597  if ( x > 1.0 ) x = 1.0; // Limit to domain of arc cosine function.
598  origin.lat = ossim::acosd(x);
599 
600  proj->setOrigin(origin);
601  }
602 
603  // Shift the tie to the center of the pixel.
604  ossimGpt tiePoint;
605  tiePoint.latd(gpts[0].latd() - (scale.y/2.0));
606  tiePoint.lond(gpts[0].lond() + (scale.x/2.0));
607 
608  // Set the tie points.
609  proj->setUlTiePoints(tiePoint);
610 
611  // Set the scale.
612  proj->setDecimalDegreesPerPixel(scale);
613 
614  return proj;
615 }
ossim_uint32 x
void computeScaleInDecimalDegrees(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts, ossimDpt &scale) const
Computes the scale in decimal degrees with scale.x being longitude, y being latitude.
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
double y
Definition: ossimDpt.h:165
double acosd(double x)
Definition: ossimCommon.h:264
virtual void setDecimalDegreesPerPixel(const ossimDpt &gsd)
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
double ossim_float64
virtual void setOrigin(const ossimGpt &origin)
bool hasNans() const
Definition: ossimDpt.h:67
const ossimGpt & getOrigin() const
double x
Definition: ossimDpt.h:164
virtual void setUlTiePoints(const ossimGpt &gpt)
ossim_float64 lat
Definition: ossimGpt.h:265

◆ makeGeographic()

ossimProjection * ossimNitfProjectionFactory::makeGeographic ( const ossimNitfImageHeader hdr,
const ossimString coordinateSysetm 
) const
private
Parameters
hdrThe nitf image header.
coordianteSystemThe coordinate system as a string.
geographicLocationThis should contain the four corner strings.
Returns
Either an ossimEquDistCylProjection or ossimBilinearProjection depending upon if the corner points line up evenly.

Definition at line 207 of file ossimNitfProjectionFactory.cpp.

References getBlockaPoints(), ossimNitfImageHeader::getGeographicLocation(), getGeolobPoints(), and ossimString::size().

Referenced by createProjectionFromHeaders().

210 {
211  ossimProjection* proj = 0;
212 
213  if (hdr)
214  {
215  // To hold corner points.
216  std::vector<ossimGpt> gpts(0);
217  std::vector<ossimGpt> geolobPts(0);
218  std::vector<ossimGpt> blockaPts(0);
219  std::vector<ossimGpt> igeoloPts(0);
220 
221  //---
222  // Look for points from the GEOLOB tag if geographic coordinate
223  // system. This has an origin and scale with good precision.
224  //
225  // NOTES:
226  // 1) More precise than the BLOCKA
227  // 2) Making an assumption this is not present if rotated.
228  // Might need to test for rotation in BLOCKA and IGEOLO
229  // 3) GEOLOB points are always rectangular as they are derived
230  // from a single origin.
231  //---
232  getGeolobPoints(hdr, geolobPts);
233 
234  //---
235  // Look for points from the BLOCKA tag. This may or may not be present.
236  // If present since it has six digit precision use it for the points.
237  //---
238  getBlockaPoints(hdr, blockaPts);
239 
240  if ( blockaPts.empty() )
241  {
242  // Least precise IGEOLO field:
243  ossimString geographicLocation = hdr->getGeographicLocation();
244  if ( geographicLocation.size() )
245  {
246  if (traceDebug())
247  {
249  << "ossimNitfProjectionFactory::makeGeographic DEBUG:"
250  << "\ngeographicLocation: " << geographicLocation
251  << std::endl;
252  }
253 
254  if (coordinateSysetm == "G")
255  {
256  //---
257  // If coord system is G then format is:
258  // Lat = ddmmssX
259  // where d is degrees and m is minutes
260  // and s is seconds and X is either N (North) or S (South).
261  // Lon = dddmmssX
262  // where d is degrees and m is minutes
263  // and s is seconds and X is either N (North) or S (South).
264  //---
265  parseGeographicString(geographicLocation, igeoloPts);
266  }
267  else if (coordinateSysetm == "D")
268  {
269  //---
270  // If coor system is D then format is:
271  // +-dd.ddd +-dd.ddd four times where + is northern hemispher and
272  // - is souther hemisphere for lat and longitude
273  // + is easting and - is westing.
274  //---
275  parseDecimalDegreesString(geographicLocation, igeoloPts);
276  }
277 
278  } // matches: if ( geographicLocation.size() )
279 
280  } // matches: if ( getBlockaPoints(hdr, gpts) == false )
281 
282  bool isSkewedFlag = false;
283  if ( blockaPts.size() )
284  {
285  isSkewedFlag = isSkewed(blockaPts);
286  if ( (isSkewedFlag == false) && geolobPts.size() )
287  {
288  gpts = geolobPts; // Not skewed and have more accurate geolob points.
289  }
290  else
291  {
292  gpts = blockaPts;
293  }
294  }
295  else if ( igeoloPts.size() )
296  {
297  isSkewedFlag = isSkewed(igeoloPts);
298  if ( (isSkewedFlag == false) && geolobPts.size() )
299  {
300  gpts = geolobPts; // Not skewed and have more accurate geolob points.
301  }
302  else
303  {
304  gpts = igeoloPts;
305  }
306  }
307 
308  if (gpts.size() == 4)
309  {
310  ossimDpt scaleTest;
311  computeScaleInDecimalDegrees(hdr, gpts, scaleTest);
312 
313  //---
314  // Getting very small value above 1.0 when dividing; hence the .000001.
315  // Code calling arc cosine function in makeEquDistant(...) clamps to 1.0.
316  //---
317  if ( !isSkewedFlag && (ossim::abs(scaleTest.y/scaleTest.x) <= 1.000001))
318  {
319  proj = makeEuiDistant(hdr, gpts);
320  }
321  else
322  {
323  // Image is rotated. Make a Bilinear.
324  proj = makeBilinear(hdr, gpts);
325  }
326  }
327 
328  if (traceDebug() && proj)
329  {
331  << "ossimNitfProjectionFactory::makeGeographic DEBUG:"
332  << "\nUpper left corner: " << gpts[0]
333  << "\nUpper right corner: " << gpts[1]
334  << "\nLower right corner: " << gpts[2]
335  << "\nLower left corner: " << gpts[3] << "\n";
337  }
338 
339  } // matches: if (hdr)
340 
341  return proj;
342 }
void computeScaleInDecimalDegrees(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts, ossimDpt &scale) const
Computes the scale in decimal degrees with scale.x being longitude, y being latitude.
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
double y
Definition: ossimDpt.h:165
ossimProjection * makeBilinear(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
T abs(const T &value)
Definition: ossimCommon.h:138
ossimProjection * makeEuiDistant(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
std::string::size_type size() const
Definition: ossimString.h:405
virtual ossimString getGeographicLocation() const =0
bool getGeolobPoints(const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
void parseDecimalDegreesString(const ossimString &geographicLocation, std::vector< ossimGpt > &gpts) const
Parses Decimal degree stream.
bool isSkewed(const std::vector< ossimGpt > &gpts) const
double x
Definition: ossimDpt.h:164
bool getBlockaPoints(const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
void parseGeographicString(const ossimString &geographicLocation, std::vector< ossimGpt > &gpts) const
Parses geographic stream.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ makeUtm()

ossimProjection * ossimNitfProjectionFactory::makeUtm ( const ossimNitfImageHeader hdr,
const ossimString coordinateSysetm 
) const
private
Parameters
hdrThe nitf image header.
coordianteSystemThe coordinate system as a string.
geographicLocationThis should contain the four corner strings.
Returns
ossimUtmProjection

Definition at line 344 of file ossimNitfProjectionFactory.cpp.

References ossimNitfImageHeader::getGeographicLocation(), parseMgrsString(), parseUtmString(), ossimString::size(), and status.

Referenced by createProjectionFromHeaders().

347 {
348  ossimProjection* proj = 0;
349  bool isBilinear = false;
350  if (hdr)
351  {
352  ossimString geographicLocation = hdr->getGeographicLocation();
353 
354  if ( geographicLocation.size() )
355  {
356  std::vector<ossimDpt> utmPoints;
357  ossim_uint32 zone;
358  ossimDpt scale;
359  char hemisphere = 'N';
360 
361  bool status = true;
362  if ( coordinateSystem == "U")
363  {
364  // Sets zone, hemisphere and utmPoints. Returns true on success.
365  status = parseMgrsString(geographicLocation, zone, hemisphere, utmPoints);
366  }
367  else
368  {
369  // Sets zone and utmPoints. Void return...
370  parseUtmString(geographicLocation, zone, utmPoints);
371  if(coordinateSystem == "S")
372  {
373  hemisphere = 'S';
374  }
375  }
376 
377  if ( status )
378  {
379  if ( traceDebug() )
380  {
381  std::string s;
382  s.push_back(hemisphere);
384  << "ossimNitfProjectionFactory::makeUtm DEBUG"
385  << "\ngeo string: " << geographicLocation
386  << "\nutm zone: " << zone
387  << "\nhemisphere: " << hemisphere
388  << std::endl;
389  for (ossim_uint32 i=0; i<utmPoints.size(); ++i)
390  {
392  << "utmPoints[" << utmPoints[i] << std::endl;
393  }
394  }
395 
397  uproj->setHemisphere(hemisphere);
398  uproj->setZone(zone);
399 
400  if(isSkewed(utmPoints))
401  {
402  std::vector<ossimGpt> gpts;
403 
404  // Try blocka points first as they are more accurate.
405  if ( getBlockaPoints(hdr, gpts) == false )
406  {
407  ossimGpt ul = uproj->inverse(utmPoints[0]);
408  ossimGpt ur = uproj->inverse(utmPoints[1]);
409  ossimGpt lr = uproj->inverse(utmPoints[2]);
410  ossimGpt ll = uproj->inverse(utmPoints[3]);
411  gpts.push_back(ul);
412  gpts.push_back(ur);
413  gpts.push_back(lr);
414  gpts.push_back(ll);
415  }
416 
417  //---
418  // Make a bilinear either from our skewed utm points or the points from the blocka
419  // tag.
420  //---
421  proj = makeBilinear(hdr, gpts);
422  if(proj) scale = proj->getMetersPerPixel();
423  isBilinear = true;
424  uproj = 0; // Done with utm projeciton
425 
426  }
427  else
428  {
429  computeScaleInMeters(hdr, utmPoints, scale);
430 
431  //---
432  // Assign our projection to the return "proj".
433  // Use ossimRefPtr::release the so we don't delete proj when uproj
434  // goes out of scope.
435  //---
436  proj = uproj.release();
437  }
438 
439  if( (scale.hasNans() == false)&&(!isBilinear) )
440  {
441  //---
442  // Get the tie point.
443  //
444  // Look for the the BLOCKA tag which may or may not be present.
445  // This has six digit precision in decimal degrees which equates to
446  // about 0.11 meters (at equator) as compared to 1.0 accuaracy of the
447  // IGEOLO field.
448  //---
449  ossimDpt tie;
450  std::vector<ossimGpt> gpts;
451  if ( getBlockaPoints(hdr, gpts) )
452  {
453  if (traceDebug())
454  {
456  << "ossimNitfProjectionFactory::makeUtm DEBUG:"
457  << "\nTie point from blocka: " << gpts[0]
458  << endl;
459  }
460 
461  tie = proj->forward(gpts[0]);
462  tie.x += scale.x/2.0;
463  tie.y -= scale.y/2.0;
464  }
465  else
466  {
467  tie.x = utmPoints[0].x + scale.x/2.0;
468  tie.y = utmPoints[0].y - scale.y/2.0;
469  }
470 
471  if (traceDebug())
472  {
474  << "ossimNitfProjectionFactory::makeUtm DEBUG:"
475  << "\nTie point: " << tie
476  << "\nScale: " << scale
477  << endl;
478  }
479 
480  // Set the tie and scale.
481  ossimMapProjection* mproj = dynamic_cast<ossimMapProjection*>(proj);
482  if ( mproj )
483  {
484  mproj->setUlEastingNorthing(tie);
485  mproj->setMetersPerPixel(scale);
486  }
487  else // cannot cast
488  {
489  if ( proj )
490  {
491  delete proj;
492  proj = 0;
493  }
494  }
495  }
496  else if(isBilinear)
497  {
498  // blank
499  }
500  else // Scale has nans
501  {
502  if ( proj )
503  {
504  delete proj;
505  proj = 0;
506  }
507  }
508 
509  } // matches: if (status)
510 
511  } // matches: if ( geographicLocation.size() )
512 
513  } // matches: if (hdr)
514 
515  return proj;
516 }
virtual ossimGpt inverse(const ossimDpt &eastingNorthing) const
Will take a point in meters and convert it to ground.
void parseUtmString(const ossimString &utmLocation, ossim_uint32 &zone, std::vector< ossimDpt > &utmPoints) const
double y
Definition: ossimDpt.h:165
ossimProjection * makeBilinear(const ossimNitfImageHeader *hdr, const std::vector< ossimGpt > &gpts) const
virtual void setMetersPerPixel(const ossimDpt &gsd)
bool parseMgrsString(const ossimString &mgrsLocationString, ossim_uint32 &zone, char &hemisphere, std::vector< ossimDpt > &utmPoints) const
Gets UTM points, zone and hemisphere from IGEOLO field when ICORDS files = U which is UTM expressed i...
virtual void setUlEastingNorthing(const ossimDpt &ulEastingNorthing)
std::string::size_type size() const
Definition: ossimString.h:405
virtual ossimDpt getMetersPerPixel() const =0
unsigned int ossim_uint32
T * release()
Definition: ossimRefPtr.h:93
virtual ossimString getGeographicLocation() const =0
void computeScaleInMeters(const ossimNitfImageHeader *hdr, const std::vector< ossimDpt > &dpts, ossimDpt &scale) const
Computes the scale in meters with scale.x being easting, y being northing.
bool hasNans() const
Definition: ossimDpt.h:67
void setZone(const ossimGpt &ground)
return status
virtual ossimDpt forward(const ossimGpt &wp) const
bool isSkewed(const std::vector< ossimGpt > &gpts) const
double x
Definition: ossimDpt.h:164
bool getBlockaPoints(const ossimNitfImageHeader *hdr, std::vector< ossimGpt > &gpts) const
void setHemisphere(const ossimGpt &ground)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ operator=()

ossimNitfProjectionFactory & ossimNitfProjectionFactory::operator= ( const ossimNitfProjectionFactory rhs)
private

Private operator = to hide from use.

Definition at line 1117 of file ossimNitfProjectionFactory.cpp.

1118 {
1119  return *this;
1120 }

◆ parseDecimalDegreesString()

void ossimNitfProjectionFactory::parseDecimalDegreesString ( const ossimString geographicLocation,
std::vector< ossimGpt > &  gpts 
) const
private

Parses Decimal degree stream.

This will initialize the vector of ossimGpt's with the four corners. If the string geographicLocation is not the correct size the vector will be cleared.

Parameters
geographicLocationString containing corners.
gptsVector to initialize.

Definition at line 1066 of file ossimNitfProjectionFactory.cpp.

References ossimString::c_str(), and ossimString::toDouble().

1068 {
1069  const char* bufPtr = geographicLocation.c_str();
1070 
1071 
1072  ossimString ulLat(bufPtr,
1073  bufPtr + 7);
1074  bufPtr+=7;
1075  ossimString ulLon(bufPtr,
1076  bufPtr+8);
1077  bufPtr+=8;
1078  ossimString urLat(bufPtr,
1079  bufPtr + 7);
1080  bufPtr+=7;
1081  ossimString urLon(bufPtr,
1082  bufPtr+8);
1083  bufPtr+=8;
1084  ossimString lrLat(bufPtr,
1085  bufPtr + 7);
1086  bufPtr+=7;
1087  ossimString lrLon(bufPtr,
1088  bufPtr+8);
1089  bufPtr+=8;
1090  ossimString llLat(bufPtr,
1091  bufPtr + 7);
1092  bufPtr+=7;
1093  ossimString llLon(bufPtr,
1094  bufPtr+8);
1095 
1096  gpts.push_back(ossimGpt(ulLat.toDouble(), ulLon.toDouble()));
1097  gpts.push_back(ossimGpt(urLat.toDouble(), urLon.toDouble()));
1098  gpts.push_back(ossimGpt(lrLat.toDouble(), lrLon.toDouble()));
1099  gpts.push_back(ossimGpt(llLat.toDouble(), llLon.toDouble()));
1100 
1101  if (traceDebug())
1102  {
1104  << "ossimNitfProjectionFactory::parseDecimalDegreesString DEBUG:"
1105  << "\nground point[" << 0 << "]: " << gpts[0]
1106  << "\nground point[" << 1 << "]: " << gpts[1]
1107  << "\nground point[" << 2 << "]: " << gpts[2]
1108  << "\nground point[" << 3 << "]: " << gpts[3]
1109  << std::endl;
1110  }
1111 }
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
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ parseGeographicString()

void ossimNitfProjectionFactory::parseGeographicString ( const ossimString geographicLocation,
std::vector< ossimGpt > &  gpts 
) const
private

Parses geographic stream.

This will initialize the vector of ossimGpt's with the four corners. If the string geographicLocation is not the correct size the vector will be cleared.

Parameters
geographicLocationString containing corners.
gptsVector to initialize.

Definition at line 972 of file ossimNitfProjectionFactory.cpp.

References ossimString::c_str(), ossimDms::getDegrees(), ossimGpt::latd(), ossimGpt::lond(), ossimDms::setDegrees(), ossimDms::setLatFlag(), ossimString::size(), and SPACE.

974 {
975  gpts.clear();
976 
977  if (geographicLocation.size() != 60)
978  {
979  return;
980  }
981 
982  std::string::size_type geo_index = 0;
983  for (int i=0; i<4; ++i)
984  {
985  //---
986  // We have to split up the geographicLocation string for the dms class.
987  //
988  // geographicLocation = ddmmssXdddmmssX (four times).
989  // "dd mm ss X" has a string length of 10
990  // "ddd mm ss X" has a string length of 11
991  //---
992  std::string::size_type lat_index = 0;
993  std::string::size_type lon_index = 0;
994  const char SPACE = ' ';
995  ossimString latString(10, SPACE);
996  ossimString lonString(11, SPACE);
997 
998  // degrees latitude
999  latString[lat_index++] = geographicLocation[geo_index++];
1000  latString[lat_index++] = geographicLocation[geo_index++];
1001  ++lat_index;
1002 
1003  // minutes latitude
1004  latString[lat_index++] = geographicLocation[geo_index++];
1005  latString[lat_index++] = geographicLocation[geo_index++];
1006  ++lat_index;
1007 
1008  // seconds latitude
1009  latString[lat_index++] = geographicLocation[geo_index++];
1010  latString[lat_index++] = geographicLocation[geo_index++];
1011  ++lat_index;
1012 
1013  // hemisphere
1014  latString[lat_index++] = geographicLocation[geo_index++];
1015 
1016  // degrees longitude
1017  lonString[lon_index++] = geographicLocation[geo_index++];
1018  lonString[lon_index++] = geographicLocation[geo_index++];
1019  lonString[lon_index++] = geographicLocation[geo_index++];
1020  ++lon_index;
1021 
1022  // minutes longitude
1023  lonString[lon_index++] = geographicLocation[geo_index++];
1024  lonString[lon_index++] = geographicLocation[geo_index++];
1025  ++lon_index;
1026 
1027  // seconds longitude
1028  lonString[lon_index++] = geographicLocation[geo_index++];
1029  lonString[lon_index++] = geographicLocation[geo_index++];
1030  ++lon_index;
1031 
1032  // hemisphere
1033  lonString[lon_index++] = geographicLocation[geo_index++];
1034 
1035  // Convert to decimal degrees using the dms class.
1036  ossimGpt gpt;
1037  ossimDms dms(0.0);
1038  dms.setLatFlag(true);
1039  if ( ! dms.setDegrees(latString.c_str()) )
1040  {
1041  gpts.clear();
1042  return;
1043  }
1044  gpt.latd(dms.getDegrees());
1045 
1046  dms.setLatFlag(false);
1047  if ( ! dms.setDegrees(lonString.c_str()) )
1048  {
1049  gpts.clear();
1050  return;
1051  }
1052  gpt.lond(dms.getDegrees());
1053 
1054  gpts.push_back(gpt);
1055 
1056  if (traceDebug())
1057  {
1059  << "ossimNitfProjectionFactory::parseGeographicString DEBUG:"
1060  << "\nground point[" << i << "]: " << gpt
1061  << std::endl;
1062  }
1063  }
1064 }
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
#define SPACE
Definition: vpfio.h:25
std::string::size_type size() const
Definition: ossimString.h:405
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ parseMgrsString()

bool ossimNitfProjectionFactory::parseMgrsString ( const ossimString mgrsLocationString,
ossim_uint32 zone,
char &  hemisphere,
std::vector< ossimDpt > &  utmPoints 
) const
private

Gets UTM points, zone and hemisphere from IGEOLO field when ICORDS files = U which is UTM expressed in MGRS.

Parameters
mgrsLocationStringString from IGEOLO field.
zoneInitialized in method.
hemisphereInitialized in method.
utmPointsInitialized in method.
Returns
True on success, false on error.

Definition at line 518 of file ossimNitfProjectionFactory.cpp.

References Convert_OSSIM_MGRS_To_UTM(), n, ossimString::size(), and ossimString::substr().

Referenced by makeUtm().

522 {
523  bool result = false; // Start false.
524 
525  //---
526  // From spec:
527  // UTM expressed in MGRS use the format zzBJKeeeeennnnn (15 characters).
528  // Assumption Zone and hemisphere same for all corners.
529  //---
530  if ( mgrsLocationString.size() >= 60 )
531  {
532  // Split the location string into four separate ones.
533  std::vector<std::string> mgrsStr(4); // Corner strings.
534  mgrsStr[0] = mgrsLocationString.substr(0, 15);
535  mgrsStr[1] = mgrsLocationString.substr(15, 15);
536  mgrsStr[2] = mgrsLocationString.substr(30, 15);
537  mgrsStr[3] = mgrsLocationString.substr(45, 15);
538 
539  utmPoints.resize(4);
540  long z = 0;
541  ossim_float64 e=0.0;
542  ossim_float64 n=0.0;
543 
544  result = true; // Set to true.
545 
546 
547  //---
548  // Convert each string to Easting Northing. This also sets zone hemisphere.
549  // Method takes long for zone.
550  //---
551  for (ossim_uint32 i = 0; i < 4; ++i)
552  {
553  if ( Convert_OSSIM_MGRS_To_UTM(mgrsStr[i].c_str(), &z, &hemisphere, &e, &n) == 0 )
554  {
555  utmPoints[i].x = e;
556  utmPoints[i].y = n;
557  }
558  else
559  {
560  result = false; // Geotrans code errored on string.
561  break;
562  }
563  }
564  if (result) zone = static_cast<ossim_uint32>(z); // Set the zone.
565  }
566 
567  return result;
568 }
double ossim_float64
std::string::size_type size() const
Definition: ossimString.h:405
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
OSSIM_DLL long Convert_OSSIM_MGRS_To_UTM(const char *MGRS, long *Zone, char *Hemisphere, double *Easting, double *Northing)
std::string substr(std::string::size_type pos=0, std::string::size_type n=std::string::npos) const
Equivalent to basic_string(*this, pos, n).
Definition: ossimString.h:910

◆ parseUtmString()

void ossimNitfProjectionFactory::parseUtmString ( const ossimString utmLocation,
ossim_uint32 zone,
std::vector< ossimDpt > &  utmPoints 
) const
private

Definition at line 909 of file ossimNitfProjectionFactory.cpp.

References ossimString::begin(), ossimString::push_back(), ossimString::toDouble(), and ossimString::toUInt32().

Referenced by makeUtm().

912 {
913  ossim_uint32 idx = 0;
914  ossimString z;
915  ossimString east;
916  ossimString north;
917 
918 
919  z = ossimString(utmLocation.begin() + idx,
920  utmLocation.begin() + idx + 2);
921  idx += 2;
922  east = ossimString(utmLocation.begin() + idx,
923  utmLocation.begin() + idx + 6);
924  idx += 6;
925  north = ossimString(utmLocation.begin() + idx,
926  utmLocation.begin() + idx + 7);
927  idx += 7;
928 
929  utmPoints.push_back(ossimDpt(east.toDouble(),
930  north.toDouble()));
931 
932  z = ossimString(utmLocation.begin() + idx,
933  utmLocation.begin() + idx + 2);
934  idx += 2;
935  east = ossimString(utmLocation.begin() + idx,
936  utmLocation.begin() + idx + 6);
937  idx += 6;
938  north = ossimString(utmLocation.begin() + idx,
939  utmLocation.begin() + idx + 7);
940  idx += 7;
941  utmPoints.push_back(ossimDpt(east.toDouble(),
942  north.toDouble()));
943 
944  z = ossimString(utmLocation.begin() + idx,
945  utmLocation.begin() + idx + 2);
946  idx += 2;
947  east = ossimString(utmLocation.begin() + idx,
948  utmLocation.begin() + idx + 6);
949  idx += 6;
950  north = ossimString(utmLocation.begin() + idx,
951  utmLocation.begin() + idx + 7);
952  idx += 7;
953  utmPoints.push_back(ossimDpt(east.toDouble(),
954  north.toDouble()));
955 
956  z = ossimString(utmLocation.begin() + idx,
957  utmLocation.begin() + idx + 2);
958  idx += 2;
959  east = ossimString(utmLocation.begin() + idx,
960  utmLocation.begin() + idx + 6);
961  idx += 6;
962  north = ossimString(utmLocation.begin() + idx,
963  utmLocation.begin() + idx + 7);
964  idx += 7;
965  utmPoints.push_back(ossimDpt(east.toDouble(),
966  north.toDouble()));
967 
968  zone = z.toUInt32();
969 }
ossim_uint32 toUInt32() const
void push_back(char c)
Equivalent to insert(end(), c).
Definition: ossimString.h:905
std::string::iterator begin()
Definition: ossimString.h:420
unsigned int ossim_uint32
double toDouble() const

Member Data Documentation

◆ theInstance

ossimNitfProjectionFactory * ossimNitfProjectionFactory::theInstance = 0
staticprivate

Definition at line 266 of file ossimNitfProjectionFactory.h.

Referenced by instance().


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