OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ossimGpkgTileMatrixSetRecord Class Reference

#include <ossimGpkgTileMatrixSetRecord.h>

Inheritance diagram for ossimGpkgTileMatrixSetRecord:
ossimGpkgDatabaseRecordBase ossimReferenced

Public Member Functions

 ossimGpkgTileMatrixSetRecord ()
 default constructor More...
 
 ossimGpkgTileMatrixSetRecord (const ossimGpkgTileMatrixSetRecord &obj)
 
const ossimGpkgTileMatrixSetRecordoperator= (const ossimGpkgTileMatrixSetRecord &obj)
 
virtual ~ossimGpkgTileMatrixSetRecord ()
 destructor More...
 
virtual bool init (sqlite3_stmt *pStmt)
 Initialize from database. More...
 
bool init (const std::string &tableName, ossim_int32 srs_id, const ossimDpt &minPt, const ossimDpt &maxPt)
 Initialize from projection. More...
 
bool insert (sqlite3 *db)
 Inserst this record into gpkg_spatial_ref_sys table. More...
 
virtual void saveState (ossimKeywordlist &kwl, const std::string &prefix) const
 Saves the state of object. More...
 
void getRect (ossimDrect &rect) const
 Gets the rectangle from bounds. More...
 
ossim_float64 getWidth () const
 
ossim_float64 getHeight () const
 
- Public Member Functions inherited from ossimGpkgDatabaseRecordBase
 ossimGpkgDatabaseRecordBase ()
 default constructor More...
 
virtual ~ossimGpkgDatabaseRecordBase ()
 virtual destructor. More...
 
virtual std::ostream & print (std::ostream &out) const
 Print method. More...
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Static Public Member Functions

static const std::string & getTableName ()
 Get the table name "gpkg_tile_matrix_set". More...
 
static bool createTable (sqlite3 *db)
 Creates table in database. More...
 

Public Attributes

std::string m_table_name
 
ossim_int32 m_srs_id
 
ossim_float64 m_min_x
 
ossim_float64 m_min_y
 
ossim_float64 m_max_x
 
ossim_float64 m_max_y
 

Additional Inherited Members

- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Detailed Description

Definition at line 24 of file ossimGpkgTileMatrixSetRecord.h.

Constructor & Destructor Documentation

◆ ossimGpkgTileMatrixSetRecord() [1/2]

ossimGpkgTileMatrixSetRecord::ossimGpkgTileMatrixSetRecord ( )

default constructor

Definition at line 26 of file ossimGpkgTileMatrixSetRecord.cpp.

◆ ossimGpkgTileMatrixSetRecord() [2/2]

ossimGpkgTileMatrixSetRecord::ossimGpkgTileMatrixSetRecord ( const ossimGpkgTileMatrixSetRecord obj)

◆ ~ossimGpkgTileMatrixSetRecord()

ossimGpkgTileMatrixSetRecord::~ossimGpkgTileMatrixSetRecord ( )
virtual

destructor

Definition at line 65 of file ossimGpkgTileMatrixSetRecord.cpp.

66 {
67 }

Member Function Documentation

◆ createTable()

bool ossimGpkgTileMatrixSetRecord::createTable ( sqlite3 *  db)
static

Creates table in database.

Parameters
db
Returns
true on success, false on error.

Definition at line 177 of file ossimGpkgTileMatrixSetRecord.cpp.

References status, and ossim_sqlite::tableExists().

Referenced by ossimGpkgWriter::createTables().

178 {
179  bool status = false;
180  if ( db )
181  {
182  status = ossim_sqlite::tableExists( db, TABLE_NAME );
183  if ( !status )
184  {
185  std::ostringstream sql;
186  sql << "CREATE TABLE " << TABLE_NAME << " ( "
187  << "table_name TEXT NOT NULL PRIMARY KEY, "
188  << "srs_id INTEGER NOT NULL, "
189  << "min_x DOUBLE NOT NULL, "
190  << "min_y DOUBLE NOT NULL, "
191  << "max_x DOUBLE NOT NULL, "
192  << "max_y DOUBLE NOT NULL, "
193  << "CONSTRAINT fk_gtms_table_name FOREIGN KEY (table_name) REFERENCES gpkg_contents(table_name), "
194  << "CONSTRAINT fk_gtms_srs FOREIGN KEY (srs_id) REFERENCES gpkg_spatial_ref_sys (srs_id) "
195  << ")";
196 
197  if ( ossim_sqlite::exec( db, sql.str() ) == SQLITE_DONE )
198  {
199  status = true;
200  }
201  }
202  }
203  return status;
204 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
int exec(sqlite3 *db, const std::string &sql)
Preforms sqlite3_prepare_v2, sqlite3_step and sqlite3_finalize.
bool tableExists(sqlite3 *db, const std::string &tableName)
Checks for existance of table.
return status

◆ getHeight()

ossim_float64 ossimGpkgTileMatrixSetRecord::getHeight ( ) const
Returns
height

Definition at line 240 of file ossimGpkgTileMatrixSetRecord.cpp.

References m_max_y, and m_min_y.

Referenced by ossimGpkgTileEntry::printValidate().

◆ getRect()

void ossimGpkgTileMatrixSetRecord::getRect ( ossimDrect rect) const

Gets the rectangle from bounds.

Parameters
rectInitialized by this.

Definition at line 230 of file ossimGpkgTileMatrixSetRecord.cpp.

References m_max_x, m_max_y, m_min_x, m_min_y, and OSSIM_RIGHT_HANDED.

◆ getTableName()

const std::string & ossimGpkgTileMatrixSetRecord::getTableName ( )
static

Get the table name "gpkg_tile_matrix_set".

Returns
table name

Definition at line 69 of file ossimGpkgTileMatrixSetRecord.cpp.

Referenced by ossim_gpkg::getNewTableRecord(), ossim_gpkg::getTileEntries(), and ossim_gpkg::getTileEntry().

70 {
71  return TABLE_NAME;
72 }

◆ getWidth()

ossim_float64 ossimGpkgTileMatrixSetRecord::getWidth ( ) const
Returns
width

Definition at line 235 of file ossimGpkgTileMatrixSetRecord.cpp.

References m_max_x, and m_min_x.

Referenced by ossimGpkgTileEntry::printValidate().

◆ init() [1/2]

bool ossimGpkgTileMatrixSetRecord::init ( sqlite3_stmt *  pStmt)
virtual

Initialize from database.

Parameters
pStmtSQL statement, i.e. result of sqlite3_prepare_v2(...) call.

Implements ossimGpkgDatabaseRecordBase.

Definition at line 74 of file ossimGpkgTileMatrixSetRecord.cpp.

References m_max_x, m_max_y, m_min_x, m_min_y, m_srs_id, m_table_name, ossimNotify(), ossimNotifyLevel_WARN, and status.

Referenced by ossimGpkgWriter::writeGpkgTileMatrixSetTable().

75 {
76  static const char M[] = "ossimGpkgTileMatrixSetRecord::init";
77 
78  bool status = false;
79 
80  if ( pStmt )
81  {
82  const ossim_int32 EXPECTED_COLUMNS = 6;
83  ossim_int32 nCol = sqlite3_column_count( pStmt );
84 
85  if ( nCol != EXPECTED_COLUMNS )
86  {
88  << M << " WARNING:\nUnexpected number of columns: " << nCol
89  << "Expected column count: " << EXPECTED_COLUMNS
90  << std::endl;
91  }
92 
93  if ( nCol >= EXPECTED_COLUMNS )
94  {
95  ossim_int32 columnsFound = 0;
96  std::string colName;
97  const char* c = 0; // To catch null so not to pass to string.
98 
99  for ( ossim_int32 i = 0; i < nCol; ++i )
100  {
101  colName = sqlite3_column_name(pStmt, i);
102  if ( colName.size() )
103  {
104  if ( colName == "table_name" )
105  {
106  c = (const char*)sqlite3_column_text(pStmt, i);
107  m_table_name = (c ? c : "");
108  ++columnsFound;
109  }
110  else if ( colName == "srs_id" )
111  {
112  m_srs_id = sqlite3_column_int(pStmt, i);
113  ++columnsFound;
114  }
115  else if ( colName == "min_x" )
116  {
117  m_min_x = sqlite3_column_double(pStmt, i);
118  ++columnsFound;
119  }
120  else if ( colName == "min_y" )
121  {
122  m_min_y = sqlite3_column_double(pStmt, i);
123  ++columnsFound;
124  }
125  else if ( colName == "max_x" )
126  {
127  m_max_x = sqlite3_column_double(pStmt, i);
128  ++columnsFound;
129  }
130  else if ( colName == "max_y" )
131  {
132  m_max_y = sqlite3_column_double(pStmt, i);
133  ++columnsFound;
134  }
135  else
136  {
138  << M << " Unhandled column name["
139  << i << "]: " << colName << std::endl;
140  }
141 
142  } // Matches: if ( colName.size() )
143 
144  if ( columnsFound == EXPECTED_COLUMNS )
145  {
146  status = true;
147  break;
148  }
149 
150  } // Matches: for ( int i = 0; i < nCol; ++i )
151  }
152 
153  } // Matches: if ( pStmt )
154 
155  return status;
156 
157 } // End: ossimGpkgTileMatrixSetRecord::init( pStmt )
return status
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ init() [2/2]

bool ossimGpkgTileMatrixSetRecord::init ( const std::string &  tableName,
ossim_int32  srs_id,
const ossimDpt minPt,
const ossimDpt maxPt 
)

Initialize from projection.

Parameters
tableNamee.g. "tiles"
srs_idID of gpkg_spatial_ref_sys record our projection is relative to.
minPtMinimum bounds in either Easting Northin or lat lon.
maxPtMaximum bounds in either Easting Northin or lat lon.
Returns
true on success, false on error.

Definition at line 159 of file ossimGpkgTileMatrixSetRecord.cpp.

References ossimDpt::hasNans(), m_max_x, m_max_y, m_min_x, m_min_y, m_srs_id, m_table_name, status, ossimDpt::x, and ossimDpt::y.

162 {
163  bool status = false;
164  if ( (minPt.hasNans() == false) && (maxPt.hasNans() == false) )
165  {
166  m_table_name = tableName;
167  m_srs_id = srs_id;
168  m_min_x = minPt.x;
169  m_min_y = minPt.y;
170  m_max_x = maxPt.x;
171  m_max_y = maxPt.y;
172  status = true;
173  }
174  return status;
175 }
double y
Definition: ossimDpt.h:165
bool hasNans() const
Definition: ossimDpt.h:67
return status
double x
Definition: ossimDpt.h:164

◆ insert()

bool ossimGpkgTileMatrixSetRecord::insert ( sqlite3 *  db)

Inserst this record into gpkg_spatial_ref_sys table.

Parameters
db
Returns
true on success, false on error.

Definition at line 206 of file ossimGpkgTileMatrixSetRecord.cpp.

References ossim_sqlite::exec(), m_max_x, m_max_y, m_min_x, m_min_y, m_srs_id, m_table_name, and status.

Referenced by ossimGpkgWriter::writeGpkgTileMatrixSetTable().

207 {
208  bool status = false;
209  if ( db )
210  {
211  std::ostringstream sql;
212  sql << "INSERT INTO gpkg_tile_matrix_set VALUES ( "
213  << "'" << m_table_name << "', "
214  << m_srs_id << ", "
215  << std::setprecision(16)
216  << m_min_x << ", "
217  << m_min_y << ", "
218  << m_max_x << ", "
219  << m_max_y
220  << " )";
221 
222  if ( ossim_sqlite::exec( db, sql.str() ) == SQLITE_DONE )
223  {
224  status = true;
225  }
226  }
227  return status;
228 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
int exec(sqlite3 *db, const std::string &sql)
Preforms sqlite3_prepare_v2, sqlite3_step and sqlite3_finalize.
return status

◆ operator=()

const ossimGpkgTileMatrixSetRecord & ossimGpkgTileMatrixSetRecord::operator= ( const ossimGpkgTileMatrixSetRecord obj)

Definition at line 50 of file ossimGpkgTileMatrixSetRecord.cpp.

References m_max_x, m_max_y, m_min_x, m_min_y, m_srs_id, and m_table_name.

52 {
53  if ( this != &obj )
54  {
56  m_srs_id = obj.m_srs_id;
57  m_min_x = obj.m_min_x;
58  m_min_y = obj.m_min_y;
59  m_max_x = obj.m_max_x;
60  m_max_y = obj.m_max_y;
61  }
62  return *this;
63 }

◆ saveState()

void ossimGpkgTileMatrixSetRecord::saveState ( ossimKeywordlist kwl,
const std::string &  prefix 
) const
virtual

Saves the state of object.

Parameters
kwlInitialized by this.
prefixe.g. "image0.". Can be empty.

Implements ossimGpkgDatabaseRecordBase.

Definition at line 245 of file ossimGpkgTileMatrixSetRecord.cpp.

References ossimKeywordlist::addPair(), m_max_x, m_max_y, m_min_x, m_min_y, m_srs_id, m_table_name, ossimString::string(), and ossimString::toString().

Referenced by ossimGpkgTileEntry::saveState().

247 {
248  std::string myPref = prefix.size() ? prefix : std::string("gpkg_tile_matrix_set.");
249  std::string value;
250 
251  std::string key = "table_name";
252  kwl.addPair(myPref, key, m_table_name, true);
253 
254  key = "srs_id";
256  kwl.addPair(myPref, key, value, true);
257 
258  key = "min_x";
259  value = ossimString::toString(m_min_x, 15).string();
260  kwl.addPair(myPref, key, value, true);
261 
262  key = "min_y";
263  value = ossimString::toString(m_min_y, 15).string();
264  kwl.addPair(myPref, key, value, true);
265 
266  key = "max_x";
267  value = ossimString::toString(m_max_x, 15).string();
268  kwl.addPair(myPref, key, value, true);
269 
270  key = "max_y";
271  value = ossimString::toString(m_max_y, 15).string();
272  kwl.addPair(myPref, key, value, true);
273 }
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
const std::string & string() const
Definition: ossimString.h:414

Member Data Documentation

◆ m_max_x

ossim_float64 ossimGpkgTileMatrixSetRecord::m_max_x

◆ m_max_y

ossim_float64 ossimGpkgTileMatrixSetRecord::m_max_y

◆ m_min_x

ossim_float64 ossimGpkgTileMatrixSetRecord::m_min_x

◆ m_min_y

ossim_float64 ossimGpkgTileMatrixSetRecord::m_min_y

◆ m_srs_id

ossim_int32 ossimGpkgTileMatrixSetRecord::m_srs_id

◆ m_table_name

std::string ossimGpkgTileMatrixSetRecord::m_table_name

The documentation for this class was generated from the following files: