50 #ifdef OSSIM_ID_ENABLED 51 static const char OSSIM_ID[] =
"$Id$";
54 static ossimTrace traceDebug(
"ossimGpkgReader:debug");
55 static ossimTrace traceValidate(
"ossimGpkgReader:validate");
74 <<
"ossimGpkgReader::ossimGpkgReader entered...\n";
75 #ifdef OSSIM_ID_ENABLED 77 <<
"OSSIM_ID: " << OSSIM_ID <<
"\n";
154 fillTile(resLevel, tileRect, clipRect, result);
176 std::vector<ossimIpt> tileIndexes;
179 std::vector<ossimIpt>::const_iterator i = tileIndexes.begin();
180 while ( i != tileIndexes.end() )
197 std::vector<ossimIpt>& tileIndexes )
const 202 if ( tileSize.
x && tileSize.
y )
211 expandedRect += subImageOffset;
217 while (
y < expandedRect.
lr().
y )
220 while (
x < expandedRect.
lr().
x )
223 tileIndexes.push_back( index );
254 const char* prefix)
const 289 static const char M[] =
"ossimGpkgReader::open";
317 <<
"File: " <<
theImageFile <<
" does not have required application_id!" 318 <<
"\nProceeding anyway...\n";
323 if ( rc == SQLITE_OK )
334 std::vector<ossimGpkgTileEntry>::const_iterator i =
m_entries.begin();
343 std::vector<ossimGpkgTileEntry>::const_iterator i =
m_entries.begin();
366 << M <<
" exit status: " << (
status?
"true":
"false") <<
"\n";
482 sqlite3_close(
m_db );
502 entryList.push_back(i);
508 std::vector<ossimGpkgTileEntry>::const_iterator i =
m_entries.begin();
511 entryNames.push_back(
ossimString((*i).getTileMatrixSet().m_table_name) );
630 <<
"ossimGpkgReader::getImageGeometry geometry:\n" 641 static const char M[] =
"ossimGpkgReader::getInternalImageGeometry";
653 if ( mapProj.
valid() )
683 static const char MODULE[] =
"ossimGpkgReader::initImageParams";
703 const char *zLeftover;
704 sqlite3_stmt *pStmt = 0;
707 sql <<
"SELECT min(id), tile_column, tile_row from " 708 << tableName <<
" WHERE zoom_level=" << zoomLevel;
713 <<
"sql:\n" << sql.str() <<
"\n";
716 int rc = sqlite3_prepare_v2(
m_db,
721 if ( rc == SQLITE_OK )
723 int nCol = sqlite3_column_count( pStmt );
727 rc = sqlite3_step(pStmt);
728 if ( rc == SQLITE_ROW )
730 index.
x = sqlite3_column_int(pStmt, 1);
731 index.
y = sqlite3_column_int(pStmt, 2);
736 sqlite3_finalize(pStmt);
738 if ( (index.
x > -1) && (index.
y > -1) )
773 << MODULE <<
" exit status = " << (result?
"true":
"false") <<
"\n";
782 static const char MODULE[] =
"ossimGpkgReader::getTile(resLevel, index)";
786 << MODULE <<
" entered..." 787 <<
"\nresLevel: " << resLevel <<
" index: " << index <<
"\n";
798 std::string tableName =
802 const char *zLeftover;
803 sqlite3_stmt *pStmt = 0;
805 sql <<
"SELECT id, zoom_level, tile_column, tile_row, tile_data from " 807 <<
" WHERE zoom_level=" << zoomLevel
808 <<
" AND tile_column=" << index.
x 809 <<
" AND tile_row=" << index.
y;
814 << MODULE <<
" sql:\n" << sql.str() <<
"\n";
817 int rc = sqlite3_prepare_v2(
823 if ( rc == SQLITE_OK )
825 int nCol = sqlite3_column_count( pStmt );
829 rc = sqlite3_step(pStmt);
830 if (rc == SQLITE_ROW)
834 if (tile.
init( pStmt ) )
870 <<
"Unhandled type: " << tile.
getTileType() << endl;;
886 <<
"WARNING: decode failed...\n";
890 if ( result.
valid() )
894 index.
y*tileSize.
y );
899 origin -= subImageOffset;
903 else if (traceDebug())
906 << MODULE <<
" WARNING: result is null!\n";
915 sqlite3_finalize(pStmt);
926 << MODULE <<
" exit result is " << (result.
valid()?
"set.":
"null.") <<
"\n";
944 std::string data( (
char*)&tile.
m_tile_data.front(),
948 std::shared_ptr<ossim::istream> is;
950 std::shared_ptr<ossim::istringstream> testIs =
951 std::make_shared<ossim::istringstream>();
962 if ( sri->
open( is, std::string(
"gpkg_tile")) == false )
983 ossimIrect rect( 0, 0, tileSize.
x - 1, tileSize.
y - 1 );
1004 <<
"ossimGpkgReader::computeGsd DEBUG:\ngsd: " << gsd <<
"\n";
static ossimCodecFactoryRegistry * instance()
void getTileIndexes(ossim_uint32 resLevel, const ossimIrect &clipRect, std::vector< ossimIpt > &tileIndexes) const
void clear()
Erases the entire container.
virtual ossim_uint32 getWidth() const
virtual bool isSourceEnabled() const
static ossimImageGeometryRegistry * instance()
virtual ossim_uint32 getImageTileWidth() const
Returns the tile width of the image or 0 if the image is not tiled.
ossimRefPtr< ossimImageGeometry > theGeometry
ossim_uint32 m_tileHeight
ossimRefPtr< ossimImageHandler > m_ih
void setProjection(ossimProjection *projection)
Sets the projection to be used for local-to-world coordinate transformation.
ossimRefPtr< ossimImageData > uncompressPngTile(const ossimGpkgTileRecord &tile, const ossimIpt &tileSize)
Uncompresses png tile to m_cacheTile.
virtual ossimString getClassName() const
void getTileEntries(sqlite3 *db, std::vector< ossimGpkgTileEntry > &entries)
Gets all the tile entries.
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::basic_ostringstream< char > ostringstream
Class for char output memory streams.
virtual ossim_uint32 getNumberOfBands() const
bool checkApplicationId(std::istream &in)
Check application_id.
ossimFilename theImageFile
virtual void setImageRectangle(const ossimIrect &rect)
ossim_uint32 m_currentEntry
std::vector< ossim_uint8 > m_tile_data
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
Represents serializable keyword/value map.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const
Returns the number of lines in the image.
std::basic_ifstream< char > ifstream
Class for char input file streams.
virtual bool open()
open method.
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
bool init(sqlite3_stmt *pStmt)
Initialize from database.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Get propterty method.
void allocate()
Allocates m_tile.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
const ossimIpt & ul() const
void computeGsd(ossimDpt &gsd) const
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
virtual ossim_uint32 getNumberOfDecimationLevels() const
Returns the number of decimation levels.
bool intersects(const ossimIrect &rect) const
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual ossimString getLongName() const
void fillTile(ossim_uint32 resLevel, const ossimIrect &tileRect, const ossimIrect &clipRect, ossimImageData *tile)
virtual bool extendGeometry(ossimImageHandler *handler) const
virtual void getEntryNames(std::vector< ossimString > &entryNames) const
Get the list of entry names.
void ref() const
increment the reference count by one, indicating that this object has another pointer which is refere...
virtual void initialize()
Initialize the data buffer.
virtual ossim_uint32 getImageTileHeight() const
Returns the tile width of the image or 0 if the image is not tiled.
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.
virtual ossim_uint32 getTileWidth() const
Returns the width of the output tile.
virtual void close()
Close method.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
bool checkSignature(std::istream &in)
Check signature method.
ossimRefPtr< ossimCodecBase > m_jpegCodec
virtual bool getOverviewTile(ossim_uint32 resLevel, ossimImageData *result)
Method to get an overview tile.
static ossimImageDataFactory * instance()
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
ossim_uint32 getNumberOfZoomLevels() const
virtual ossimDataObjectStatus validate() const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &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...
unsigned int ossim_uint32
virtual ossimScalarType getOutputScalarType() const
Returns the output pixel type of the tile source.
virtual bool decode(const std::vector< ossim_uint8 > &in, ossimRefPtr< ossimImageData > &out) const =0
Decode method.
virtual void getEntryList(std::vector< ossim_uint32 > &entryList) const
Gets the entry list.
virtual ossimIrect getImageRectangle() const
std::vector< ossimGpkgTileEntry > m_entries
ossimRefPtr< ossimImageData > m_tile
virtual ossim_uint32 getCurrentEntry() const
const ossimIpt & lr() const
virtual void close()
Deletes the overview and clears the valid image vertices.
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
virtual ~ossimGpkgReader()
virtual destructor
virtual ossim_uint32 getTileHeight() const
Returns the height of the output tile.
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
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns the zero based image rectangle for the reduced resolution data set (rrds) passed in...
virtual ossim_uint32 getNumberOfEntries() const
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
void unref() const
decrement the reference count by one, indicating that a pointer to this object is referencing it...
virtual void setOrigin(const ossimIpt &origin)
virtual ossimString getShortName() const
virtual ossimRefPtr< ossimImageGeometry > getExternalImageGeometry() const
Returns the image geometry object associated with this tile source or NULL if non defined...
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual ossimScalarType getScalarType() const
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.
virtual bool setCurrentEntry(ossim_uint32 entryIdx)
ossimRefPtr< ossimImageHandler > theOverview
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
Get propterty names.
bool isOpen() const
Derived classes must implement this method to be concrete.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
virtual ossimRefPtr< ossimImageGeometry > getInternalImageGeometry()
virtual const void * getBuf() const
virtual bool open(std::shared_ptr< ossim::istream > &str, const std::string &connectionString)=0
Pure virtual open method that takes a stream.
ossimRefPtr< ossimImageData > m_cacheTile
ossimGpkgTileType getTileType() const
ossimRefPtr< ossimCodecBase > m_pngCodec
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string's contents...
void stretchToTileBoundary(const ossimIpt &tileWidthHeight)
ossimFilename theOverviewFile
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
static ossimImageHandlerRegistry * instance()
ossimGpkgReader()
default constructor
#define RTTI_DEF1(cls, name, b1)
void setCopyTileFlag(bool flag)
void getTileSize(ossim_uint32 resLevel, ossimIpt &tileSize) const
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const
Returns the number of samples in the image.
virtual ossim_uint32 getNumberOfInputBands() const
Returns the number of bands in the image.
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Set propterty method.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)