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

#include <ossimGpkgNsgTileMatrixExtentRecord.h>

Inheritance diagram for ossimGpkgNsgTileMatrixExtentRecord:
ossimGpkgDatabaseRecordBase ossimReferenced

Public Member Functions

 ossimGpkgNsgTileMatrixExtentRecord ()
 default constructor More...
 
 ossimGpkgNsgTileMatrixExtentRecord (const ossimGpkgNsgTileMatrixExtentRecord &obj)
 
const ossimGpkgNsgTileMatrixExtentRecordoperator= (const ossimGpkgNsgTileMatrixExtentRecord &obj)
 
virtual ~ossimGpkgNsgTileMatrixExtentRecord ()
 destructor More...
 
virtual bool init (sqlite3_stmt *pStmt)
 Initialize from database. More...
 
bool init (const std::string &tableName, ossim_int32 zoom_level, const ossimIrect &imageRect, const ossimDrect &projectionRect)
 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...
 
- 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 "nsg_tile_matrix_extent". More...
 
static bool createTable (sqlite3 *db)
 Creates table in database. More...
 

Public Attributes

std::string m_table_name
 
ossim_int32 m_zoom_level
 
std::string m_extent_type
 “complete”,”missing”,“present”,”absent”,”mixed” More...
 
ossim_int32 m_min_column
 
ossim_int32 m_min_row
 
ossim_int32 m_max_column
 
ossim_int32 m_max_row
 
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 ossimGpkgNsgTileMatrixExtentRecord.h.

Constructor & Destructor Documentation

◆ ossimGpkgNsgTileMatrixExtentRecord() [1/2]

ossimGpkgNsgTileMatrixExtentRecord::ossimGpkgNsgTileMatrixExtentRecord ( )

default constructor

Definition at line 27 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

28  :
30  m_table_name(),
31  m_zoom_level(0),
32  m_extent_type(),
33  m_min_column(0),
34  m_min_row(0),
35  m_max_column(0),
36  m_max_row(0),
41 {
42 }
ossimGpkgDatabaseRecordBase()
default constructor
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”

◆ ossimGpkgNsgTileMatrixExtentRecord() [2/2]

ossimGpkgNsgTileMatrixExtentRecord::ossimGpkgNsgTileMatrixExtentRecord ( const ossimGpkgNsgTileMatrixExtentRecord obj)

Definition at line 44 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

46  :
52  m_min_row(obj.m_min_row),
54  m_max_row(obj.m_max_row),
55  m_min_x(obj.m_min_x),
56  m_min_y(obj.m_min_y),
57  m_max_x(obj.m_max_x),
58  m_max_y(obj.m_max_y)
59 {
60 }
ossimGpkgDatabaseRecordBase()
default constructor
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”

◆ ~ossimGpkgNsgTileMatrixExtentRecord()

ossimGpkgNsgTileMatrixExtentRecord::~ossimGpkgNsgTileMatrixExtentRecord ( )
virtual

destructor

Definition at line 82 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

83 {
84 }

Member Function Documentation

◆ createTable()

bool ossimGpkgNsgTileMatrixExtentRecord::createTable ( sqlite3 *  db)
static

Creates table in database.

Parameters
db
Returns
true on success, false on error.

Definition at line 230 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

References status, and ossim_sqlite::tableExists().

Referenced by ossimGpkgWriter::createTables().

231 {
232  bool status = false;
233  if ( db )
234  {
235  status = ossim_sqlite::tableExists( db, TABLE_NAME );
236  if ( !status )
237  {
238  std::ostringstream sql;
239  sql << "CREATE TABLE " << TABLE_NAME << " ( "
240  << "table_name TEXT NOT NULL, "
241  << "zoom_level INTEGER NOT NULL, "
242  << "extent_type TEXT NOT NULL, "
243  << "min_column INTEGER NOT NULL, "
244  << "min_row INTEGER NOT NULL, "
245  << "max_column INTEGER NOT NULL, "
246  << "max_row INTEGER NOT NULL, "
247  << "min_x DOUBLE NOT NULL, "
248  << "min_y DOUBLE NOT NULL, "
249  << "max_x DOUBLE NOT NULL, "
250  << "max_y DOUBLE NOT NULL, "
251  << "CONSTRAINT pk_ntme PRIMARY KEY (table_name, zoom_level, extent_type, min_column, min_row, max_column, max_row), "
252  << "CONSTRAINT fk_ntme FOREIGN KEY (table_name, zoom_level) "
253  << "REFERENCES gpkg_tile_matrix(table_name, zoom_level)"
254  << ")";
255 
256  if ( ossim_sqlite::exec( db, sql.str() ) == SQLITE_DONE )
257  {
258  status = true;
259  }
260  }
261  }
262  return status;
263 }
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

◆ getTableName()

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

Get the table name "nsg_tile_matrix_extent".

Returns
table name

Definition at line 86 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

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

87 {
88  return TABLE_NAME;
89 }

◆ init() [1/2]

bool ossimGpkgNsgTileMatrixExtentRecord::init ( sqlite3_stmt *  pStmt)
virtual

Initialize from database.

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

Implements ossimGpkgDatabaseRecordBase.

Definition at line 91 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

References m_extent_type, m_max_column, m_max_row, m_max_x, m_max_y, m_min_column, m_min_row, m_min_x, m_min_y, m_table_name, m_zoom_level, ossimNotify(), ossimNotifyLevel_WARN, and status.

92 {
93  static const char M[] = "ossimGpkgNsgTileMatrixExtentRecord::init";
94 
95  bool status = false;
96 
97  if ( pStmt )
98  {
99  const ossim_int32 EXPECTED_COLUMNS = 11;
100  ossim_int32 nCol = sqlite3_column_count( pStmt );
101 
102  if ( nCol != EXPECTED_COLUMNS )
103  {
105  << M << " WARNING:\nUnexpected number of columns: " << nCol
106  << "Expected column count: " << EXPECTED_COLUMNS
107  << std::endl;
108  }
109 
110  if ( nCol >= EXPECTED_COLUMNS )
111  {
112  ossim_int32 columnsFound = 0;
113  std::string colName;
114  ossim_int32 type;
115 
116  const char* c = 0; // To catch null so not to pass to string.
117 
118  for ( ossim_int32 i = 0; i < nCol; ++i )
119  {
120  colName = sqlite3_column_name(pStmt, i);
121  type = sqlite3_column_type(pStmt, i);
122  if ( colName.size() )
123  {
124  if ( colName == "table_name" )
125  {
126  c = (const char*)sqlite3_column_text(pStmt, i);
127  m_table_name = (c ? c : "");
128  ++columnsFound;
129  }
130  else if ( ( colName == "zoom_level" ) && ( type == SQLITE_INTEGER ) )
131  {
132  m_zoom_level = sqlite3_column_int(pStmt, i);
133  ++columnsFound;
134  }
135  else if ( colName == "extent_type" )
136  {
137  c = (const char*)sqlite3_column_text(pStmt, i);
138  m_extent_type = (c ? c : "");
139  ++columnsFound;
140  }
141  else if ( ( colName == "min_column" ) && ( type == SQLITE_INTEGER ) )
142  {
143  m_min_column = sqlite3_column_int(pStmt, i);
144  ++columnsFound;
145  }
146  else if ( ( colName == "min_row" ) && ( type == SQLITE_INTEGER ) )
147  {
148  m_min_row = sqlite3_column_int(pStmt, i);
149  ++columnsFound;
150  }
151  else if ( ( colName == "max_column" ) && ( type == SQLITE_INTEGER ) )
152  {
153  m_max_column = sqlite3_column_int(pStmt, i);
154  ++columnsFound;
155  }
156  else if ( ( colName == "max_row" ) && ( type == SQLITE_INTEGER ) )
157  {
158  m_max_row = sqlite3_column_int(pStmt, i);
159  ++columnsFound;
160  }
161  else if ( ( colName == "min_x" ) && ( type == SQLITE_FLOAT ) )
162  {
163  m_min_x = sqlite3_column_double(pStmt, i);
164  ++columnsFound;
165  }
166  else if ( ( colName == "min_y" ) && ( type == SQLITE_FLOAT ) )
167  {
168  m_min_y = sqlite3_column_double(pStmt, i);
169  ++columnsFound;
170  }
171  else if ( ( colName == "max_x" ) && ( type == SQLITE_FLOAT ) )
172  {
173  m_max_x = sqlite3_column_double(pStmt, i);
174  ++columnsFound;
175  }
176  else if ( colName == "max_y" )
177  {
178  m_max_y = sqlite3_column_double(pStmt, i);
179  ++columnsFound;
180  }
181  else
182  {
184  << M << " Unhandled column name["
185  << i << "]: " << colName << std::endl;
186  }
187 
188  } // Matches: if ( colName.size() )
189 
190  if ( columnsFound == EXPECTED_COLUMNS )
191  {
192  status = true;
193  break;
194  }
195 
196  } // Matches: for ( int i = 0; i < nCol; ++i )
197  }
198 
199  } // Matches: if ( pStmt )
200 
201  return status;
202 
203 } // End: ossimGpkgNsgTileMatrixExtentRecord::init( pStmt )
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”
return status
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ init() [2/2]

bool ossimGpkgNsgTileMatrixExtentRecord::init ( const std::string &  tableName,
ossim_int32  zoom_level,
const ossimIrect imageRect,
const ossimDrect projectionRect 
)

Initialize from projection.

Parameters
tableNamee.g. "tiles"
zoom_level
imageRect
projectionRectEdge to edge either Easting Northin or lat lon.
Returns
true on success, false on error.

Definition at line 205 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

References ossimIrect::hasNans(), ossimDrect::hasNans(), ossimDrect::ll(), ossimIrect::lr(), m_extent_type, m_max_column, m_max_row, m_max_x, m_max_y, m_min_column, m_min_row, m_min_x, m_min_y, m_table_name, m_zoom_level, status, ossimIrect::ul(), ossimDrect::ur(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

209 {
210  bool status = false;
211  if ( (imageRect.hasNans() == false) && (projectionRect.hasNans() == false) )
212  {
213  m_table_name = tableName;
214  m_zoom_level = zoom_level;
215  m_extent_type = "complete";
216  m_min_column = imageRect.ul().x;
217  m_min_row = imageRect.ul().y;
218  m_max_column = imageRect.lr().x;
219  m_max_row = imageRect.lr().y;
220  m_min_x = projectionRect.ll().x;
221  m_min_y = projectionRect.ll().y;
222  m_max_x = projectionRect.ur().x;
223  m_max_y = projectionRect.ur().y;
224 
225  status = true;
226  }
227  return status;
228 }
double y
Definition: ossimDpt.h:165
const ossimIpt & ul() const
Definition: ossimIrect.h:274
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”
const ossimIpt & lr() const
Definition: ossimIrect.h:276
bool hasNans() const
Definition: ossimDrect.h:396
return status
ossim_int32 y
Definition: ossimIpt.h:142
const ossimDpt & ur() const
Definition: ossimDrect.h:340
double x
Definition: ossimDpt.h:164
bool hasNans() const
Definition: ossimIrect.h:337
ossim_int32 x
Definition: ossimIpt.h:141
const ossimDpt & ll() const
Definition: ossimDrect.h:342

◆ insert()

bool ossimGpkgNsgTileMatrixExtentRecord::insert ( sqlite3 *  db)

Inserst this record into gpkg_spatial_ref_sys table.

Parameters
db
Returns
true on success, false on error.

Definition at line 265 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

References ossim_sqlite::exec(), m_extent_type, m_max_column, m_max_row, m_max_x, m_max_y, m_min_column, m_min_row, m_min_x, m_min_y, m_table_name, m_zoom_level, and status.

266 {
267  bool status = false;
268  if ( db )
269  {
270  std::ostringstream sql;
271  sql << "INSERT INTO nsg_tile_matrix_extent VALUES ( "
272  << "'" << m_table_name << "', "
273  << m_zoom_level << ", "
274  << "'" << m_extent_type << "', "
275  << m_min_column << ", "
276  << m_min_row << ", "
277  << m_max_column << ", "
278  << m_max_row << ", "
279  << std::setprecision(16)
280  << m_min_x << ", "
281  << m_min_y << ", "
282  << m_max_x << ", "
283  << m_max_y
284  << " )";
285 
286  if ( ossim_sqlite::exec( db, sql.str() ) == SQLITE_DONE )
287  {
288  status = true;
289  }
290  }
291  return status;
292 }
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.
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”
return status

◆ operator=()

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

Definition at line 62 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

References m_extent_type, m_max_column, m_max_row, m_max_x, m_max_y, m_min_column, m_min_row, m_min_x, m_min_y, m_table_name, and m_zoom_level.

64 {
65  if ( this != &obj )
66  {
71  m_min_row = obj.m_min_row;
73  m_max_row = obj.m_max_row;
74  m_min_x = obj.m_min_x;
75  m_min_y = obj.m_min_y;
76  m_max_x = obj.m_max_x;
77  m_max_y = obj.m_max_y;
78  }
79  return *this;
80 }
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”

◆ saveState()

void ossimGpkgNsgTileMatrixExtentRecord::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 294 of file ossimGpkgNsgTileMatrixExtentRecord.cpp.

References ossimKeywordlist::addPair(), m_extent_type, m_max_column, m_max_row, m_max_x, m_max_y, m_min_column, m_min_row, m_min_x, m_min_y, m_table_name, m_zoom_level, ossimString::string(), and ossimString::toString().

296 {
297  std::string myPref = prefix.size() ? prefix : std::string("nsg_tile_matrix_extent.");
298  std::string value;
299 
300  std::string key = "table_name";
301  kwl.addPair(myPref, key, m_table_name, true);
302 
303  key = "zoom_level";
305  kwl.addPair(myPref, key, value, true);
306 
307  key = "extent_type";
308  kwl.addPair(myPref, key, m_extent_type, true);
309 
310  key = "min_column";
312  kwl.addPair(myPref, key, value, true);
313 
314  key = "min_row";
316  kwl.addPair(myPref, key, value, true);
317 
318  key = "max_column";
320  kwl.addPair(myPref, key, value, true);
321 
322  key = "max_row";
324  kwl.addPair(myPref, key, value, true);
325 
326  key = "min_x";
327  value = ossimString::toString(m_min_x, 20).string();
328  kwl.addPair(myPref, key, value, true);
329 
330  key = "min_y";
331  value = ossimString::toString(m_min_y, 20).string();
332  kwl.addPair(myPref, key, value, true);
333 
334  key = "max_x";
335  value = ossimString::toString(m_max_x, 20).string();
336  kwl.addPair(myPref, key, value, true);
337 
338  key = "max_y";
339  value = ossimString::toString(m_max_y, 20).string();
340  kwl.addPair(myPref, key, value, true);
341 }
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
std::string m_extent_type
“complete”,”missing”,“present”,”absent”,”mixed”
const std::string & string() const
Definition: ossimString.h:414

Member Data Documentation

◆ m_extent_type

std::string ossimGpkgNsgTileMatrixExtentRecord::m_extent_type

“complete”,”missing”,“present”,”absent”,”mixed”

Definition at line 92 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_max_column

ossim_int32 ossimGpkgNsgTileMatrixExtentRecord::m_max_column

Definition at line 96 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_max_row

ossim_int32 ossimGpkgNsgTileMatrixExtentRecord::m_max_row

Definition at line 97 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_max_x

ossim_float64 ossimGpkgNsgTileMatrixExtentRecord::m_max_x

Definition at line 100 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_max_y

ossim_float64 ossimGpkgNsgTileMatrixExtentRecord::m_max_y

Definition at line 101 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_min_column

ossim_int32 ossimGpkgNsgTileMatrixExtentRecord::m_min_column

Definition at line 94 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_min_row

ossim_int32 ossimGpkgNsgTileMatrixExtentRecord::m_min_row

Definition at line 95 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_min_x

ossim_float64 ossimGpkgNsgTileMatrixExtentRecord::m_min_x

Definition at line 98 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_min_y

ossim_float64 ossimGpkgNsgTileMatrixExtentRecord::m_min_y

Definition at line 99 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_table_name

std::string ossimGpkgNsgTileMatrixExtentRecord::m_table_name

Definition at line 88 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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

◆ m_zoom_level

ossim_int32 ossimGpkgNsgTileMatrixExtentRecord::m_zoom_level

Definition at line 89 of file ossimGpkgNsgTileMatrixExtentRecord.h.

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


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