26 static ossimTrace traceDebug(
"ossimERS:debug");
44 in.open(headerFile, std::ios::in | std::ios::binary);
73 std::vector<ossimString> tokens;
84 if (tokens[0] ==
"CellType")
86 if (tokens[1] ==
"Unsigned8BitInteger")
90 else if (tokens[1] ==
"Unsigned16BitInteger")
94 else if (tokens[1] ==
"Signed16BitInteger")
98 else if (tokens[1] ==
"IEEE4ByteReal")
102 else if (tokens[1] ==
"IEEE8ByteReal")
111 else if (tokens[0] ==
"NullCellValue")
116 else if (tokens[0] ==
"Xdimension")
120 else if (tokens[0] ==
"Ydimension")
124 else if (tokens[0] ==
"NrOfLines")
128 else if (tokens[0] ==
"NrOfCellsPerLine")
132 else if (tokens[0] ==
"Eastings")
137 else if (tokens[0] ==
"Northings")
142 else if (tokens[0] ==
"Longitude")
145 double deg,
min, sec;
146 sscanf (tokens[1].chars(),
"%lg:%lg:%lg", °, &
min, &sec);
154 else if (tokens[0] ==
"Latitude")
156 double deg,
min, sec;
157 sscanf (tokens[1].chars(),
"%lg:%lg:%lg", °, &
min, &sec);
165 else if (tokens[0] ==
"NrOfBands")
169 else if (tokens[0] ==
"Value")
173 tokens.erase(tokens.begin());
175 id.
join(tokens,
" ");
178 else if (tokens[0] ==
"RasterInfo")
188 std::vector<ossimString> tokens;
199 if (tokens[0] ==
"Datum")
207 else if (tokens[0] ==
"Projection")
221 else if (tokens[0] ==
"CoordinateType")
225 else if (tokens[0] ==
"Units")
229 else if (tokens[0] ==
"Rotation")
231 double deg,
min, sec;
232 sscanf (tokens[1].chars(),
"%lg:%lg:%lg", °, &
min, &sec);
235 else if (tokens[0] ==
"CoordinateSpace")
248 char magicNumberTest[14];
249 in.read(magicNumberTest, 13);
251 magicNumberTest+13) !=
"DatasetHeader")
253 parseError(
"First line must be DatasetHeader");
257 std::vector<ossimString> tokens =
parseLine(in);
260 parseError(
"First line must be DatasetHeader");
263 if (tokens[0] !=
"DatasetHeader")
265 parseError(
"First line must be DatasetHeader");
278 if (tokens[0] ==
"Version")
286 else if (tokens[0] ==
"DataSetType")
294 else if (tokens[0] ==
"DataType")
302 else if (tokens[0] ==
"ByteOrder")
307 parseError(
"ByteOrder must either be MSBFirst or LSBFirst");
310 else if (tokens[0] ==
"CoordinateSpace")
312 if (tokens[1] ==
"Begin")
317 else if (tokens[0] ==
"RasterInfo")
319 if (tokens[1] ==
"Begin")
324 else if (tokens[0] ==
"SenseDate")
328 else if (tokens[0] ==
"Comments")
332 else if (tokens[0] ==
"DatasetHeader")
355 std::vector<ossimString> tokens;
356 bool invalidCharHit =
false;
357 const int MAX_LENGTH = 10000;
360 while (tokens.empty()&&(in)&&(tempCount < MAX_LENGTH))
370 invalidCharHit =
true;
389 tokens = line.
split(
"= \t");
390 if (tokens.size() > 1)
392 tokens[1].trim(
'\"');
393 tokens.back().trim(
'\"');
403 if(in.bad()||(tempCount>=MAX_LENGTH))
433 out<< std::setiosflags(std::ios::fixed) << std::setprecision(12);
434 out<<
"DatasetHeader Begin" <<std::endl;
435 out<<
" Version = \"5.5\"" <<std::endl;
440 out<<
" CoordinateSpace Begin" <<std::endl;
441 out<<
" Datum = \"" <<
theDatum <<
"\"" <<std::endl;
444 out<<
" CoordinateSpace End" <<std::endl;
448 celltype =
"Unsigned8BitInteger";
450 celltype =
"Signed8BitInteger";
452 celltype =
"Unsigned16BitInteger";
454 celltype =
"Signed16BitInteger";
456 celltype =
"Unsigned32BitInteger";
458 celltype =
"Signed32BitInteger";
460 celltype =
"Unsigned16BitInteger";
462 celltype =
"Unsigned16BitInteger";
464 celltype =
"Unsigned16BitInteger";
466 celltype =
"Unsigned16BitInteger";
468 celltype =
"Unsigned16BitInteger";
470 celltype =
"Unsigned16BitInteger";
472 out<<
" RasterInfo Begin" <<std::endl;
473 out<<
" CellType = " <<celltype <<std::endl;
475 out<<
" CellInfo Begin" <<std::endl;
478 out<<
" CellInfo End" <<std::endl;
480 out<<
" NrOfLines = " <<
theLine <<std::endl;
481 out<<
" NrOfCellsPerLine = " <<
theSample <<std::endl;
483 out<<
" RegistrationCoord Begin" <<std::endl;
487 out<<
" Northings = " <<
theOriginY <<std::endl;
493 double degrees, seconds;
500 min = (int)((degrees-(
int)degrees)*60);
501 seconds = ((degrees-(int)degrees)*60 -
min)*60;
505 <<(int)degrees<<
":"<<
min<<
":"<<seconds<<std::endl;
514 min = (int)((degrees-(
int)degrees)*60);
515 seconds = ((degrees-(int)degrees)*60 -
min)*60;
519 <<(int)degrees<<
":"<<
min<<
":"<<seconds<<std::endl;
521 out<<
" RegistrationCoord End" <<std::endl;
523 out<<
" NrOfBands = " <<
theBands <<std::endl;
524 out<<
" RasterInfo End" <<std::endl;
526 out<<
"DatasetHeader End" <<std::endl;
532 const char* prefix)
const 555 if(proj ==
"ossimUtmProjection")
620 result =
"ossimUtmProjection";
624 result =
"ossimEquDistCylProjection";
637 <<
"Please notify us with the datum name so we can add it\n";
void parseHeader(std::istream &fptr)
16 bit unsigned integer (15 bits used)
static const char * DECIMAL_DEGREES_PER_PIXEL_LAT
ossimString theSensorname
static const char * DATUM_KW
const ossimString & join(const std::vector< ossimString > &stringList, const ossimString &separator)
ossimUnitType theTieUnitType
ossimString theCoordSysType
Represents serializable keyword/value map.
static const ossimErrorCode OSSIM_OK
std::basic_ifstream< char > ifstream
Class for char input file streams.
ossimString theDescription
ossimString toOssimProjection() const
std::vector< ossimString > theBandID
bool contains(char aChar) const
static const char * TIE_POINT_LON_KW
std::vector< ossimString > parseLine(std::istream &in)
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
ossim_int32 theCellsizeof
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
bool toOssimProjectionGeom(ossimKeywordlist &kwl, const char *prefix=NULL) const
16 bit unsigned integer (13 bits used)
static const char * METERS_PER_PIXEL_Y_KW
static const char * TYPE_KW
std::string::iterator end()
ossimScalarType theCelltype
static const char * TIE_POINT_NORTHING_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const char * ZONE_KW
virtual std::ostream & print(std::ostream &out) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
void parseError(const char *msg)
static const char * TIE_POINT_EASTING_KW
std::string::iterator begin()
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
static const char * DECIMAL_DEGREES_PER_PIXEL_LON
ossimErrorCode theErrorStatus
16 bit unsigned integer (11 bits used)
std::basic_istream< char > istream
Base class for char input streams.
ossimString toOssimDatum() const
static const char * HEMISPHERE_KW
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
bool writeFile(const ossimFilename &file)
static const char * TIE_POINT_LAT_KW
std::basic_ofstream< char > ofstream
Class for char output file streams.
ossimString theProjection
void parseCoordinateSpace(std::istream &fptr)
ossimString theDatasetType
ossim_int32 theHeaderOffset
static const char * METERS_PER_PIXEL_X_KW
void parseRasterInfo(std::istream &fptr)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
16 bit unsigned integer (12 bits used)