36 "ossimGeneralRasterTileSource",
39 static ossimTrace traceDebug(
"ossimGeneralRasterTileSource:debug");
56 m_bufferRect(0, 0, 0, 0),
57 m_swapBytesFlag(false),
58 m_bufferSizeInPixels(0),
188 static_cast<ossim_int32>(result->
getHeight()));
193 <<
"Error from fill buffer..." 225 static const char MODULE[] =
"ossimGeneralRasterTileSource::fillBuffer";
254 << MODULE <<
" ERROR:\n" 255 <<
" Unsupported interleave type: " 274 static const char MODULE[] =
"ossimGeneralRasterTileSource::fillBIP ";
287 const ossim_int32 INPUT_BYTES_PER_SAMPLE = BYTES_PER_PIXEL * INPUT_BANDS;
288 const ossim_int32 OUTPUT_BYTES_PER_SAMPLE = BYTES_PER_PIXEL * OUTPUT_BANDS;
293 origin.
x * INPUT_BYTES_PER_SAMPLE;
296 std::streamsize inputLineBufferWidth = WIDTH * INPUT_BYTES_PER_SAMPLE;
299 std::streamsize outputLineBufferWidth = WIDTH * OUTPUT_BYTES_PER_SAMPLE;
304 <<
"\norigin: " << origin
305 <<
"\nSeek position: " << rasterOffset
306 <<
"\ninputLineBufferWidth: " << inputLineBufferWidth
307 <<
"\noutputLineBufferWidth: " << outputLineBufferWidth
308 <<
"\nINPUT_BANDS: " << INPUT_BANDS
309 <<
"\nOUTPUT_BANDS: " << OUTPUT_BANDS
317 while ( currentLine < HEIGHT )
325 << MODULE <<
" ERROR:\n" 326 <<
" Seek error! Returning with error..." << std::endl;
336 << MODULE <<
"\nERROR: Reading image line." << std::endl;
341 for (
ossim_int32 sample = 0; sample < WIDTH; ++sample )
344 for (
ossim_int32 band = 0; band < OUTPUT_BANDS; ++band )
347 memcpy( (
void*)(
m_buffer + bufferOffset +
348 sample * OUTPUT_BYTES_PER_SAMPLE +
349 band * BYTES_PER_PIXEL),
351 sample * INPUT_BYTES_PER_SAMPLE +
352 selectedBand * BYTES_PER_PIXEL),
358 bufferOffset += outputLineBufferWidth;
369 static const char MODULE[] =
"ossimGeneralRasterTileSource::fillBIL";
383 const std::streamoff LINE_OFFSET =
388 currentLine * LINE_OFFSET +
401 <<
"\norigin: " << origin
402 <<
"\nSeek position: " << offset
403 <<
"\nStarting line number: " << currentLine
404 <<
"\nbuffer_width: " << buffer_width << std::endl;
409 linesProcessed <
size.y)
424 << MODULE <<
" ERROR:\n" 425 <<
" Seek error! Returning with error..." << std::endl;
436 << MODULE <<
"\nERROR: Reading image line." 437 <<
"\ncurrentLine: " << currentLine << std::endl;
448 offset += LINE_OFFSET;
461 static const char MODULE[] =
"ossimGeneralRasterTileSource::fillBSQ";
473 std::streamoff startSeekPosition
482 std::streamoff bandOffset
488 <<
"\norigin: " << origin
489 <<
"\nSeek position: " << startSeekPosition
490 <<
"\nStarting line number: " << origin.
y 491 <<
"\nbuffer_width: " << buffer_width
492 <<
"\nbytesPerRawLine(): " 494 <<
"\nm_rasterInfo.offsetToFirstValidSample(): " 496 <<
"\nbandOffset: " << bandOffset << std::endl;
503 for (
ossim_int32 band = 0; band < num_bands; ++band)
508 std::streamoff offset = startSeekPosition + (band * bandOffset);
512 linesProcessed < height)
520 << MODULE <<
" ERROR:\n" 521 <<
" Seek error! Returning with error..." << std::endl;
531 << MODULE <<
"\nERROR: Reading image line." 532 <<
"\ncurrentLine: " << currentLine << std::endl;
554 static const char MODULE[] =
"ossimGeneralRasterTileSource::fillBsqMultiFile";
556 if (traceDebug())
CLOG <<
" Entered..." << std::endl;
586 <<
"\norigin: " << origin
587 <<
"\nSeek position: " << startSeekPosition
588 <<
"\nStarting line number: " << origin.
y 589 <<
"\nbuffer_width: " << buffer_width
591 <<
"\nbytesPerRawLine(): " 593 <<
"\nm_rasterInfo.offsetToFirstValidSample(): " 599 std::vector<ossim_uint32>::const_iterator bandIter =
m_outputBandList.begin();
617 << MODULE <<
" ERROR:\n" 618 <<
" Seek error! Returning with error..." << std::endl;
631 << MODULE <<
"\nERROR: Reading image line." 632 <<
"\ncurrentLine: " << currentLine << std::endl;
655 const char* prefix)
const 692 std::string pfx = ( prefix ? prefix :
"" );
757 static const char MODULE[] =
"ossimGeneralRasterTileSource::isValidRLevel";
759 if (reduced_res_level == 0)
771 <<
" Invalid reduced_res_level: " << reduced_res_level
786 if (reduced_res_level == 0)
804 if (reduced_res_level == 0)
833 static const char MODULE[] =
"ossimGeneralRasterTileSource::open";
835 if (traceDebug())
CLOG <<
" Entered..." << std::endl;
877 << MODULE <<
" Exit status: " << (result?
"true":
"false") << std::endl;
933 <<
"ossimGeneralRasterTileSource::open" <<
" ERROR:\n" 934 <<
"Cannot open: " << f.
c_str() << std::endl;
975 <<
"ossimGeneralRasterTileSource::initializeHandler()" <<
" DEBUG:" 979 <<
"\nByte swapping is " 983 <<
"\nRasterInfo:\n";
1022 std::vector< shared_ptr<ossim::istream> >::iterator is =
m_fileStrList.begin();
1074 char delimeter =
' ';
1090 bool noDataFound =
false;
1092 const char* lookup = kwl.
find(
"ncols");
1099 lookup = kwl.
find(
"nrows");
1112 lookup = kwl.
find(
"nbands");
1118 lookup = kwl.
find(
"nodata");
1124 lookup = kwl.
find(
"nodata_value");
1131 lookup = kwl.
find(
"nbits");
1137 lookup = kwl.
find(
"pixeltype");
1143 lookup = kwl.
find(
"layout");
1149 lookup = kwl.
find(
"byteorder");
1162 fseek(fp, 0, SEEK_END);
1167 if (lines > 0 && samples > 0)
1170 if( numBytes > 0 && numBytes != 3 )
1172 numBits = numBytes*8;
1184 if (chPixelType ==
"S")
1186 scalarType =
"ossim_sint16";
1190 scalarType =
"ossim_uint16";
1193 else if( numBits == 32 )
1195 if( chPixelType ==
"S")
1197 scalarType =
"ossim_sint32";
1199 else if( chPixelType ==
"F")
1201 scalarType =
"ossim_float32";
1205 scalarType =
"ossim_uint32";
1208 else if( numBits == 8 )
1210 scalarType =
"ossim_uint8";
1213 else if( numBits < 8 && numBits >= 1 )
1215 scalarType =
"ossim_uint8";
1217 else if(numBits == -1)
1219 if( chPixelType ==
"F")
1221 scalarType =
"ossim_float32";
1226 scalarType =
"ossim_uint8";
1251 if (file.
open(xmlFile))
1282 if (samples > 0 && lines > 0)
1290 file.
getPath(
"/metadata/eainfo/detailed/enttyp/enttypd", eainfo);
1294 if ( (lines > 0) && (samples > 0) && (bands > 0) )
1298 if( numBytes > 0 && numBytes != 3 )
1300 numBits = numBytes*8;
1307 scalarType =
"ossim_uint16";
1309 else if( numBits == 32 )
1313 scalarType =
"ossim_float32";
1317 scalarType =
"ossim_uint32";
1320 else if( numBits == 8 )
1322 scalarType =
"ossim_uint8";
1325 else if( numBits < 8 && numBits >= 1 )
1327 scalarType =
"ossim_uint8";
1365 const char* lookup = kwl.
find(
"ncols");
1372 lookup = kwl.
find(
"nrows");
1379 lookup = kwl.
find(
"cellsize");
1383 yCellSize = xCellSize;
1388 lookup = kwl.
find(
"xdim");
1395 lookup = kwl.
find(
"ydim");
1402 lookup = kwl.
find(
"xllcenter");
1406 ll_lon = centerX + xCellSize * 0.5;
1410 lookup = kwl.
find(
"yllcenter");
1414 ll_lat = (centerY + (lines - 1) * yCellSize) + yCellSize * 0.5;
1418 lookup = kwl.
find(
"xllcorner");
1425 lookup = kwl.
find(
"yllcorner");
1429 ll_lat = centerY + lines * yCellSize;
1433 lookup = kwl.
find(
"ulxmap");
1440 lookup = kwl.
find(
"ulymap");
1444 ll_lat = centerY + lines * yCellSize;
1456 createProjection(geoKwl);
1463 else if (xmlFile.
exists())
1466 if ( file.
open(xmlFile) )
1469 if ( !proj.
valid() )
1507 bool result =
false;
1524 bool result =
false;
1528 std::vector<ossim_uint32> inputList = band_list;
16 bit unsigned integer (15 bits used)
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
static ossimImageGeometryRegistry * instance()
ossimRefPtr< ossimImageGeometry > theGeometry
static const char * DECIMAL_DEGREES_PER_PIXEL_LAT
ossim_int32 validSamples() const
Returns the number of samples within "theValidImageRect".
virtual bool open()
Pure virtual open.
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossim_int32 bytesPerPixel() const
Bytes per pixel.
virtual ossim_uint32 getNumberOfBands() const
static const char * DATUM_KW
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
Represents serializable keyword/value map.
bool addFile(const char *file)
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimInterleaveType interleaveType() const
Enumerated in InterleaveTypeLUT.
virtual bool fillBIL(const ossimIpt &origin, const ossimIpt &size)
const char * find(const char *key) const
ossimInterleaveType m_bufferInterleave
ossim_int64 fileSize() const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimString getEntryString(ossim_int32 entry_number) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
std::vector< ossim_uint32 > m_outputBandList
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 reduced_res_level=0) const
Returns the number of samples in the image.
ossim_uint32 getNumberOfBands()
Get Bands.
std::streamoff offsetToFirstValidSample() const
Returns the offset in bytes to the first valid sample in the image.
ossimKeywordlist & downcaseKeywords()
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Override base getXXXXPixValue methods since the null/min/max can be set to something different...
static ossimMapProjectionFactory * instance()
ossim_uint32 height() const
bool contains(char aChar) const
static const char * NULL_VALUE_KW
virtual bool fillBIP(const ossimIpt &origin, const ossimIpt &size)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossimRefPtr< ossimProjection > getGridCoordSysProjection()
Gets projection from Grid Coordinate system node.
static ossimString toString(bool aValue)
Numeric to string methods.
bool getPath(const ossimString &path, ossimString &s) const
Gets path from doc and initializes string.
static const char * NUMBER_LINES_KW
static const char * TIE_POINT_LON_KW
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
virtual ossimString getShortName() const
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
virtual bool isOpen() const
Derived classes must implement this method to be concrete.
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
void toSimpleStringList(ossimString &result, const std::vector< T > &valuesList)
This will output a vector of values inst a string.
const ossimIpt & ul() const
ossim_int32 bytesPerRawLine() const
Returns the number of bytes in a raw line.
void change_delimiter(char del)
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
OSSIM_DLL ossimByteOrder byteOrder()
16 bit unsigned integer (14 bits used)
static const ossimErrorCode OSSIM_ERROR
ossim_uint32 toUInt32() const
16 bit unsigned integer (13 bits used)
static StreamFactoryRegistry * instance()
bool intersects(const ossimIrect &rect) const
ossim_uint32 m_bufferSizeInPixels
ossim_int32 validLines() const
Returns the number of lines within "theValidImageRect".
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
Returns a pointer to a tile given an origin representing the upper left corner of the tile to grab fr...
virtual bool fillBsqMultiFile(const ossimIpt &origin, const ossimIpt &size)
virtual ossim_uint32 getTileHeight() const
Returns the height of the output tile.
static const char * TYPE_KW
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void initialize()
Initialize the data buffer.
ossimGeneralRasterTileSource()
ossimByteOrder getImageDataByteOrder() const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual std::ostream & print(std::ostream &out) const
Generic print method.
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
virtual bool isValidRLevel(ossim_uint32 resLevel) const
Determines if the passed in reslution level is valid.
bool toSimpleVector(std::vector< T > &result, const ossimString &stringOfPoints)
void set_ul(const ossimIpt &pt)
bool completely_within(const ossimIrect &rect) const
ossim_uint8 * m_lineBuffer
virtual bool fillBSQ(const ossimIpt &origin, const ossimIpt &size)
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
#define RTTI_DEF1_INST(cls, name, b1)
const std::vector< ossimFilename > & getImageFileList() const
std::vector< std::shared_ptr< ossim::istream > > m_fileStrList
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual void setNullPix(ossim_float64 null_pix)
virtual bool setOutputBandList(const std::vector< ossim_uint32 > &band_list)
If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled...
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
static ossimImageDataFactory * instance()
virtual bool fillBuffer(const ossimIpt &origin, const ossimIpt &size)
Methods return true on succes false on error.
bool open(const ossimFilename &imageFile)
Takes image file and attempts to derive/find header file to parse for general raster data...
virtual ossim_uint32 getSizeInBytes() const
Returns the total number of bytes for all bands.
virtual ossim_uint32 getTileWidth() const
Returns the width of the output tile.
virtual ossimDataObjectStatus validate() const
std::string::size_type size() const
virtual bool isIdentityBandList(const std::vector< ossim_uint32 > &bandList) const
Convenience method to see if band list is identity.
bool isValidRLevel(ossim_uint32 reduced_res_level) const
Determines if the passed in reslution level is valid.
unsigned int ossim_uint32
virtual ossim_uint32 getNumberOfLines(ossim_uint32 reduced_res_level=0) const
Returns the number of lines in the image.
ossim_int32 rawLines() const
Returns the number of lines within "theRawImageRect".
Class for FGDC XML doc parsing.
static ossimDatumFactory * instance()
virtual ossimIrect getImageRectangle() const
static const char * DECIMAL_DEGREES_PER_PIXEL_LON
bool getImageSize(ossimIpt &size) const
virtual ossimKeywordlist getHdrInfo(ossimFilename hdrFile)
ossim_float32 toFloat32() const
const ossimIpt & lr() const
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
static const char * NUMBER_BANDS_KW
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 width() const
ossimErrorCode theErrorStatus
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
static const char * BANDS_KW
ossimIrect clipToRect(const ossimIrect &rect) const
virtual bool isBandSelector() const
Indicates whether or not the image handler can control output band selection via the setOutputBandLis...
virtual ossimKeywordlist getXmlInfo(ossimFilename xmlFile)
virtual void close()
Deletes the overview and clears the valid image vertices.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimRefPtr< ossimImageData > m_tile
static const char * ORIGIN_LATITUDE_KW
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
void set_lrx(ossim_int32 x)
ossimRefPtr< ossimProjection > getProjection()
Gets projection from document.
virtual void makeBlank()
Initializes data to null pixel values.
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void completeOpen()
Will complete the opening process.
16 bit unsigned integer (11 bits used)
static const char * INTERLEAVE_TYPE_KW
ossimImageMetaData theMetaData
ossimRefPtr< ossimImageHandler > theOverview
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList to the zero based order of output bands.
virtual void setMaxPix(ossim_float64 max_pix)
This class defines an abstract Handler which all image handlers(loaders) should derive from...
void set_lry(ossim_int32 y)
virtual ossimString getLongName() const
virtual ossim_uint32 getSize() const
Returns the total number of pixels in a tile for all bands.
virtual ~ossimGeneralRasterTileSource()
virtual void setErrorStatus() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
static const char * SCALAR_TYPE_KW
const ossimImageMetaData & getImageMetaData() const
const ossimIrect & imageRect() const
Zero based rectangle of the valid image.
bool open(const ossimFilename &xmlFileName)
Open method.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
static const char * TIE_POINT_LAT_KW
virtual void setScalarType(ossimScalarType type)
See ossimScalarType in ossimConstants for a full list.
void allocateBuffer(const ossimImageData *tile)
Allocates m_buffer.
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
void allocateTile()
Allocates m_tile.
virtual bool setOutputBandList(const std::vector< ossim_uint32 > &band_list)
If the image handler "isBandSeletor()" then the band selection of the output chip can be controlled...
virtual void setMinPix(ossim_float64 min_pix)
ossim_int32 numberOfBands() const
Number of bands.
static const char * NUMBER_SAMPLES_KW
unsigned char ossim_uint8
ossimGeneralRasterInfo m_rasterInfo
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
signed long long ossim_sint64
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
const std::string & string() const
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
16 bit unsigned integer (12 bits used)