23 static const std::string TABLE_NAME =
"gpkg_contents";
44 m_table_name(obj.m_table_name),
45 m_data_type(obj.m_data_type),
46 m_identifier(obj.m_identifier),
47 m_description(obj.m_description),
48 m_last_change(obj.m_last_change),
53 m_srs_id(obj.m_srs_id)
60 if (
this != ©_this )
87 static const char M[] =
"ossimGpkgContentsRecord::init";
96 if ( nCol != EXPECTED_COLUMNS )
99 << M <<
" WARNING:\nUnexpected number of columns: " << nCol
100 <<
"Expected column count: " << EXPECTED_COLUMNS
104 if ( nCol >= EXPECTED_COLUMNS )
112 colName = sqlite3_column_name(pStmt, i);
113 if ( colName.size() )
115 if ( colName ==
"table_name" )
117 c = (
const char*)sqlite3_column_text(pStmt, i);
121 else if ( colName ==
"data_type" )
123 c = (
const char*)sqlite3_column_text(pStmt, i);
127 else if ( colName ==
"identifier" )
129 c = (
const char*)sqlite3_column_text(pStmt, i);
133 else if ( colName ==
"description" )
135 c = (
const char*)sqlite3_column_text(pStmt, i);
139 else if ( colName ==
"last_change" )
141 c = (
const char*)sqlite3_column_text(pStmt, i);
145 else if ( colName ==
"min_x" )
147 m_min_x = sqlite3_column_double(pStmt, i);
150 else if ( colName ==
"min_y" )
152 m_min_y = sqlite3_column_double(pStmt, i);
155 else if ( colName ==
"max_x" )
157 m_max_x = sqlite3_column_double(pStmt, i);
160 else if ( colName ==
"max_y" )
162 m_max_y = sqlite3_column_double(pStmt, i);
165 else if ( colName ==
"srs_id" )
167 m_srs_id = sqlite3_column_int(pStmt, i);
173 << M <<
" Unhandled column name[" 174 << i <<
"]: " << colName << std::endl;
179 if ( columnsFound == EXPECTED_COLUMNS )
229 sql <<
"CREATE TABLE " << TABLE_NAME <<
" ( " 230 <<
"table_name TEXT NOT NULL PRIMARY KEY, " 231 <<
"data_type TEXT NOT NULL, " 232 <<
"identifier TEXT UNIQUE, " 233 <<
"description TEXT DEFAULT \"\", " 240 <<
"last_change DATETIME NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')), " 245 <<
"srs_id INTEGER, " 246 <<
"CONSTRAINT fk_gc_r_srs_id FOREIGN KEY (srs_id) " 247 <<
"REFERENCES gpkg_spatial_ref_sys(srs_id)" 265 sql <<
"INSERT INTO gpkg_contents VALUES ( " 271 << std::setprecision(16)
288 const std::string& prefix )
const 290 std::string myPref = prefix.size() ? prefix : std::string(
"gpkg_contents.");
293 std::string key =
"table_name";
310 kwl.
addPair(myPref, key, value,
true);
314 kwl.
addPair(myPref, key, value,
true);
318 kwl.
addPair(myPref, key, value,
true);
322 kwl.
addPair(myPref, key, value,
true);
326 kwl.
addPair(myPref, key, value,
true);
virtual ~ossimGpkgContentsRecord()
destructor
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Represents serializable keyword/value map.
int exec(sqlite3 *db, const std::string &sql)
Preforms sqlite3_prepare_v2, sqlite3_step and sqlite3_finalize.
double nan()
Method to return ieee floating point double precision NAN.
This code was derived from https://gist.github.com/mshockwave.
bool insert(sqlite3 *db)
Inserst this record into gpkg_spatial_ref_sys table.
bool tableExists(sqlite3 *db, const std::string &tableName)
Checks for existance of table.
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
static bool createTable(sqlite3 *db)
Creates table in database.
const ossimGpkgContentsRecord & operator=(const ossimGpkgContentsRecord ©_this)
std::string m_last_change
virtual bool init(sqlite3_stmt *pStmt)
Initialize from database.
virtual void saveState(ossimKeywordlist &kwl, const std::string &prefix) const
Saves the state of object to keyword list.
std::string m_description
void getTime(std::string &result)
Gets time in the form of "%Y-%m-%dT%H:%M:%S.000Z".
ossimGpkgContentsRecord()
default constructor
static const std::string & getTableName()
Get the table name "gpkg_contents".
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const