40 if ( (SIG[0] ==
'S') && (SIG[1] ==
'Q') && (SIG[2] ==
'L') && (SIG[3] ==
'i') &&
41 (SIG[4] ==
't') && (SIG[5] ==
'e') && (SIG[6] ==
' ') && (SIG[7] ==
'f') &&
42 (SIG[8] ==
'o') && (SIG[9] ==
'r') && (SIG[10] ==
'm') && (SIG[11] ==
'a') &&
43 (SIG[12] ==
't') && (SIG[13] ==
' ') && (SIG[14] ==
'3') )
64 in.seekg( 68, std::ios_base::beg );
66 if ( (APP_ID[0] ==
'G') && (APP_ID[1] ==
'P') && (APP_ID[2] ==
'1') &&
67 ( (APP_ID[3] ==
'0') || (APP_ID[3] ==
'1') ) )
80 std::vector<ossimGpkgTileMatrixSetRecord> sets;
87 std::vector<ossimGpkgTileMatrixRecord> levels;
92 std::vector<ossimGpkgNsgTileMatrixExtentRecord> extents;
97 std::vector<ossimGpkgSpatialRefSysRecord> srs;
102 std::vector<ossimGpkgTileMatrixSetRecord>::const_iterator setIdx = sets.begin();
103 while ( setIdx != sets.end() )
109 std::vector<ossimGpkgTileMatrixRecord>::const_iterator mIdx = levels.begin();
110 while ( mIdx != levels.end() )
121 std::vector<ossimGpkgNsgTileMatrixExtentRecord>::const_iterator extIdx = extents.begin();
122 while ( extIdx != extents.end() )
132 std::vector<ossimGpkgSpatialRefSysRecord>::const_iterator srsIdx = srs.begin();
133 while ( srsIdx != srs.end() )
138 entry.
setSrs( (*srsIdx) );
151 entries.push_back( entry );
156 <<
"ossim_gpkg::getTileEntries WARNING No levels found for entry!" 169 const std::string& tileTableName,
184 std::vector<ossimGpkgTileMatrixRecord> levels;
191 std::vector<ossimGpkgTileMatrixRecord>::const_iterator mIdx = levels.begin();
192 while ( mIdx != levels.end() )
216 std::vector<ossimGpkgNsgTileMatrixExtentRecord> extents;
222 std::vector<ossimGpkgNsgTileMatrixExtentRecord>::const_iterator extIdx =
224 while ( extIdx != extents.end() )
248 <<
"ossim_gpkg::getTileEntry WARNING size mismatch between tile matrix" 249 <<
" and tile matrix extents!\n";
256 <<
"ossim_gpkg::getTileEntry WARNING No gpkg_spatial_ref_sys record found for" 263 <<
"ossim_gpkg::getTileEntry WARNING No gpkg_tile_matrix records found for entry!" 275 std::vector<T>& result,
276 const std::string& dbTableName )
278 if ( db && dbTableName.size() )
280 const char *zLeftover;
281 sqlite3_stmt *pStmt = 0;
282 std::string sql =
"SELECT * from ";
285 int rc = sqlite3_prepare_v2(db,
290 if ( rc == SQLITE_OK )
295 rc = sqlite3_step(pStmt);
296 if ( rc == SQLITE_ROW )
303 if ( gpkgRecPtr->
init( pStmt ) )
305 result.push_back(record);
310 <<
"ossim_gpkg::getGpkgRecords init failed!" 326 sqlite3_finalize(pStmt);
332 std::vector<T>& result,
333 const std::string& dbTableName,
334 const std::string& table_name )
336 if ( db && dbTableName.size() && table_name.size() )
338 const char *zLeftover;
339 sqlite3_stmt *pStmt = 0;
341 sql <<
"SELECT * from " << dbTableName
342 <<
" WHERE table_name == '" << table_name <<
"'";
344 int rc = sqlite3_prepare_v2(db,
349 if ( rc == SQLITE_OK )
354 rc = sqlite3_step(pStmt);
355 if ( rc == SQLITE_ROW )
362 if ( gpkgRecPtr->
init( pStmt ) )
364 result.push_back(record);
369 <<
"ossim_gpkg::getGpkgRecords init failed!" 385 sqlite3_finalize(pStmt);
392 const std::string& dbTableName,
393 const std::string& table_name )
397 if ( db && dbTableName.size() && table_name.size() )
399 const char *zLeftover;
400 sqlite3_stmt *pStmt = 0;
402 sql <<
"SELECT * from " << dbTableName
403 <<
" WHERE table_name == '" << table_name <<
"'";
405 int rc = sqlite3_prepare_v2(db,
410 if ( rc == SQLITE_OK )
413 rc = sqlite3_step(pStmt);
415 if ( rc == SQLITE_ROW )
425 <<
"ossim_gpkg::getGpkgRecord init failed!" 431 sqlite3_finalize(pStmt);
447 const char *zLeftover;
448 sqlite3_stmt *pStmt = 0;
451 <<
" WHERE srs_id == " << srs_id;
453 int rc = sqlite3_prepare_v2(db,
458 if ( rc == SQLITE_OK )
461 rc = sqlite3_step(pStmt);
462 if ( rc == SQLITE_ROW )
472 <<
"ossim_gpkg::getSrsRecord init failed!" 478 sqlite3_finalize(pStmt);
487 const std::string& tableName,
490 static const char M[] =
"ossim_gpkg::getTableRows";
494 if ( db && tableName.size() )
496 const char *zLeftover;
497 sqlite3_stmt *pStmt = 0;
498 std::string sql =
"SELECT * from ";
501 int rc = sqlite3_prepare_v2(db,
506 if ( rc == SQLITE_OK )
508 bool initStatus =
true;
510 int nCol = sqlite3_column_count( pStmt );
516 rc = sqlite3_step(pStmt);
517 if ( rc == SQLITE_ROW )
522 if ( row->
init( pStmt ) )
524 result.push_back(row);
529 << M <<
" init failed!" << std::endl;
537 << M <<
" could not make object for table name: " << tableName
549 if ( initStatus && result.size() )
554 sqlite3_finalize(pStmt);
562 const std::string& tableName )
593 const char *zLeftover;
594 sqlite3_stmt *pStmt = 0;
595 std::string sql =
"SELECT * from ";
596 sql += tileTableName;
598 int rc = sqlite3_prepare_v2(db,
603 if ( rc == SQLITE_OK )
605 int nCol = sqlite3_column_count( pStmt );
613 rc = sqlite3_step(pStmt);
614 if ( rc == SQLITE_ROW )
616 if (tile.
init( pStmt ) )
618 out << tile << std::endl;
628 sqlite3_finalize(pStmt);
void addTileMatrixExtent(const ossimGpkgNsgTileMatrixExtentRecord &record)
Adds a tile matrix extent level to array.
static const std::string & getTableName()
Get the table name "gpkg_spatial_ref_sys".
void getTileEntries(sqlite3 *db, std::vector< ossimGpkgTileEntry > &entries)
Gets all the tile entries.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
bool getSrsRecord(sqlite3 *db, ossim_int32 srs_id, ossimGpkgSpatialRefSysRecord &srs)
Get gpkg_spatial_ref_sys record for srs_it.
bool checkApplicationId(std::istream &in)
Check application_id.
const ossimGpkgTileMatrixSetRecord & getTileMatrixSet() const
static const std::string & getTableName()
Get the table name "gpkg_tile_matrix_set".
static const std::string & getTableName()
Get the table name "gpkg_tile_matrix".
bool init(sqlite3_stmt *pStmt)
Initialize from database.
void setTileMatrixSet(const ossimGpkgTileMatrixSetRecord &set)
Sets the tile matrix set.
bool getTileEntry(sqlite3 *db, const std::string &tileTableName, ossimGpkgTileEntry &entry)
Gets tile entry whos table_name field matches tileTableName.
bool getTableRows(sqlite3 *db, const std::string &tableName, std::vector< ossimRefPtr< ossimGpkgDatabaseRecordBase > > &result)
Parse table rows.
void getGpkgRecords(sqlite3 *db, std::vector< T > &result, const std::string &dbTableName)
Get gpkg records.
bool checkSignature(std::istream &in)
Check signature method.
std::ostream & printTiles(sqlite3 *db, const std::string &tileTableName, std::ostream &out)
void sortTileMatrix()
Sorts the m_tileMatrix by zoom levels with the highest zoom level being at the lowest array index...
void addTileMatrix(const ossimGpkgTileMatrixRecord &level)
Adds a tile matrix level to array.
void sortTileMatrixExtents()
Sorts the m_tileMatrixExtents by zoom levels with the highest zoom level being at the lowest array in...
void setSrs(const ossimGpkgSpatialRefSysRecord &srs)
Sets the spatial ref sys.
std::basic_istream< char > istream
Base class for char input streams.
const std::vector< ossimGpkgTileMatrixRecord > & getTileMatrix() const
static const std::string & getTableName()
Get the table name "nsg_tile_matrix_extent".
virtual bool init(sqlite3_stmt *pStmt)=0
Initialize from database.
ossimRefPtr< ossimGpkgDatabaseRecordBase > getNewTableRecord(const std::string &tableName)
Parse gpkg_spatial_ref_sys tables.
bool getGpkgRecord(sqlite3 *db, T &result, const std::string &dbTableName, const std::string &table_name)
Get gpkg record.
void setCopyTileFlag(bool flag)
static const std::string & getTableName()
Get the table name "gpkg_contents".
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
const std::vector< ossimGpkgNsgTileMatrixExtentRecord > & getTileMatrixExtent() const