| TerraLib 4.1

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

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/PostgreSQL/TePostGIS.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00026 #ifndef  __TERRALIB_INTERNAL_POSTGIS_H
    00027 #define  __TERRALIB_INTERNAL_POSTGIS_H
    00028
    00029 #include "TePostgreSQL.h"
    00030 #include "../../kernel/TeDatabaseFactory.h"
    00031
    00032 class TePostGISPortal;
    00033
    00035
    00045 class TLPOSTGRESQL_DLL TePostGIS : public TePostgreSQL
    00046 {
    00047            friend class TePostGISPortal;
    00048
    00049            public:
    00050
    00052                       TePostGIS();
    00053
    00055                       virtual ~TePostGIS()
    00056                       {
    00057                       }
    00058
    00060                       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 = "");
    00061
    00063                       bool connect(const string& host, const string& user, const string& password, const string& database, int port = -1);
    00064
    00065                       bool showDatabases(const string& host, const string& user, const string& password, vector<string>& dbNames, int port = -1);
    00066
    00068                       TeDatabasePortal* getPortal();
    00069
    00071                       bool createTable(const string& table, TeAttributeList &attr);
    00072
    00074                       bool generateLabelPositions(TeTheme *theme, const std::string& objectId = "");
    00075
    00077                       bool selectPolygonSet(const string& table, const string& criteria, TePolygonSet& ps);
    00078
    00080                       bool loadPolygonSet(TeTheme* theme, TePolygonSet& ps);
    00081
    00083                       bool loadPolygonSet(const string& table, const string& geoid, TePolygonSet& ps);
    00084
    00086                       bool loadPolygonSet(const string& table, TeBox& box, TePolygonSet& ps);
    00087
    00089                       TeDatabasePortal* loadPolygonSet(const string& table, TeBox& box);
    00090
    00092                bool locatePolygon(const string& table, TeCoord2D& pt, TePolygon& polygon, const double& tol = 0.0);
    00093
    00095                       bool locatePolygonSet  (const string& table, TeCoord2D &pt, double tol, TePolygonSet &polygons);
    00096
    00098                       bool insertPolygon(const string& table, TePolygon& p);
    00099
    00101                       bool updatePolygon(const string& table, TePolygon& p);
    00102
    00103                       bool loadLineSet(const string& table, const string& geoid, TeLineSet& ls);
    00104
    00105                       bool loadLineSet(const string& table, TeBox& box, TeLineSet& linSet);
    00106
    00107                       TeDatabasePortal* loadLineSet(const string& table, TeBox& box);
    00108
    00110                       bool insertLine(const string& table, TeLine2D& l);
    00111
    00113                       bool updateLine(const string& table, TeLine2D& l);
    00114
    00116                       bool locateLine(const string& table, TeCoord2D& pt, TeLine2D& line, const double& tol = 0.0);
    00117
    00119                       bool insertPoint(const string& table, TePoint& p);
    00120
    00122                       bool updatePoint(const string& table, TePoint& p);
    00123
    00125                       bool locatePoint(const string& table, TeCoord2D& pt, TePoint& point, const double& tol = 0.0);
    00126
    00128                       bool insertNode(const string& table, TeNode& node);
    00129
    00131                       bool updateNode(const string& table, TeNode& node);
    00132
    00134                       bool insertCell(const string& table, TeCell& c);
    00135
    00137                       bool updateCell(const string& table, TeCell& c);
    00138
    00140                       bool locateCell(const string& table, TeCoord2D& pt, TeCell& c, const double& tol = 0.0);
    00141
    00143                       virtual bool removeGeometry(const string& tableName, const TeGeomRep& rep, const int& geomId);
    00144
    00146                       bool createSpatialIndex(const string& table, const string& column, TeSpatialIndexType type = TeRTREE, short level = 0, short tile = 0);
    00147
    00149                       string getSQLBoxWhere(const TeBox& box, const TeGeomRep rep, const std::string& tableName);
    00150
    00152                       virtual std::string getSQLOrderBy(const TeGeomRep& rep) const;
    00153
    00155                       string getSQLBoxWhere(const string& table1, const string& table2, TeGeomRep rep2, TeGeomRep rep1 = TePOLYGONS);
    00156
    00158                       string getSQLBoxSelect(const string& tableName, TeGeomRep rep);
    00159
    00161                       bool getMBRGeom(string tableGeom, string object_id, TeBox& box, string colGeom);
    00162
    00164                       bool getMBRSelectedObjects(string geomTable, string colGeom, string fromClause, string whereClause, string afterWhereClause, TeGeomRep repType, TeBox& bout, const double& tol = 0.0);
    00165
    00167                       string getSpatialIdxColumn(TeGeomRep rep);
    00168
    00170                       bool getEncodingList(const std::string& host, const std::string& user, const std::string& password, const int& port, std::vector<std::string>& vecEncodingList);
    00171 };
    00172
    00173
    00175
    00178 class TLPOSTGRESQL_DLL TePostGISPortal : public TePostgreSQLPortal
    00179 {
    00180            public:
    00181
    00183                       TePostGISPortal()
    00184                       {
    00185                       }
    00186
    00188                       TePostGISPortal(TeDatabase *pDatabase);
    00189
    00191                       virtual ~TePostGISPortal()
    00192                       {
    00193                       };
    00194
    00195                       bool fetchGeometry(TePolygon& pol);
    00196                       bool fetchGeometry(TeLine2D& line);
    00197                       bool fetchGeometry(TeNode& n);
    00198                       bool fetchGeometry(TePoint& p);
    00199                       bool fetchGeometry(TeCell& cell);
    00200
    00201                       bool fetchGeometry(TePolygon& pol, const unsigned int& initIndex);
    00202                       bool fetchGeometry(TeLine2D& line, const unsigned int& initIndex);
    00203                       bool fetchGeometry(TeNode& n, const unsigned int& initIndex);
    00204                       bool fetchGeometry(TePoint& p, const unsigned int& initIndex);
    00205                       bool fetchGeometry(TeCell& cell, const unsigned int& initIndex);
    00206
    00207            protected:
    00208
    00209                       TePointSet            _multiPointBuffer;
    00210                       TeLineSet             _multiLineBuffer;
    00211                       TePolygonSet          _multiPolygonBuffer;
    00212
    00213 };
    00214
    00215
    00221 class TLPOSTGRESQL_DLL TePostGISFactory : public TeDatabaseFactory
    00222 {
    00223   public :
    00224
    00228     TePostGISFactory() : TeDatabaseFactory( std::string( "PostGIS" ) ) {};
    00229
    00233     ~TePostGISFactory() {};
    00234
    00235   protected :
    00236
    00244     TeDatabase* build( const TeDatabaseFactoryParams& arg )
    00245     {
    00246       TePostGIS* instance_ptr = new TePostGIS();
    00247
    00248       if( arg.host_ != "" ) {
    00249         instance_ptr->connect( arg.host_, arg.user_, arg.password_,
    00250           arg.database_, arg.port_ );
    00251       }
    00252
    00253       return (TeDatabase*)instance_ptr;
    00254     }
    00255 };
    00256
    00257 namespace {
    00258   static TePostGISFactory TePostGISFactory_instance;
    00259 };
    00260
    00261 #endif     // __TERRALIB_INTERNAL_POSTGIS_H
    00262

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines