41 #include <lt_fileSpec.h> 42 #include <lt_ioFileStream.h> 43 #include <lti_imageReader.h> 44 #include <lti_pixel.h> 45 #include <lti_scene.h> 46 #include <lti_sceneBuffer.h> 47 #include <lt_fileSpec.h> 48 #include <lti_geoCoord.h> 49 #include <lt_ioFileStream.h> 50 #include <lti_pixelLookupTable.h> 51 #include <lti_utils.h> 52 #include <lti_metadataDatabase.h> 53 #include <lti_metadataRecord.h> 60 #ifdef OSSIM_ID_ENABLED 61 static const char OSSIM_ID[] =
"$Id";
64 static ossimTrace traceDebug(
"ossimMrSidReader:debug");
65 static ossimTrace traceDump(
"ossimMrSidReader:dump");
131 vector<ossimDpt>& decimations)
const 228 static const char MODULE[] =
"ossimMrSidReader::open";
233 << MODULE <<
" entered...\n" 251 LT_STATUS sts = LT_STS_Uninit;
256 sts =
theReader->initialize(fileSpec,
true);
257 if (LT_SUCCESS(sts) ==
false)
278 if ( !width || !height )
307 << MODULE <<
" exit status = " << (result?
"true":
"false\n")
329 LT_STATUS sts = LT_STS_Uninit;
365 lt_uint16 anOssimBandIndex = 0;
368 LTISceneBuffer sceneBuffer(pixel, clipRect.
width(), clipRect.
height(), NULL);
377 clipRect.
lr().
x - clipRect.
ul().
x + 1,
378 clipRect.
lr().
y - clipRect.
ul().
y + 1, mag);
381 sts =
theReader->read(scene, sceneBuffer);
383 if (LT_SUCCESS(sts) ==
true)
388 sceneBuffer.exportDataBSQ(buf);
392 for(anOssimBandIndex = 0; anOssimBandIndex <
theNumberOfBands; anOssimBandIndex++)
395 clipRect, anOssimBandIndex);
484 if ( geom.
valid() == false )
488 auxXmlFile +=
".aux.xml";
489 if ( auxXmlFile.
exists() )
505 static const char MODULE[] =
"ossimMrSidReader::getInternalImageGeometry";
523 std::vector<ossimDpt>& decimations)
const 546 if ( (r0 > 0.0) && (rL > 0.0) )
559 if ( (r0 > 0.0) && (rL > 0.0) )
570 decimations.push_back(pt);
576 <<
"ossimMrSidReader::computeDecimationFactors DEBUG\n";
580 <<
"decimation[" << i <<
"]: " << decimations[i]
601 lt_uint32 height = 0;
603 double mag = LTIUtils::levelToMag(level);
607 ossimIrect imageRect(0, 0, width-1, height-1);
609 tileDims.push_back(imageRect);
637 LTIDataType pixelType =
theReader->getPixelProps().getDataType();
639 LTIPixel pixel =
theReader->getPixelProps();
643 case LTI_DATATYPE_UINT8:
648 case LTI_DATATYPE_SINT8:
653 case LTI_DATATYPE_UINT16:
658 case LTI_DATATYPE_SINT16:
663 case LTI_DATATYPE_UINT32:
668 case LTI_DATATYPE_SINT32:
673 case LTI_DATATYPE_FLOAT32:
678 case LTI_DATATYPE_FLOAT64:
715 const LTIGeoCoord& geo =
theReader->getGeoCoord();
716 LTIMetadataDatabase metaDb =
theReader->getMetadata();
719 for (
ossim_uint32 i = 0; i < metaDb.getIndexCount(); ++i )
721 const LTIMetadataRecord* rec = 0;
722 metaDb.getDataByIndex(i, rec);
723 cout <<
"rec.getTagName(): " << rec->getTagName() << endl;
725 const char* projStr = geo.getWKT();
728 std::string wktStr = projStr;
730 cout <<
"wktStr: " << wktStr << endl;
732 if ( wkt.open( wktStr ) )
734 cout <<
"kwl:\n" << wkt.
getKwl() << endl;
740 if( (geo.getXRot() != 0.0) || (geo.getYRot() != 0.0))
744 metaDb,
"GEOTIFF_NUM::2048::GeographicTypeGeoKey", &gcsCode);
746 metaDb,
"GEOTIFF_NUM::3072::ProjectedCSTypeGeoKey", &pcsCode);
748 if (gcsFound && !pcsFound)
752 proj_type =
"ossimEquDistCylProjection";
754 tie_pt_units =
"degrees";
759 &unitStr,
sizeof(unitStr)) ==
true)
762 if ( unitTag.
contains(
"Angular_Degree") )
763 scale_units =
"degrees";
764 else if ( unitTag.
contains(
"Angular_Minute") )
765 scale_units =
"minutes";
766 else if ( unitTag.
contains(
"Angular_Second") )
767 scale_units =
"seconds";
789 sizeof(unitStr)) ==
true )
796 const char* wktProjStr = geo.getWKT();
799 std::string wktStr = wktProjStr;
801 if ( wkt.
parse( wktStr ) )
803 unitTag = wkt.
getKwl().
findKey( std::string(
"PROJCS.UNIT.name") );
808 if ( unitTag.
size() )
814 scale_units =
"meters";
816 else if ( unitTag.
contains(
"linear_foot_us_survey") )
818 scale_units =
"us_survey_feet";
820 else if ( unitTag.
contains(
"linear_foot") )
822 scale_units =
"feet";
824 tie_pt_units = scale_units;
831 const char* projStr = geo.getWKT();
836 char rasterTypeStr[200];
837 strcpy( rasterTypeStr,
"unnamed" );
838 double topLeftX = geo.getX();
839 double topLeftY = geo.getY();
840 if (
getMetadataElement(metaDb,
"GEOTIFF_CHAR::GTRasterTypeGeoKey", &rasterTypeStr,
sizeof(rasterTypeStr)) ==
true)
846 if ( rasterTypeTag.
contains(
"RasterPixelIsPoint") )
848 topLeftX -= geo.getXRes() / 2.0;
849 topLeftY += geo.getYRes() / 2.0;
852 ossimDpt gsd(fabs(geo.getXRes()), fabs(geo.getYRes()));
876 if (auxFile.
exists() && auxHandler.
open(auxFile))
885 if (proj_name.
contains(
"Geographic"))
888 scale_units =
"degrees";
889 tie_pt_units =
"degrees";
895 if (unitType.
empty())
899 scale_units =
"feet";
900 tie_pt_units =
"feet";
905 scale_units = unitType;
906 tie_pt_units = unitType;
920 if ( scale_units.
empty() || (scale_units ==
"unknown" ) ||
921 tie_pt_units.
empty() || (tie_pt_units ==
"unknown" ) )
924 <<
"ossimMrSidReader::getProjection WARNING: Undefined units!" 925 <<
"\nscale units: " << scale_units
926 <<
"\ntie_pt_units: " << tie_pt_units
945 if (!metaDb.has(tagName))
950 const LTIMetadataRecord* metaRec = 0;
951 metaDb.get(tagName, metaRec );
953 if (!metaRec->isScalar())
960 switch(metaRec->getDataType())
962 case LTI_METADATA_DATATYPE_UINT8:
963 case LTI_METADATA_DATATYPE_SINT8:
966 case LTI_METADATA_DATATYPE_UINT16:
967 case LTI_METADATA_DATATYPE_SINT16:
970 case LTI_METADATA_DATATYPE_UINT32:
971 case LTI_METADATA_DATATYPE_SINT32:
972 case LTI_METADATA_DATATYPE_FLOAT32:
975 case LTI_METADATA_DATATYPE_FLOAT64:
978 case LTI_METADATA_DATATYPE_ASCII:
986 if ( metaRec->getDataType() == LTI_METADATA_DATATYPE_ASCII )
988 strncpy( (
char *)pValue, ((
const char**)metaRec->getScalarData())[0], iSize );
989 ((
char *)pValue)[iSize - 1] =
'\0';
993 memcpy( pValue, metaRec->getScalarData(), iSize);
virtual void loadBand(const void *src, const ossimIrect &src_rect, ossim_uint32 band)
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
const ossimString & getProjectionName() const
Reads a single record from a aux file.
virtual bool isSourceEnabled() const
static ossimImageGeometryRegistry * instance()
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Gets number of lines for res level.
bool getImageDimensions(std::vector< ossimIrect > &tileDims) const
ossimRefPtr< ossimImageGeometry > theGeometry
ossimMrSidReader()
default construtor
virtual bool open()
Open method.
static const char * PROJECTION_KW
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
const ossimString & getDatumName() const
static const char * DATUM_KW
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
Represents serializable keyword/value map.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
virtual void closeEntry()
Method to close current entry.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Method to grab a tile(rectangle) from image.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
ossim_uint32 height() const
bool contains(char aChar) const
static const char * NUMBER_LINES_KW
virtual void getDecimationFactors(vector< ossimDpt > &decimations) const
Get array of decimations for all levels.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
const ossimIpt & ul() const
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
Gets the decimation factor for a resLevel.
bool intersects(const ossimIrect &rect) const
virtual ossimString getClassName() const
Returns class name.
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry() const
Method to get geometry from internal mrsid tags.
static const char * TYPE_KW
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void initialize()
Initialize the data buffer.
RTTI_DEF1_INST(ossimMrSidReader, "ossimMrSidReader", ossimImageHandler) ossimMrSidReader
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 open(const ossimFilename &file)
the file for reading
const ossimString & getUnitType() const
virtual ~ossimMrSidReader()
virtural destructor
bool completely_within(const ossimIrect &rect) const
static const char * PIXEL_SCALE_XY_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool computeDecimationFactors(std::vector< ossimDpt > &decimations) const
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
static ossimImageDataFactory * instance()
ossimProjection * createProjection(const ossimFilename &filename, ossim_uint32 entryIdx) const
virtual ossimDataObjectStatus validate() const
static const char * TIE_POINT_XY_KW
std::string::size_type size() const
unsigned int ossim_uint32
ossimRefPtr< ossimImageData > theTile
const ossimIpt & lr() const
virtual void close()
Deletes the overview and clears the valid image vertices.
Utility/support data class to parse WKT text string to an ossimKeywordlist.
static ossimString downcase(const ossimString &aString)
ossimScalarType theScalarType
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 width() const
virtual ossimString getShortName() const
Returns short name.
void initImageParameters(ossimImageGeometry *geom) const
Convenience method to set things needed in the image geometry from the image handler.
ossimIrect clipToRect(const ossimIrect &rect) const
std::vector< ossimIrect > theMrSidDims
Has sub image offset.
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
static ossimProjectionFactoryRegistry * instance()
ossim_uint32 theNumberOfBands
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
Utility/support data class to extract the projection from a dot aux dot xml file commonly found with ...
void decimationFactors(std::vector< ossimDpt > &decimations) const
Gets array of all decimation levels.
void setDiscreteDecimation(const std::vector< ossimDpt > &decimation_list)
Sets the decimation scheme to a discrete list of decimation factors.
virtual void makeBlank()
Initializes data to null pixel values.
static const char * PCS_CODE_KW
const ossimProjection * getProjection() const
Access methods for projection (may be NULL pointer).
virtual void completeOpen()
Will complete the opening process.
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
ossimProjection * getGeoProjection()
bool getMetadataElement(LTIMetadataDatabase metaDb, const char *tagName, void *pValue, int iLength=0)
ossimString toString(ossim_uint32 precision=15) const
ossimRefPtr< ossimImageHandler > theOverview
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Gets the image geometry from external ".geom" or ".aux.xml" file.
virtual bool isOpen() const
Method to test for open file stream.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of decimation levels.
virtual const void * getBuf() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
virtual ossimString getLongName() const
Returns long name.
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
LTINavigator * theImageNavigator
ossim_uint32 theMinDwtLevels
virtual void setScalarType(ossimScalarType type)
See ossimScalarType in ossimConstants for a full list.
bool parse(const std::string &wkt)
Parses string to keyword list.
const ossimKeywordlist & getKwl() const
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
MrSIDImageReader * theReader
ossim_uint32 getNumberOfDecimations() const
static const char * NUMBER_SAMPLES_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
ossimRefPtr< ossimProjection > getProjection(const ossimFilename &file) const
Method to get a projection if possible.
static const char * PIXEL_SCALE_UNITS_KW
static const char * TIE_POINT_UNITS_KW
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Gets the number of samples for res level.
ossimDpt decimationFactor(ossim_uint32 r_index) const
Returns the decimation factor from R0 for the resolution level specified.
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 ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)