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

GeoPackage info class. More...

#include <ossimGpkgInfo.h>

Inheritance diagram for ossimGpkgInfo:
ossimInfoBase ossimReferenced

Public Member Functions

 ossimGpkgInfo ()
 default constructor More...
 
virtual ~ossimGpkgInfo ()
 virtual destructor More...
 
virtual bool open (const ossimFilename &file)
 open method. More...
 
virtual std::ostream & print (std::ostream &out) const
 Print method. More...
 
- Public Member Functions inherited from ossimInfoBase
 ossimInfoBase ()
 default constructor More...
 
virtual bool open (std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
 open method. More...
 
void setProcessOverviewFlag (bool flag)
 Sets the overview flag. More...
 
bool getProcessOverviewFlag () const
 Method to get the overview flag. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl) const
 Method to dump info to a keyword list. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl, ossim_uint32 entryIndex) const
 Method to dump info to a keyword list. 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
 

Private Attributes

ossimFilename m_file
 

Additional Inherited Members

- Protected Member Functions inherited from ossimInfoBase
virtual ~ossimInfoBase ()
 virtual destructor More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Attributes inherited from ossimInfoBase
bool theOverviewFlag
 

Detailed Description

GeoPackage info class.

Encapsulates the listgeo functionality.

Definition at line 26 of file ossimGpkgInfo.h.

Constructor & Destructor Documentation

◆ ossimGpkgInfo()

ossimGpkgInfo::ossimGpkgInfo ( )

default constructor

Definition at line 31 of file ossimGpkgInfo.cpp.

32  : ossimInfoBase(),
33  m_file()
34 {
35 }
ossimFilename m_file
Definition: ossimGpkgInfo.h:56
ossimInfoBase()
default constructor

◆ ~ossimGpkgInfo()

ossimGpkgInfo::~ossimGpkgInfo ( )
virtual

virtual destructor

Definition at line 37 of file ossimGpkgInfo.cpp.

38 {
39 }

Member Function Documentation

◆ open()

bool ossimGpkgInfo::open ( const ossimFilename file)
virtual

open method.

Parameters
fileFile name to open.
Returns
true on success false on error.

Reimplemented from ossimInfoBase.

Definition at line 41 of file ossimGpkgInfo.cpp.

References ossimString::c_str(), ossim_gpkg::checkSignature(), m_file, and ossimString::size().

42 {
43  bool result = false;
44 
45  if ( file.size() ) // Check for empty filename.
46  {
47  std::ifstream str;
48  str.open( file.c_str(), std::ios_base::in | std::ios_base::binary);
49 
50  if ( str.good() ) // Open good...
51  {
52  if ( ossim_gpkg::checkSignature( str ) ) // Has "SQLite format 3" signature.
53  {
54  m_file = file;
55  result = true;
56  }
57  }
58  }
59 
60  return result;
61 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
bool checkSignature(std::istream &in)
Check signature method.
std::string::size_type size() const
Definition: ossimString.h:405
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimFilename m_file
Definition: ossimGpkgInfo.h:56

◆ print()

std::ostream & ossimGpkgInfo::print ( std::ostream &  out) const
virtual

Print method.

Parameters
outStream to print to.
Returns
std::ostream&

Implements ossimInfoBase.

Definition at line 63 of file ossimGpkgInfo.cpp.

64 {
65  static const char MODULE[] = "ossimGpkgInfo::open";
66 
67  if ( traceDebug() )
68  {
70  << MODULE << " entered..."
71  << "File: " << m_file.c_str()
72  << std::endl;
73  }
74 
75  // Check for empty filename.
76  if (m_file.size())
77  {
78  ossimKeywordlist kwl;
79 
80  std::ifstream fileStream;
81  fileStream.open(m_file.c_str(), std::ios_base::in | std::ios_base::binary);
82  char APP_ID[5];
83  fileStream.seekg( 68, std::ios_base::beg );
84  fileStream.read(APP_ID, 4);
85  APP_ID[4] = '\0';
86  std::string appId(APP_ID);
87  kwl.addPair("gpkg.", "version", appId, true);
88  fileStream.close();
89 
90  sqlite3* db;
91 
92  int rc = sqlite3_open_v2( m_file.c_str(), &db, SQLITE_OPEN_READONLY, 0);
93  if ( rc == SQLITE_OK )
94  {
95  // Get the gpkg_contents records:
96  std::string tableName = "gpkg_contents";
97  std::vector< ossimRefPtr<ossimGpkgDatabaseRecordBase> > records;
98  if ( ossim_gpkg::getTableRows( db, tableName, records ) )
99  {
100  std::vector< ossimRefPtr<ossimGpkgDatabaseRecordBase> >::const_iterator i =
101  records.begin();
102  ossim_int32 index = 0;
103  while ( i != records.end() )
104  {
105  std::string prefix = "gpkg.";
106  prefix += tableName;
107  prefix += ossimString::toString(index++).string();
108  prefix += ".";
109  (*i)->saveState( kwl, prefix );
110  ++i;
111  }
112  }
113 
114  records.clear();
115 
116  // Get the gpkg_spatial_ref_sys record:
117  tableName = "gpkg_spatial_ref_sys";
118  if ( ossim_gpkg::getTableRows( db, tableName, records ) )
119  {
120  std::vector< ossimRefPtr<ossimGpkgDatabaseRecordBase> >::const_iterator i =
121  records.begin();
122  ossim_int32 index = 0;
123  while ( i != records.end() )
124  {
125  std::string prefix = "gpkg.";
126  prefix += tableName;
127  prefix += ossimString::toString(index++).string();
128  prefix += ".";
129  (*i)->saveState( kwl, prefix );
130  ++i;
131  }
132  }
133 
134  records.clear();
135 
136  // Get the gpkg_tile_matrix_set records:
137  tableName = "gpkg_tile_matrix_set";
138  if ( ossim_gpkg::getTableRows( db, tableName, records ) )
139  {
140  std::vector< ossimRefPtr<ossimGpkgDatabaseRecordBase> >::const_iterator i =
141  records.begin();
142  ossim_int32 index = 0;
143  while ( i != records.end() )
144  {
145  std::string prefix = "gpkg.";
146  prefix += tableName;
147  prefix += ossimString::toString(index++).string();
148  prefix += ".";
149  (*i)->saveState( kwl, prefix );
150  ++i;
151 
152  if ( traceTiles() )
153  {
154  std::string key = "table_name";
155  std::string tileTableName = kwl.findKey( prefix, key );
156  if ( tileTableName.size() )
157  {
158  ossim_gpkg::printTiles( db, tileTableName,
160  }
161  }
162  }
163  }
164 
165  records.clear();
166 
167  // Get the gpkg_tile_matrix_set records:
168  tableName = "gpkg_tile_matrix";
169  if ( ossim_gpkg::getTableRows( db, tableName, records ) )
170  {
171  std::vector< ossimRefPtr<ossimGpkgDatabaseRecordBase> >::const_iterator i =
172  records.begin();
173  ossim_int32 index = 0;
174  while ( i != records.end() )
175  {
176  std::string prefix = "gpkg.";
177  prefix += tableName;
178  prefix += ossimString::toString(index++).string();
179  prefix += ".";
180  (*i)->saveState( kwl, prefix );
181  ++i;
182  }
183  }
184 
185  records.clear();
186 
187  // Get the nsg_tile_matrix_extent records:
188  tableName = "nsg_tile_matrix_extent";
189  if ( ossim_gpkg::getTableRows( db, tableName, records ) )
190  {
191  std::vector< ossimRefPtr<ossimGpkgDatabaseRecordBase> >::const_iterator i =
192  records.begin();
193  ossim_int32 index = 0;
194  while ( i != records.end() )
195  {
196  std::string prefix = "gpkg.";
197  prefix += tableName;
198  prefix += ossimString::toString(index++).string();
199  prefix += ".";
200  (*i)->saveState( kwl, prefix );
201  ++i;
202  }
203  }
204 
205 
206 
207  if ( kwl.getSize() )
208  {
209  out << kwl << std::endl;
210  }
211  }
212 
213  sqlite3_close(db);
214  db = 0;
215  }
216 
217  return out;
218 }
Represents serializable keyword/value map.
const std::string & findKey(const std::string &key) const
Find methods that take std::string(s).
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
static ossimString toString(bool aValue)
Numeric to string methods.
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
bool getTableRows(sqlite3 *db, const std::string &tableName, std::vector< ossimRefPtr< ossimGpkgDatabaseRecordBase > > &result)
Parse table rows.
std::ostream & printTiles(sqlite3 *db, const std::string &tileTableName, std::ostream &out)
std::string::size_type size() const
Definition: ossimString.h:405
ossim_uint32 getSize() const
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimFilename m_file
Definition: ossimGpkgInfo.h:56
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
const std::string & string() const
Definition: ossimString.h:414

Member Data Documentation

◆ m_file

ossimFilename ossimGpkgInfo::m_file
private

Definition at line 56 of file ossimGpkgInfo.h.

Referenced by open().


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