Namespace for the TerraLib PostGIS driver implementation. More...
Classes | |
struct | Array |
Auxiliary structure used to decode Array data types. More... | |
class | ConnectedDataSet |
Implementation of a connected dataset for the PostGIS driver. More... | |
class | Connection |
A class that implements a connection to a PostgreSQL database. More... | |
class | ConnectionPool |
This class implements a connection pool for the PostGIS driver. More... | |
class | DataSet |
Implementation of a dataset for the PostGIS driver. More... | |
class | DataSource |
The PostGIS driver. More... | |
class | EWKBReader |
An utility class for reading a PostGIS EWKB. More... | |
class | EWKBWriter |
An utility class for writing a PostGIS EWKB. More... | |
class | Globals |
An static class with global definitions. More... | |
struct | Numeric |
Auxiliary structure used to decode Numeric data types. More... | |
class | PreparedQuery |
A class that implements a prepared query for PostgreSQL data access driver. More... | |
class | SQLVisitor |
A visitor for building an SQL statement using PostGIS dialect. More... | |
class | Transactor |
The transactor class for the PostGIS driver. More... | |
struct | VersionInfo |
A data structure for holding version information. More... | |
Typedefs | |
typedef boost::shared_ptr< Transactor > | TransactorPtr |
Functions | |
te::da::DataSource * | Build (const te::core::URI &uri) |
void | Convert2OGCWKBType (unsigned int &gType) |
It converts the PostGIS geometry type to a pure OGC WKB code. More... | |
void | Convert2PostGIS (const te::gm::Envelope *e, int srid, std::string &output) |
It converts the envelope into a PostGIS BOX3D. More... | |
void | Convert2PostGIS (PGconn *conn, const te::gm::Geometry *g, std::string &output) |
It converts the geometry into a PostGIS geometry. More... | |
void | Convert2PostGISWKBType (unsigned int &gType) |
te::dt::Property * | Convert2TerraLib (unsigned int attNum, const char *attName, unsigned int attType, bool attNotNull, const char *fmt, bool attHasDefault, const char *attDefValue, unsigned int pgisGeomTypeOid, unsigned int pgisRasterTypeOid) |
It creates a PropertyType from a PostgreSQL attribute description. More... | |
te::dt::Property * | Convert2TerraLib (unsigned int attNum, const char *attName, unsigned int attType, bool attNotNull, const char *fmt, bool attHasDefault, const char *attDefValue, int ndims, unsigned int pgisGeomTypeOid, unsigned int pgisRasterTypeOid) |
It creates a PropertyType from a PostgreSQL attribute description. More... | |
void | Convert2TerraLib (PGresult *result, unsigned int pgisGeomTypeOid, unsigned int pgisRasterTypeOid, std::vector< int > &teTypes) |
It creates a data set type from a PostGIS internal result. More... | |
int | Date2Julian (int y, int m, const int d) |
It returns a julian date (in seconds) from a gregorian date. More... | |
te::da::FKActionType | GetAction (char a) |
It converts the PostgreSQL foreign key modifier to a TerraLib data type. More... | |
std::string | GetBindableUpdateSQL (const std::vector< te::dt::Property * > &properties) |
Given a list of properties it constructs a string with bindable parameters that can be used inside an update query. More... | |
std::string | GetBindableWhereSQL (const std::vector< te::dt::Property * > &properties, const std::size_t offset=0) |
Given a list of properties it creates an AND connected expression with bindable parameters ($n). More... | |
std::string | GetBoxSpatialRelation (te::gm::SpatialRelation rel) |
It converts the spatial relationship to PostGIS dialect. More... | |
te::gm::Envelope * | GetEnvelope (const char *str) |
It converts the pgType to a valid TerraLib data type. More... | |
const std::string & | GetGeometryName (te::gm::GeomType t) |
It returns the geometry names as usual for PostGIS. More... | |
te::da::IndexType | GetIndexType (const char *t) |
It converts the PostgreSQL index string to a TerraLib index type. More... | |
std::string | GetLoadDataRow (const te::da::DataSetType *dt, te::da::DataSet *d, PGconn *conn) |
std::string | GetSpatialRelation (te::gm::SpatialRelation rel) |
It converts the spatial relationship to PostGIS dialect. More... | |
std::string | GetSQLBindValues (std::size_t nproperties) |
std::string | GetSQLValue (const te::dt::Property *p, std::size_t propertyPos, te::da::DataSet *d, PGconn *conn) |
std::string | GetSQLValues (const te::da::DataSetType *dt, te::da::DataSet *d, PGconn *conn) |
te::dt::DateTime * | Internal2Date (const long dDate) |
It returns a DateTime type from a date loaded by PostgreSQL. More... | |
te::dt::DateTime * | Internal2Time (boost::int64_t tval) |
It returns a DateTime type from a time loaded by PostgreSQL. More... | |
te::dt::DateTime * | Internal2TimeStamp (boost::int64_t ival) |
It returns a DateTime type from a timestamp loaded by PostgreSQL. More... | |
te::dt::DateTime * | Internal2TimeStampTZ (boost::int64_t ival, int z) |
te::dt::DateTime * | Internal2TimeTZ (boost::int64_t tval, int z) |
void | Julian2Date (const int jd, int *year, int *month, int *day) |
It returns a gregorian date from a julian date (in seconds). More... | |
std::string | MakeConnectionStr (const te::core::URI &connInfo) |
void | ScapeString (PGconn *conn, const std::string &s, std::string &output) |
It escapes a string for use within an SQL command. More... | |
bool | SetColumnDef (std::string &s, const te::dt::Property *p, bool justDataType=false) |
It writes the PostgreSQL column definition to the output string. More... | |
void | SplitTableName (const std::string &fullName, const std::string *defaultSchema, std::string &schemaName, std::string &tableName) |
Namespace for the TerraLib PostGIS driver implementation.
typedef boost::shared_ptr<Transactor> te::pgis::TransactorPtr |
Definition at line 475 of file Transactor.h.
te::da::DataSource* te::pgis::Build | ( | const te::core::URI & | uri | ) |
|
inline |
It converts the PostGIS geometry type to a pure OGC WKB code.
This function will turn off the PostGIS flags and will turn on the right bits for OGC WKB type.
gType | A value that can have some flags set by PostGIS. |
Definition at line 930 of file Utils.h.
References TE_EWKB_M_OFFSET, TE_EWKB_Z_OFFSET, and TE_EWKB_ZM_OFFSET.
|
inline |
It converts the envelope into a PostGIS BOX3D.
e | The envelope to be converted. |
srid | The envelope coordinates SRS. |
output | The string to output the result. |
Definition at line 228 of file Utils.h.
References te::common::Convert2String(), te::gm::Envelope::m_llx, te::gm::Envelope::m_lly, te::gm::Envelope::m_urx, and te::gm::Envelope::m_ury.
void te::pgis::Convert2PostGIS | ( | PGconn * | conn, |
const te::gm::Geometry * | g, | ||
std::string & | output | ||
) |
It converts the geometry into a PostGIS geometry.
conn | The connection to be used with bytearray. |
g | The geometry to be converted. |
output | The string to output the result. |
|
inline |
Definition at line 960 of file Utils.h.
References TE_EWKB_M_OFFSET, TE_EWKB_Z_OFFSET, and TE_EWKB_ZM_OFFSET.
|
inline |
It creates a PropertyType from a PostgreSQL attribute description.
attNum | The column number (a number in the range [1, num-columns]). |
attName | The column name. |
attType | The column type |
attLen | The column size (depends on column type). |
attNotNull | If the column is not null. |
fmt | Column formats: Numeric(20, 30), VARCHAR(30), CHAR(10). |
attHasDefault | True if the column has a default value. |
attDefValue | The default value expression if attHasDefValue is true otherwise this has no meaning. |
pgisGeomTypeOid | The oid of PostGIS geometry type. |
Definition at line 486 of file Utils.h.
References te::dt::BOOLEAN_TYPE, te::dt::BYTE_ARRAY_TYPE, te::dt::CHAR_TYPE, te::dt::DATE, te::dt::DOUBLE_TYPE, te::dt::FIXED_STRING, te::dt::FLOAT_TYPE, te::dt::INT16_TYPE, te::dt::INT32_TYPE, te::dt::INT64_TYPE, PG_BOOL_TYPE, PG_BYTEA_TYPE, PG_CHAR_TYPE, PG_CHARACTER_TYPE, PG_DATE_TYPE, PG_FLOAT4_TYPE, PG_FLOAT8_TYPE, PG_INT2_TYPE, PG_INT4_TYPE, PG_INT8_TYPE, PG_NAME_TYPE, PG_NUMERIC_TYPE, PG_OID_TYPE, PG_TEXT_TYPE, PG_TIME_TYPE, PG_TIMESTAMP_TYPE, PG_TIMESTAMPTZ_TYPE, PG_TIMETZ_TYPE, PG_VARCHAR_TYPE, te::dt::SimpleProperty::setAutoNumber(), te::dt::STRING, te::dt::TIME_DURATION, te::dt::TIME_INSTANT, te::dt::UNKNOWN_TYPE, and te::dt::VAR_STRING.
Referenced by Convert2TerraLib().
|
inline |
It creates a PropertyType from a PostgreSQL attribute description.
attNum | The column number. |
attName | The column name. |
attType | The column type. |
attNotNull | If the column is not null. |
fmt | Column formats: Numeric(20, 30), VARCHAR(30), CHAR(10). |
attHasDefault | True, if the column has a default value. |
attDefValue | The default value expression, if attHasDefValue is true; otherwise, it has no meaning. |
ndims | If different of 0, it indicates an array type. |
pgisGeomTypeOid | The oid of the PostGIS geometry type. |
Definition at line 621 of file Utils.h.
References Convert2TerraLib(), PG__INT2_VECTOR_TYPE, PG_BOOL_ARRAY_TYPE, PG_BOOL_TYPE, PG_BYTEA_ARRAY_TYPE, PG_BYTEA_TYPE, PG_CHAR_ARRAY_TYPE, PG_CHAR_TYPE, PG_CHARACTER_ARRAY_TYPE, PG_CHARACTER_TYPE, PG_DATE_ARRAY_TYPE, PG_DATE_TYPE, PG_FLOAT4_ARRAY_TYPE, PG_FLOAT4_TYPE, PG_FLOAT8_ARRAY_TYPE, PG_FLOAT8_TYPE, PG_INT2_ARRAY_TYPE, PG_INT2_TYPE, PG_INT2_VECTOR_TYPE, PG_INT4_ARRAY_TYPE, PG_INT4_TYPE, PG_INT8_ARRAY_TYPE, PG_INT8_TYPE, PG_NAME_ARRAY_TYPE, PG_NUMERIC_ARRAY_TYPE, PG_NUMERIC_TYPE, PG_OID_ARRAY_TYPE, PG_OID_VECTOR_TYPE, PG_TEXT_ARRAY_TYPE, PG_TEXT_TYPE, PG_TIME_ARRAY_TYPE, PG_TIME_TYPE, PG_TIMESTAMP_ARRAY_TYPE, PG_TIMESTAMP_TYPE, PG_TIMESTAMPTZ_ARRAY_TYPE, PG_TIMESTAMPTZ_TYPE, PG_TIMETZ_ARRAY_TYPE, PG_TIMETZ_TYPE, PG_VARCHAR_ARRAY_TYPE, PG_VARCHAR_TYPE, and te::dt::ArrayProperty::setElementType().
void te::pgis::Convert2TerraLib | ( | PGresult * | result, |
unsigned int | pgisGeomTypeOid, | ||
unsigned int | pgisRasterTypeOid, | ||
std::vector< int > & | teTypes | ||
) |
It creates a data set type from a PostGIS internal result.
result | A PostGIS internal result. |
pgisGeomTypeOid | The oid of PostGIS geometry type. |
|
inline |
It returns a julian date (in seconds) from a gregorian date.
It returns a julian date (in seconds) from a gregorian date. Internally, postgresql stores julian dates.
y | A year of a gregorian date. |
m | A month of a gregorian date. |
d | A day of a gregorian date. |
|
inline |
It converts the PostgreSQL foreign key modifier to a TerraLib data type.
a | PostgreSQL foreign key modifier type. |
The equivalent TerraLib foreign key modifier type.
Definition at line 116 of file Utils.h.
References te::da::CASCADE, te::da::NO_ACTION, te::da::RESTRICT, te::da::SET_DEFAULT, and te::da::SET_NULL.
std::string te::pgis::GetBindableUpdateSQL | ( | const std::vector< te::dt::Property * > & | properties | ) |
Given a list of properties it constructs a string with bindable parameters that can be used inside an update query.
properties | A vector with property names that will be used to create the expression. |
std::string te::pgis::GetBindableWhereSQL | ( | const std::vector< te::dt::Property * > & | properties, |
const std::size_t | offset = 0 |
||
) |
Given a list of properties it creates an AND connected expression with bindable parameters ($n).
itBegin | The start property. |
itEnd | The mark of end of properties. |
|
inline |
It converts the spatial relationship to PostGIS dialect.
rel | The spatial relationship. |
Definition at line 879 of file Utils.h.
References te::gm::CONTAINS, te::gm::COVEREDBY, te::gm::COVERS, te::gm::EQUALS, te::gm::INTERSECTS, te::gm::OVERLAPS, and te::gm::WITHIN.
|
inline |
It converts the pgType to a valid TerraLib data type.
cols | An array with column numbers. |
dt | The DataSetType to look for the property. |
Definition at line 172 of file Utils.h.
References te::gm::Envelope::m_llx, te::gm::Envelope::m_lly, te::gm::Envelope::m_urx, and te::gm::Envelope::m_ury.
const std::string& te::pgis::GetGeometryName | ( | te::gm::GeomType | t | ) |
It returns the geometry names as usual for PostGIS.
t | The TerraLib geometry type. |
|
inline |
It converts the PostgreSQL index string to a TerraLib index type.
t | PostgreSQL index name (A NULL terminated string). |
The equivalent TerraLib foreign key modifier type.
Definition at line 144 of file Utils.h.
References te::da::B_TREE_TYPE, te::da::HASH_TYPE, and te::da::R_TREE_TYPE.
std::string te::pgis::GetLoadDataRow | ( | const te::da::DataSetType * | dt, |
te::da::DataSet * | d, | ||
PGconn * | conn | ||
) |
|
inline |
It converts the spatial relationship to PostGIS dialect.
rel | The spatial relationship. |
Definition at line 833 of file Utils.h.
References te::gm::CONTAINS, te::gm::COVEREDBY, te::gm::COVERS, te::gm::CROSSES, te::gm::DISJOINT, te::gm::EQUALS, te::gm::INTERSECTS, te::gm::OVERLAPS, te::gm::TOUCHES, and te::gm::WITHIN.
std::string te::pgis::GetSQLBindValues | ( | std::size_t | nproperties | ) |
std::string te::pgis::GetSQLValue | ( | const te::dt::Property * | p, |
std::size_t | propertyPos, | ||
te::da::DataSet * | d, | ||
PGconn * | conn | ||
) |
std::string te::pgis::GetSQLValues | ( | const te::da::DataSetType * | dt, |
te::da::DataSet * | d, | ||
PGconn * | conn | ||
) |
|
inline |
It returns a DateTime type from a date loaded by PostgreSQL.
It returns a DateTime type from a date loaded by PostgreSQL. Internelly, PostgreSQL stores julian dates in 4 bytes, so this function has to convert it to gregorian date. Besides that, PostgreSQL stores date as seconds before or after midnight 2000-01-01. Therefore, this function has to sum the number of seconds (2451545 seconds) between 01-01-01 00:00:00 and 01-01-2000 00:00:00 to the date.
dDate | A julian date in seconds loaded by PostgreSQL. |
return | A gregorian date from the input julian date. |
Definition at line 346 of file Utils.h.
References Julian2Date().
Referenced by Internal2TimeStamp(), and Internal2TimeStampTZ().
|
inline |
It returns a DateTime type from a time loaded by PostgreSQL.
It returns a DateTime type from a time loaded by PostgreSQL. Internelly, PostgreSQL stores time as seconds.
tval | The amount of seconds loaded by PostgreSQL. |
return | A time (hour, minute, second) from the input amount of seconds. |
Definition at line 365 of file Utils.h.
Referenced by Internal2TimeStamp().
|
inline |
It returns a DateTime type from a timestamp loaded by PostgreSQL.
It returns a DateTime type from a timestamp loaded by PostgreSQL. Internelly, PostgreSQL stores timestamp as seconds before or after midnight 2000-01-01.
ival | The timestamp, in seconds, loaded by PostgreSQL. |
return | A time instant from the input timestamp. |
Definition at line 416 of file Utils.h.
References Internal2Date(), and Internal2Time().
|
inline |
Definition at line 440 of file Utils.h.
References te::dt::Date::getDate(), te::dt::TimeInstantTZ::getTimeInstantTZ(), Internal2Date(), and Internal2TimeTZ().
|
inline |
Definition at line 380 of file Utils.h.
Referenced by Internal2TimeStampTZ().
|
inline |
It returns a gregorian date from a julian date (in seconds).
It returns a gregorian date from a julian date (in seconds).
jd | A julian date in seconds (INPUT). |
year | The year of a gregorian date that will be filled by this function (OUTPUT). |
month | The month of a gregorian date that will be filled by this function (OUTPUT). |
day | The day of a gregorian date that will be filled by this function (OUTPUT). |
Definition at line 307 of file Utils.h.
Referenced by Internal2Date().
std::string te::pgis::MakeConnectionStr | ( | const te::core::URI & | connInfo | ) |
void te::pgis::ScapeString | ( | PGconn * | conn, |
const std::string & | s, | ||
std::string & | output | ||
) |
It escapes a string for use within an SQL command.
conn | The connection to be used with bytearray. |
s | The string to be scapaded. |
output | The string to output the result. |
bool te::pgis::SetColumnDef | ( | std::string & | s, |
const te::dt::Property * | p, | ||
bool | justDataType = false |
||
) |
It writes the PostgreSQL column definition to the output string.
s | The string to output the column definition. |
p | The TerraLib propoerty type. |
Exception | It throws an exception if the data type is not mapped to the PostgreSQL type system. |
void te::pgis::SplitTableName | ( | const std::string & | fullName, |
const std::string * | defaultSchema, | ||
std::string & | schemaName, | ||
std::string & | tableName | ||
) |