| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Friends
TePostGIS Class Reference

PostgreSQL with PostGIS extension database access class. More...

`#include <TePostGIS.h>`

Inheritance diagram for TePostGIS:

List of all members.

## Public Member Functions

| TePostGIS ()
| Constructor.
virtual | ~TePostGIS ()
| Destructor.
bool | newDatabase (const string &database, const string &user, const string &password, const string &host, const int &port=-1, bool terralibModel=true, const std::string &characterSet="")
| Creates a new database based on "template1" and open a connection to the new one.
bool | connect (const string &host, const string &user, const string &password, const string &database, int port=-1)
| Opens a conection to a database server.
bool | showDatabases (const string &host, const string &user, const string &password, vector< string > &dbNames, int port=-1)
| Show the server databases (only for MySQL, Oracle and PostgreSQL)
TeDatabasePortal * | getPortal ()
| Returns a portal associated to this database.
bool | createTable (const string &table, TeAttributeList &attr)
| Creates a generic table.
bool | generateLabelPositions (TeTheme *theme, const std::string &objectId="")
| Generate the label position (x,y) to each object of a theme.
bool | selectPolygonSet (const string &table, const string &criteria, TePolygonSet &ps)
| Returns all polygons in a table given a criteria expressed as an SQL where statement.
bool | loadPolygonSet (TeTheme *theme, TePolygonSet &ps)
| Returns all polygons that represents objects of a particular theme.
bool | loadPolygonSet (const string &table, const string &geoid, TePolygonSet &ps)
| Returns all polygons that represents objects of a particular geoid.
bool | loadPolygonSet (const string &table, TeBox &box, TePolygonSet &ps)
| Returns all polygons inside a given box.
TeDatabasePortal * | loadPolygonSet (const string &table, TeBox &box)
| Returns a database portal to iterate over the polygons that are inside a given box.
bool | locatePolygon (const string &table, TeCoord2D &pt, TePolygon &polygon, const double &tol=0.0)
| Returns the first polygon that contais a given coordinate.
bool | locatePolygonSet (const string &table, TeCoord2D &pt, double tol, TePolygonSet &polygons)
| Returns the polygons that contains a give coordinate.
bool | insertPolygon (const string &table, TePolygon &p)
| Inserts a polygon.
bool | updatePolygon (const string &table, TePolygon &p)
| Updates a polygon.
bool | loadLineSet (const string &table, const string &geoid, TeLineSet &ls)
bool | loadLineSet (const string &table, TeBox &box, TeLineSet &linSet)
TeDatabasePortal * | loadLineSet (const string &table, TeBox &box)
bool | insertLine (const string &table, TeLine2D &l)
| Inserts a line.
bool | updateLine (const string &table, TeLine2D &l)
| Updates a line.
bool | locateLine (const string &table, TeCoord2D &pt, TeLine2D &line, const double &tol=0.0)
| Locates a line.
bool | insertPoint (const string &table, TePoint &p)
| Inserts a point.
bool | updatePoint (const string &table, TePoint &p)
| Updates a point.
bool | locatePoint (const string &table, TeCoord2D &pt, TePoint &point, const double &tol=0.0)
| Locates a point.
bool | insertNode (const string &table, TeNode &node)
| Inserts a node.
bool | updateNode (const string &table, TeNode &node)
| Updates a node.
bool | insertCell (const string &table, TeCell &c)
| Inserts a cell.
bool | updateCell (const string &table, TeCell &c)
| Updates a cell.
bool | locateCell (const string &table, TeCoord2D &pt, TeCell &c, const double &tol=0.0)
| Locates a cell.
virtual bool | removeGeometry (const string &tableName, const TeGeomRep &rep, const int &geomId)
| Removes a geometry from the given tableName.
bool | createSpatialIndex (const string &table, const string &column, TeSpatialIndexType type=TeRTREE, short level=0, short tile=0)
| Creates a spatial index on column table.
string | getSQLBoxWhere (const TeBox &box, const TeGeomRep rep, const std::string &tableName)
| Return a string that describes a where clause to return the geometries inside the box.
virtual std::string | getSQLOrderBy (const TeGeomRep &rep) const
string | getSQLBoxWhere (const string &table1, const string &table2, TeGeomRep rep2, TeGeomRep rep1=TePOLYGONS)
| Returns a string that describes a where clause to return the geometries of the table2 that are inside the geometries box of the table1.
string | getSQLBoxSelect (const string &tableName, TeGeomRep rep)
| Return a string SQL to be used in the clause SELECT to select the box (lower_x, lower_y, upper_x, upper_y)
bool | getMBRGeom (string tableGeom, string object_id, TeBox &box, string colGeom)
| Returns the box of a specific geometry (object_id)
bool | getMBRSelectedObjects (string geomTable, string colGeom, string fromClause, string whereClause, string afterWhereClause, TeGeomRep repType, TeBox &bout, const double &tol=0.0)
| Return the box of a select objects set.
string | getSpatialIdxColumn (TeGeomRep rep)
| Returns the name of the column that wiil be the spatially indexed, for a given type of geometry table.
bool | getEncodingList (const std::string &host, const std::string &user, const std::string &password, const int &port, std::vector< std::string > &vecEncodingList)
| Retrives the list of available character sets.

## Friends

class | TePostGISPortal

## Detailed Description

PostgreSQL with PostGIS extension database access class.

This class contains the implementation of common methods for TerraLib access PostgreSQL using a PostGIS extension. From release 3.1 on, this driver makes use of RTree over GiST. So, to use it you will need install RTRee GiST support in your database.

Note:
  MAKE SURE you have UPGRADE your PostgreSQL database before use this driver. If you need to upgrade without use TerraView, please look at TeUpdateDBVersion.cpp for the routines: updateDB302To310 and PostgreSQLUpdateDB302To310, for a tip on how to upgrade by yourself.

Author:
  Gilberto Ribeiro de Queiroz <gribeiro@dpi.inpe.br>

## Constructor & Destructor Documentation

TePostGIS::TePostGIS | ( |  | ) |

Constructor.

virtual TePostGIS::~TePostGIS | ( |  | ) | `[inline, virtual]`

Destructor.

## Member Function Documentation

bool TePostGIS::connect | ( | const string & | host,
|  | const string & | user,
|  | const string & | password,
|  | const string & | database,
|  | int | port = `-1`
| ) |  | `[virtual]`

Opens a conection to a database server.

Reimplemented from TePostgreSQL.

bool TePostGIS::createSpatialIndex | ( | const string & | table,
|  | const string & | column,
|  | TeSpatialIndexType | type = `TeRTREE`,
|  | short | level = `0`,
|  | short | tile = `0`
| ) |  | `[virtual]`

Creates a spatial index on column table.

Reimplemented from TePostgreSQL.

bool TePostGIS::createTable | ( | const string & | table,
|  | TeAttributeList & | attr
| ) |  | `[virtual]`

Creates a generic table.

Reimplemented from TePostgreSQL.

bool TePostGIS::generateLabelPositions | ( | TeTheme * | theme,
|  | const std::string & | objectId = `""`
| ) |  | `[virtual]`

Generate the label position (x,y) to each object of a theme.

Reimplemented from TePostgreSQL.

bool TePostGIS::getEncodingList | ( | const std::string & | host,
|  | const std::string & | user,
|  | const std::string & | password,
|  | const int & | port,
|  | std::vector< std::string > & | vecEncodingList
| ) |  | `[virtual]`

Retrives the list of available character sets.

Reimplemented from TePostgreSQL.

bool TePostGIS::getMBRGeom | ( | string | tableGeom,
|  | string | object_id,
|  | TeBox & | box,
|  | string | colGeom
| ) |  | `[virtual]`

Returns the box of a specific geometry (object_id)

Reimplemented from TePostgreSQL.

bool TePostGIS::getMBRSelectedObjects | ( | string | geomTable,
|  | string | colGeom,
|  | string | fromClause,
|  | string | whereClause,
|  | string | afterWhereClause,
|  | TeGeomRep | repType,
|  | TeBox & | bout,
|  | const double & | tol = `0.0`
| ) |  | `[virtual]`

Return the box of a select objects set.

Reimplemented from TePostgreSQL.

TeDatabasePortal * TePostGIS::getPortal | ( |  | ) | `[virtual]`

Returns a portal associated to this database.

Reimplemented from TePostgreSQL.

string TePostGIS::getSpatialIdxColumn | ( | TeGeomRep | rep | ) | `[virtual]`

Returns the name of the column that wiil be the spatially indexed, for a given type of geometry table.

Reimplemented from TePostgreSQL.

string TePostGIS::getSQLBoxSelect | ( | const string & | tableName,
|  | TeGeomRep | rep
| ) |  | `[virtual]`

Return a string SQL to be used in the clause SELECT to select the box (lower_x, lower_y, upper_x, upper_y)

Reimplemented from TePostgreSQL.

string TePostGIS::getSQLBoxWhere | ( | const TeBox & | box,
|  | const TeGeomRep | rep,
|  | const std::string & | tableName
| ) |  | `[virtual]`

Return a string that describes a where clause to return the geometries inside the box.

Returns a string SQL to be used in the ORDER BY clause when querying geometries.

Reimplemented from TePostgreSQL.

string TePostGIS::getSQLBoxWhere | ( | const string & | table1,
|  | const string & | table2,
|  | TeGeomRep | rep2,
|  | TeGeomRep | rep1 = `TePOLYGONS`
| ) |  | `[virtual]`

Returns a string that describes a where clause to return the geometries of the table2 that are inside the geometries box of the table1.

Reimplemented from TePostgreSQL.

std::string TePostGIS::getSQLOrderBy | ( | const TeGeomRep & | rep | ) | const`[virtual]`

Reimplemented from TeDatabase.

bool TePostGIS::insertCell | ( | const string & | table,
|  | TeCell & | c
| ) |  | `[virtual]`

Inserts a cell.

Reimplemented from TePostgreSQL.

bool TePostGIS::insertLine | ( | const string & | table,
|  | TeLine2D & | l
| ) |  | `[virtual]`

Inserts a line.

Reimplemented from TePostgreSQL.

bool TePostGIS::insertNode | ( | const string & | table,
|  | TeNode & | node
| ) |  | `[virtual]`

Inserts a node.

Reimplemented from TePostgreSQL.

bool TePostGIS::insertPoint | ( | const string & | table,
|  | TePoint & | p
| ) |  | `[virtual]`

Inserts a point.

Reimplemented from TePostgreSQL.

bool TePostGIS::insertPolygon | ( | const string & | table,
|  | TePolygon & | p
| ) |  | `[virtual]`

Inserts a polygon.

Reimplemented from TePostgreSQL.

bool TePostGIS::loadLineSet | ( | const string & | table,
|  | TeBox & | box,
|  | TeLineSet & | linSet
| ) |  | `[virtual]`

Reimplemented from TePostgreSQL.

TeDatabasePortal * TePostGIS::loadLineSet | ( | const string & | table,
|  | TeBox & | box
| ) |  | `[virtual]`

Reimplemented from TePostgreSQL.

bool TePostGIS::loadLineSet | ( | const string & | table,
|  | const string & | geoid,
|  | TeLineSet & | ls
| ) |  | `[virtual]`

Reimplemented from TeDatabase.

TeDatabasePortal * TePostGIS::loadPolygonSet | ( | const string & | table,
|  | TeBox & | box
| ) |  | `[virtual]`

Returns a database portal to iterate over the polygons that are inside a given box.

Reimplemented from TePostgreSQL.

bool TePostGIS::loadPolygonSet | ( | const string & | table,
|  | const string & | geoid,
|  | TePolygonSet & | ps
| ) |  | `[virtual]`

Returns all polygons that represents objects of a particular geoid.

Reimplemented from TeDatabase.

bool TePostGIS::loadPolygonSet | ( | const string & | table,
|  | TeBox & | box,
|  | TePolygonSet & | ps
| ) |  | `[virtual]`

Returns all polygons inside a given box.

Reimplemented from TePostgreSQL.

bool TePostGIS::loadPolygonSet | ( | TeTheme * | theme,
|  | TePolygonSet & | ps
| ) |  | `[virtual]`

Returns all polygons that represents objects of a particular theme.

Reimplemented from TeDatabase.

bool TePostGIS::locateCell | ( | const string & | table,
|  | TeCoord2D & | pt,
|  | TeCell & | c,
|  | const double & | tol = `0.0`
| ) |  | `[virtual]`

Locates a cell.

Reimplemented from TePostgreSQL.

bool TePostGIS::locateLine | ( | const string & | table,
|  | TeCoord2D & | pt,
|  | TeLine2D & | line,
|  | const double & | tol = `0.0`
| ) |  | `[virtual]`

Locates a line.

Reimplemented from TePostgreSQL.

bool TePostGIS::locatePoint | ( | const string & | table,
|  | TeCoord2D & | pt,
|  | TePoint & | point,
|  | const double & | tol = `0.0`
| ) |  | `[virtual]`

Locates a point.

Reimplemented from TePostgreSQL.

bool TePostGIS::locatePolygon | ( | const string & | table,
|  | TeCoord2D & | pt,
|  | TePolygon & | polygon,
|  | const double & | tol = `0.0`
| ) |  | `[virtual]`

Returns the first polygon that contais a given coordinate.

Reimplemented from TePostgreSQL.

bool TePostGIS::locatePolygonSet | ( | const string & | table,
|  | TeCoord2D & | pt,
|  | double | tol,
|  | TePolygonSet & | polygons
| ) |  | `[virtual]`

Returns the polygons that contains a give coordinate.

Reimplemented from TePostgreSQL.

bool TePostGIS::newDatabase | ( | const string & | database,
|  | const string & | user,
|  | const string & | password,
|  | const string & | host,
|  | const int & | port = `-1`,
|  | bool | terralibModel = `true`,
|  | const std::string & | characterSet = `""`
| ) |  | `[virtual]`

Creates a new database based on "template1" and open a connection to the new one.

Reimplemented from TePostgreSQL.

bool TePostGIS::removeGeometry | ( | const string & | tableName,
|  | const TeGeomRep & | rep,
|  | const int & | geomId
| ) |  | `[virtual]`

Removes a geometry from the given tableName.

Reimplemented from TeDatabase.

bool TePostGIS::selectPolygonSet | ( | const string & | table,
|  | const string & | criteria,
|  | TePolygonSet & | ps
| ) |  | `[virtual]`

Returns all polygons in a table given a criteria expressed as an SQL where statement.

Reimplemented from TeDatabase.

bool TePostGIS::showDatabases | ( | const string & | host,
|  | const string & | user,
|  | const string & | password,
|  | vector< string > & | dbNames,
|  | int | port = `-1`
| ) |  | `[virtual]`

Show the server databases (only for MySQL, Oracle and PostgreSQL)

Reimplemented from TePostgreSQL.

bool TePostGIS::updateCell | ( | const string & | table,
|  | TeCell & | c
| ) |  | `[virtual]`

Updates a cell.

Reimplemented from TePostgreSQL.

bool TePostGIS::updateLine | ( | const string & | table,
|  | TeLine2D & | l
| ) |  | `[virtual]`

Updates a line.

Reimplemented from TePostgreSQL.

bool TePostGIS::updateNode | ( | const string & | table,
|  | TeNode & | node
| ) |  | `[virtual]`

Updates a node.

Reimplemented from TePostgreSQL.

bool TePostGIS::updatePoint | ( | const string & | table,
|  | TePoint & | p
| ) |  | `[virtual]`

Updates a point.

Reimplemented from TePostgreSQL.

bool TePostGIS::updatePolygon | ( | const string & | table,
|  | TePolygon & | p
| ) |  | `[virtual]`

Updates a polygon.

Reimplemented from TePostgreSQL.

## Friends And Related Function Documentation

friend class TePostGISPortal`[friend]`

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

- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/PostgreSQL/TePostGIS.h
- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/PostgreSQL/TePostGIS.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines