OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeomFileWriter.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Kenneth Melero
6 //
7 //*******************************************************************
8 // $Id: ossimGeomFileWriter.cpp 20506 2012-01-27 17:02:30Z dburken $
9 
10 #include <ossim/base/ossimDpt.h>
11 #include <ossim/base/ossimGpt.h>
13 #include <ossim/base/ossimRefPtr.h>
14 #include <ossim/base/ossimTrace.h>
16 #include <ossim/base/ossimNotify.h>
23 
25  "ossimGeomFileWriter",
27 
28 static const char DEFAULT_FILE_NAME[] = "output.geom";
29 
30 static ossimTrace traceDebug("ossimGeomFileWriter:debug");
31 
33  :
35 {}
36 
38 {}
39 
41 {
42  bool status = false;
44  {
46  if(geom.valid())
47  {
48  //---
49  // First check the ossimImageGeometry image size and adjust to area of interest if
50  // necessary. The ossimImageGeometry::applyScale method sometimes has rounding
51  // issues so fix it here...
52  //---
53  if ( geom->getImageSize().hasNans() ||
54  ( geom->getImageSize() != theAreaOfInterest.size() ) )
55  {
56  if ( traceDebug() )
57  {
59  << "ossimGeomFileWriter::writeFile DEBUG:"
60  << "\nAdjusting ossimImageGeometry size to reflect the area of interest."
61  << "\narea of interest size: " << theAreaOfInterest.size()
62  << "\nossimImageGeometry size: " << geom->getImageSize()
63  << std::endl;
64  }
66  }
67 
68  // Save the state to keyword list.
69  ossimKeywordlist kwl;
70  geom->saveState(kwl);
71 
72  const ossimMapProjection* mapProj =
74 
75  if (mapProj)
76  {
77  const char* prefix = "projection.";
78 
79  ossimDpt tiePoint;
80  if (mapProj->isGeographic())
81  {
82  // Get the ground tie point.
83  ossimGpt gpt;
84  mapProj->lineSampleToWorld(theAreaOfInterest.ul(), gpt);
85  tiePoint = gpt;
86 
87  // Set the units to degrees.
88  kwl.add(prefix,
90  ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES),
91  true);
92  }
93  else
94  {
95  // Get the easting northing tie point.
96  mapProj->lineSampleToEastingNorthing(theAreaOfInterest.ul(), tiePoint);
97 
98 
99  // Set the units to meters.
100  kwl.add(prefix,
102  ossimUnitTypeLut::instance()->getEntryString(OSSIM_METERS),
103  true);
104  }
105 
106  // Write the tie to keyword list.
107  kwl.add(prefix,
109  ossimDpt(tiePoint).toString().c_str(),
110  true);
111 
112  } // matches: if (mapProj)
113 
114  status = kwl.write(theFilename.c_str());
115 
116  } // matches: if(geom.valid())
117 
118  } // matches: if(theInputConnection)
119 
120  return status;
121 }
122 
123 void ossimGeomFileWriter::getMetadatatypeList(std::vector<ossimString>& metadatatypeList) const
124 {
125  metadatatypeList.push_back(ossimString("ossim_geometry"));
126 }
127 
129  const ossimString& metadataType)const
130 {
131  return (metadataType == "ossim_geometry");
132 }
ossimGeomFileWriter()
default constructor
virtual bool hasMetadataType(const ossimString &metadataType) const
Satisfies pure virtual from ossimMetadataWriter base.
virtual ~ossimGeomFileWriter()
virtual destructor
const ossimIpt & getImageSize() const
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool isGeographic() const
const ossimIpt & ul() const
Definition: ossimIrect.h:274
void setImageSize(const ossimIpt &size)
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
ossimIpt size() const
Definition: ossimIrect.h:510
virtual void getMetadatatypeList(std::vector< ossimString > &metadatatypeList) const
Satisfies pure virtual from ossimMetadataWriter base.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual ossimGpt lineSampleToWorld(const ossimDpt &projectedPoint) const
virtual bool writeFile()
Write a geometry file to "theFilename".
static const char * TIE_POINT_XY_KW
virtual void lineSampleToEastingNorthing(const ossimDpt &liineSample, ossimDpt &eastingNorthing) const
ossimMetadataFileWriter
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
return status
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
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
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Saves the transform (if any) and projection (if any) states to the KWL.
RTTI_DEF1(ossimGeomFileWriter, "ossimGeomFileWriter", ossimMetadataFileWriter) static const char DEFAULT_FILE_NAME[]
ossimImageSource * theInputConnection
bool hasNans() const
Definition: ossimIpt.h:58
static ossimUnitTypeLut * instance()
Returns the static instance of an ossimUnitTypeLut object.
ossimGeomFileWriter
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
static const char * TIE_POINT_UNITS_KW