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

#include <ossimGpkgTileMatrixRecord.h>

Inheritance diagram for ossimGpkgTileMatrixRecord:
ossimGpkgDatabaseRecordBase ossimReferenced

Public Member Functions

 ossimGpkgTileMatrixRecord ()
 default constructor More...
 
 ossimGpkgTileMatrixRecord (const ossimGpkgTileMatrixRecord &obj)
 
const ossimGpkgTileMatrixRecordoperator= (const ossimGpkgTileMatrixRecord &obj)
 
virtual ~ossimGpkgTileMatrixRecord ()
 destructor More...
 
virtual bool init (sqlite3_stmt *pStmt)
 Initialize from database. More...
 
bool init (const std::string &tableName, ossim_int32 zoom_level, const ossimIpt &matrixSize, const ossimIpt &tileSize, const ossimDpt &gsd)
 Initialize method. 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 getMatrixSize (ossimIpt &size) const
 Get matrix size. More...
 
void getTileSize (ossimIpt &size) const
 Get tile size. More...
 
void getGsd (ossimDpt &gsd) const
 Get gsd. More...
 
- 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". More...
 
static bool createTable (sqlite3 *db)
 Creates table in database. More...
 

Public Attributes

std::string m_table_name
 
ossim_int32 m_zoom_level
 
ossim_int32 m_matrix_width
 
ossim_int32 m_matrix_height
 
ossim_int32 m_tile_width
 
ossim_int32 m_tile_height
 
ossim_float64 m_pixel_x_size
 
ossim_float64 m_pixel_y_size
 

Additional Inherited Members

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

Detailed Description

Definition at line 24 of file ossimGpkgTileMatrixRecord.h.

Constructor & Destructor Documentation

◆ ossimGpkgTileMatrixRecord() [1/2]

ossimGpkgTileMatrixRecord::ossimGpkgTileMatrixRecord ( )

default constructor

Definition at line 26 of file ossimGpkgTileMatrixRecord.cpp.

27  :
29  m_table_name(),
30  m_zoom_level(0),
31  m_matrix_width(0),
32  m_matrix_height(0),
33  m_tile_width(0),
34  m_tile_height(0),
37 {
38 }
ossimGpkgDatabaseRecordBase()
default constructor
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135

◆ ossimGpkgTileMatrixRecord() [2/2]

ossimGpkgTileMatrixRecord::ossimGpkgTileMatrixRecord ( const ossimGpkgTileMatrixRecord obj)

◆ ~ossimGpkgTileMatrixRecord()

ossimGpkgTileMatrixRecord::~ossimGpkgTileMatrixRecord ( )
virtual

destructor

Definition at line 154 of file ossimGpkgTileMatrixRecord.cpp.

155 {
156 }

Member Function Documentation

◆ createTable()

bool ossimGpkgTileMatrixRecord::createTable ( sqlite3 *  db)
static

Creates table in database.

Parameters
db
Returns
true on success, false on error.

Definition at line 97 of file ossimGpkgTileMatrixRecord.cpp.

References status, and ossim_sqlite::tableExists().

Referenced by ossimGpkgWriter::createTables().

98 {
99  bool status = false;
100  if ( db )
101  {
102  status = ossim_sqlite::tableExists( db, TABLE_NAME );
103  if ( !status )
104  {
105  std::ostringstream sql;
106  sql << "CREATE TABLE " << TABLE_NAME << " ( "
107  << "table_name TEXT NOT NULL, "
108  << "zoom_level INTEGER NOT NULL, "
109  << "matrix_width INTEGER NOT NULL, "
110  << "matrix_height INTEGER NOT NULL, "
111  << "tile_width INTEGER NOT NULL, "
112  << "tile_height INTEGER NOT NULL, "
113  << "pixel_x_size DOUBLE NOT NULL, "
114  << "pixel_y_size DOUBLE NOT NULL, "
115  << "CONSTRAINT pk_ttm PRIMARY KEY (table_name, zoom_level), "
116  << "CONSTRAINT fk_tmm_table_name FOREIGN KEY (table_name) REFERENCES gpkg_contents(table_name) "
117  << ")";
118 
119  if ( ossim_sqlite::exec( db, sql.str() ) == SQLITE_DONE )
120  {
121  status = true;
122  }
123  }
124  }
125  return status;
126 }
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

◆ getGsd()

void ossimGpkgTileMatrixRecord::getGsd ( ossimDpt gsd) const

Get gsd.

Parameters
gsdInitializes with pixel_x_size and pixel_y_size.

Definition at line 308 of file ossimGpkgTileMatrixRecord.cpp.

References m_pixel_x_size, m_pixel_y_size, ossimDpt::x, and ossimDpt::y.

309 {
310  gsd.x = m_pixel_x_size;
311  gsd.y = m_pixel_y_size;
312 }
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164

◆ getMatrixSize()

void ossimGpkgTileMatrixRecord::getMatrixSize ( ossimIpt size) const

Get matrix size.

Parameters
sizeInitialized with matrix_width and matrix_height.

Definition at line 296 of file ossimGpkgTileMatrixRecord.cpp.

References m_matrix_height, m_matrix_width, and size.

297 {
298  size.x = m_matrix_width;
299  size.y = m_matrix_height;
300 }
yy_size_t size

◆ getTableName()

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

Get the table name "gpkg_tile_matrix".

Returns
table name

Definition at line 158 of file ossimGpkgTileMatrixRecord.cpp.

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

159 {
160  return TABLE_NAME;
161 }

◆ getTileSize()

void ossimGpkgTileMatrixRecord::getTileSize ( ossimIpt size) const

Get tile size.

Parameters
sizeInitializes with tile_width and tile_height.

Definition at line 302 of file ossimGpkgTileMatrixRecord.cpp.

References m_tile_height, m_tile_width, and size.

303 {
304  size.x = m_tile_width;
305  size.y = m_tile_height;
306 }
yy_size_t size

◆ init() [1/2]

bool ossimGpkgTileMatrixRecord::init ( sqlite3_stmt *  pStmt)
virtual

Initialize from database.

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

Implements ossimGpkgDatabaseRecordBase.

Definition at line 163 of file ossimGpkgTileMatrixRecord.cpp.

References m_matrix_height, m_matrix_width, m_pixel_x_size, m_pixel_y_size, m_table_name, m_tile_height, m_tile_width, m_zoom_level, ossimNotify(), ossimNotifyLevel_WARN, and status.

Referenced by ossimGpkgWriter::writeGpkgTileMatrixTable().

164 {
165  static const char M[] = "ossimGpkgTileMatrixRecord::init";
166 
167  bool status = false;
168 
169  if ( pStmt )
170  {
171  const ossim_int32 EXPECTED_COLUMNS = 8;
172  ossim_int32 nCol = sqlite3_column_count( pStmt );
173 
174  if ( nCol != EXPECTED_COLUMNS )
175  {
177  << M << " WARNING:\nUnexpected number of columns: " << nCol
178  << "Expected column count: " << EXPECTED_COLUMNS
179  << std::endl;
180  }
181 
182  if ( nCol >= EXPECTED_COLUMNS )
183  {
184  ossim_int32 columnsFound = 0;
185  std::string colName;
186  const char* c = 0; // To catch null so not to pass to string.
187 
188  for ( ossim_int32 i = 0; i < nCol; ++i )
189  {
190  colName = sqlite3_column_name(pStmt, i);
191  if ( colName.size() )
192  {
193  if ( colName == "table_name" )
194  {
195  c = (const char*)sqlite3_column_text(pStmt, i);
196  m_table_name = (c ? c : "");
197  ++columnsFound;
198  }
199  else if ( colName == "zoom_level" )
200  {
201  m_zoom_level = sqlite3_column_int(pStmt, i);
202  ++columnsFound;
203  }
204  else if ( colName == "matrix_width" )
205  {
206  m_matrix_width = sqlite3_column_int(pStmt, i);
207  ++columnsFound;
208  }
209  else if ( colName == "matrix_height" )
210  {
211  m_matrix_height = sqlite3_column_int(pStmt, i);
212  ++columnsFound;
213  }
214  else if ( colName == "tile_width" )
215  {
216  m_tile_width = sqlite3_column_int(pStmt, i);
217  ++columnsFound;
218  }
219  else if ( colName == "tile_height" )
220  {
221  m_tile_height = sqlite3_column_int(pStmt, i);
222  ++columnsFound;
223  }
224  else if ( colName == "pixel_x_size" )
225  {
226  m_pixel_x_size = sqlite3_column_double(pStmt, i);
227  ++columnsFound;
228  }
229  else if ( colName == "pixel_y_size" )
230  {
231  m_pixel_y_size = sqlite3_column_double(pStmt, i);
232  ++columnsFound;
233  }
234  else
235  {
237  << M << " Unhandled column name["
238  << i << "]: " << colName << std::endl;
239  }
240 
241  } // Matches: if ( colName.size() )
242 
243  if ( columnsFound == EXPECTED_COLUMNS )
244  {
245  status = true;
246  break;
247  }
248 
249  } // Matches: for ( int i = 0; i < nCol; ++i )
250  }
251 
252  } // Matches: if ( pStmt )
253 
254  return status;
255 
256 } // End: ossimGpkgTileMatrixRecord::init( sqlite3_stmt* pStmt )
return status
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ init() [2/2]

bool ossimGpkgTileMatrixRecord::init ( const std::string &  tableName,
ossim_int32  zoom_level,
const ossimIpt matrixSize,
const ossimIpt tileSize,
const ossimDpt gsd 
)

Initialize method.

Parameters
tableNamee.g. "tiles"
Zoomlevel. Zero being whole Earth...
matrixSizeSize of tile matrix, i.e. number of horizontal vertical tiles.
tileSizeSize of one tile, e.g. 256 x 256.
gsdSize of one pixel either in meters or lat lon.
Returns
true on success, false on error.

Definition at line 71 of file ossimGpkgTileMatrixRecord.cpp.

References ossimIpt::hasNans(), ossimDpt::hasNans(), m_matrix_height, m_matrix_width, m_pixel_x_size, m_pixel_y_size, m_table_name, m_tile_height, m_tile_width, m_zoom_level, status, ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

76 {
77  bool status = false;
78 
79  if ( (matrixSize.hasNans() == false) && (tileSize.hasNans() == false) &&
80  (gsd.hasNans() == false) )
81  {
82  m_table_name = tableName;
83  m_zoom_level = zoom_level;
84  m_matrix_width = matrixSize.x;
85  m_matrix_height = matrixSize.y;
86  m_tile_width = tileSize.x;
87  m_tile_height = tileSize.y;
88  m_pixel_x_size = gsd.x;
89  m_pixel_y_size = gsd.y;
90  status = true;
91  }
92 
93  return status;
94 
95 } // End: ossimGpkgTileMatrixRecord::init( zoom_level, ... )
double y
Definition: ossimDpt.h:165
bool hasNans() const
Definition: ossimDpt.h:67
return status
ossim_int32 y
Definition: ossimIpt.h:142
double x
Definition: ossimDpt.h:164
ossim_int32 x
Definition: ossimIpt.h:141
bool hasNans() const
Definition: ossimIpt.h:58

◆ insert()

bool ossimGpkgTileMatrixRecord::insert ( sqlite3 *  db)

Inserst this record into gpkg_spatial_ref_sys table.

Parameters
db
Returns
true on success, false on error.

Definition at line 128 of file ossimGpkgTileMatrixRecord.cpp.

References ossim_sqlite::exec(), m_matrix_height, m_matrix_width, m_pixel_x_size, m_pixel_y_size, m_table_name, m_tile_height, m_tile_width, m_zoom_level, and status.

Referenced by ossimGpkgWriter::writeGpkgTileMatrixTable().

129 {
130  bool status = false;
131  if ( db )
132  {
133  std::ostringstream sql;
134  sql << "INSERT INTO gpkg_tile_matrix VALUES ( "
135  << "'" << m_table_name << "', "
136  << m_zoom_level << ", "
137  << m_matrix_width << ", "
138  << m_matrix_height << ", "
139  << m_tile_width << ", "
140  << m_tile_height << ", "
141  << std::setiosflags(std::ios::fixed) << std::setprecision(16)
142  << m_pixel_x_size << ", "
143  << m_pixel_y_size
144  << " )";
145 
146  if ( ossim_sqlite::exec( db, sql.str() ) == SQLITE_DONE )
147  {
148  status = true;
149  }
150  }
151  return status;
152 }
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 ossimGpkgTileMatrixRecord & ossimGpkgTileMatrixRecord::operator= ( const ossimGpkgTileMatrixRecord obj)

◆ saveState()

void ossimGpkgTileMatrixRecord::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 258 of file ossimGpkgTileMatrixRecord.cpp.

References ossimKeywordlist::addPair(), m_matrix_height, m_matrix_width, m_pixel_x_size, m_pixel_y_size, m_table_name, m_tile_height, m_tile_width, m_zoom_level, ossimString::string(), and ossimString::toString().

260 {
261  std::string myPref = prefix.size() ? prefix : std::string("gpkg_tile_matrix.");
262  std::string value;
263 
264  std::string key = "table_name";
265  kwl.addPair(myPref, key, m_table_name, true);
266 
267  key = "zoom_level";
269  kwl.addPair(myPref, key, value, true);
270 
271  key = "matrix_width";
273  kwl.addPair(myPref, key, value, true);
274 
275  key = "matrix_height";
277  kwl.addPair(myPref, key, value, true);
278 
279  key = "tile_width";
281  kwl.addPair(myPref, key, value, true);
282 
283  key = "tile_height";
285  kwl.addPair(myPref, key, value, true);
286 
287  key = "pixel_x_size";
288  value = ossimString::toString(m_pixel_x_size, 15, true).string();
289  kwl.addPair(myPref, key, value, true);
290 
291  key = "pixel_y_size";
292  value = ossimString::toString(m_pixel_y_size, 15, true).string();
293  kwl.addPair(myPref, key, value, true);
294 }
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_matrix_height

ossim_int32 ossimGpkgTileMatrixRecord::m_matrix_height

Definition at line 111 of file ossimGpkgTileMatrixRecord.h.

Referenced by getMatrixSize(), init(), insert(), operator=(), and saveState().

◆ m_matrix_width

ossim_int32 ossimGpkgTileMatrixRecord::m_matrix_width

Definition at line 110 of file ossimGpkgTileMatrixRecord.h.

Referenced by getMatrixSize(), init(), insert(), operator=(), and saveState().

◆ m_pixel_x_size

ossim_float64 ossimGpkgTileMatrixRecord::m_pixel_x_size

Definition at line 114 of file ossimGpkgTileMatrixRecord.h.

Referenced by getGsd(), init(), insert(), operator=(), and saveState().

◆ m_pixel_y_size

ossim_float64 ossimGpkgTileMatrixRecord::m_pixel_y_size

Definition at line 115 of file ossimGpkgTileMatrixRecord.h.

Referenced by getGsd(), init(), insert(), operator=(), and saveState().

◆ m_table_name

std::string ossimGpkgTileMatrixRecord::m_table_name

Definition at line 108 of file ossimGpkgTileMatrixRecord.h.

Referenced by init(), insert(), operator=(), and saveState().

◆ m_tile_height

ossim_int32 ossimGpkgTileMatrixRecord::m_tile_height

Definition at line 113 of file ossimGpkgTileMatrixRecord.h.

Referenced by getTileSize(), init(), insert(), operator=(), and saveState().

◆ m_tile_width

ossim_int32 ossimGpkgTileMatrixRecord::m_tile_width

Definition at line 112 of file ossimGpkgTileMatrixRecord.h.

Referenced by getTileSize(), init(), insert(), operator=(), and saveState().

◆ m_zoom_level

ossim_int32 ossimGpkgTileMatrixRecord::m_zoom_level

Definition at line 109 of file ossimGpkgTileMatrixRecord.h.

Referenced by init(), insert(), operator=(), and saveState().


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