35 static ossimTrace traceDebug(
"ossimGpkgSpatialRefSysRecord:debug");
37 static std::string TABLE_NAME =
"gpkg_spatial_ref_sys";
45 m_organization_coordsys_id(0),
54 m_srs_name(obj.m_srs_name),
55 m_srs_id(obj.m_srs_id),
56 m_organization(obj.m_organization),
57 m_organization_coordsys_id(obj.m_organization_coordsys_id),
58 m_definition(obj.m_definition),
59 m_description(obj.m_description)
89 static const char M[] =
"ossimGpkgSpatialRefSysRecord::init(pStmt)";
98 if ( nCol != EXPECTED_COLUMNS )
101 << M <<
" WARNING:\nUnexpected number of columns: " << nCol
102 <<
"Expected column count: " << EXPECTED_COLUMNS
106 if ( nCol >= EXPECTED_COLUMNS )
114 colName = sqlite3_column_name(pStmt, i);
115 if ( colName.size() )
117 if ( colName ==
"srs_name" )
119 c = (
const char*)sqlite3_column_text(pStmt, i);
123 else if ( colName ==
"srs_id" )
125 m_srs_id = sqlite3_column_int(pStmt, i);
128 else if ( colName ==
"organization" )
130 c = (
const char*)sqlite3_column_text(pStmt, i);
134 else if ( colName ==
"organization_coordsys_id" )
139 else if ( colName ==
"definition" )
141 c = (
const char*)sqlite3_column_text(pStmt, i);
145 else if ( colName ==
"description" )
147 c = (
const char*)sqlite3_column_text(pStmt, i);
154 << M <<
" Unhandled column name[" << i <<
"]: " 155 << colName << std::endl;
160 if ( columnsFound == EXPECTED_COLUMNS )
185 static const char M[] =
"ossimGpkgSpatialRefSysRecord::init(proj)";
191 if ( pcsCode == 4326 )
194 m_definition =
"GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";
197 m_description =
"Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.";
201 else if ( pcsCode == 3395 )
204 m_definition =
"PROJCS[\"WGS 84 / World Mercator\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],AUTHORITY[\"EPSG\",\"3395\"],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]";
211 else if ( pcsCode == 3857 )
214 m_definition =
"PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH],EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs\"],AUTHORITY[\"EPSG\",\"3857\"]]";
226 if ( projName ==
"ossimUtmProjection" )
228 if ( datumCode ==
"WGE" )
241 if ( hemisphere ==
'N' )
253 m_definition +=
"\",GEOGCS[\"WGS 84\",DATUM[\"World Geodetic System_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Transverse Mercator\",AUTHORITY[\"EPSG\",\"9807\"]],PARAMETER[\"Latitude of natural origin\",0],PARAMETER[\"Longitude of natural origin\",";
255 m_definition +=
"],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",";
256 if ( hemisphere ==
'N' )
264 m_definition +=
"],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",AUTHORITY[\"EPSG\",\"";
270 m_description =
"Large and medium scale topographic mapping and engineering survey.";
281 <<
"\n datum: " << proj->
getDatum()->
code() << std::endl;
317 sql <<
"CREATE TABLE " << TABLE_NAME <<
" ( " 318 <<
"srs_name TEXT NOT NULL, " 319 <<
"srs_id INTEGER NOT NULL PRIMARY KEY, " 320 <<
"organization TEXT NOT NULL, " 321 <<
"organization_coordsys_id INTEGER NOT NULL, " 322 <<
"definition TEXT NOT NULL, " 323 <<
"description TEXT )";
334 if ( record.
insert( db ) )
339 if ( record.
insert( db ) )
342 record.
m_srs_name =
"WGS 84 Geographic 2D lat/lon";
343 record.
m_definition =
"GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]";
346 record.
m_description =
"Horizontal component of 3D system. Used by the GPS satellite navigation system and for NATO military geodetic surveying.";
365 sql <<
"INSERT INTO gpkg_spatial_ref_sys VALUES ( " 382 const std::string& prefix )
const 384 std::string myPref = prefix.size() ? prefix : std::string(
"gpkg_spatial_ref_sys.");
387 std::string key =
"srs_name";
392 kwl.
addPair(myPref, key, value,
true);
394 key =
"organization";
397 key =
"organization_coordsys_id";
399 kwl.
addPair( myPref, key, value,
true);
414 sql <<
"SELECT srs_id FROM gpkg_spatial_ref_sys WHERE organization == '" 416 <<
"' AND organization_coordsys_id == " 419 const char *zLeftover;
420 sqlite3_stmt *pStmt = 0;
421 int rc = sqlite3_prepare_v2(db,
426 if ( rc == SQLITE_OK )
429 rc = sqlite3_step(pStmt);
430 if ( rc == SQLITE_ROW )
432 result = sqlite3_column_int(pStmt, 0);
435 sqlite3_finalize(pStmt);
445 std::string sql =
"SELECT srs_id FROM gpkg_spatial_ref_sys ORDER BY srs_id DESC LIMIT 1";
447 const char *zLeftover;
448 sqlite3_stmt *pStmt = 0;
449 int rc = sqlite3_prepare_v2(db,
454 if ( rc == SQLITE_OK )
457 rc = sqlite3_step(pStmt);
458 if ( rc == SQLITE_ROW )
460 result = sqlite3_column_int(pStmt, 0);
464 sqlite3_finalize(pStmt);
std::string m_description
bool insert(sqlite3 *db)
Inserst this record into gpkg_contents table.
static const std::string & getTableName()
Get the table name "gpkg_spatial_ref_sys".
ossim_int32 m_organization_coordsys_id
virtual ~ossimGpkgSpatialRefSysRecord()
destructor
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
double lond() const
Will convert the radian measure to degrees.
Represents serializable keyword/value map.
virtual ossim_uint32 getPcsCode() const
Returns the EPSG PCS code or 32767 if the projection is a custom (non-EPSG) projection.
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.
virtual const ossimString & code() const
static ossimString toString(bool aValue)
Numeric to string methods.
const ossimGpkgSpatialRefSysRecord & operator=(const ossimGpkgSpatialRefSysRecord &obj)
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
virtual ossimString getClassName() const
static bool createTable(sqlite3 *db)
Creates gpkg_contents table in database.
std::string m_organization
virtual const ossimDatum * getDatum() const
virtual ossimGpt origin() const
ossimGpkgSpatialRefSysRecord()
default constructor
virtual void saveState(ossimKeywordlist &kwl, const std::string &prefix) const
Saves the state of object.
ossim_int32 getSrsId(sqlite3 *db)
Looks in database for matching record and returns the id if found.
ossim_int32 getZone() const
ossim_int32 getNextSrsId(sqlite3 *db)
Looks in database for matching record and returns the id if found.
char getHemisphere() const
virtual bool init(sqlite3_stmt *pStmt)
Initialize from database.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
const std::string & string() const