| 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/Oracle/TeOracleSpatial.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 *************************************************************************************/
    00027 #ifndef  __TERRALIB_INTERNAL_ORACLESPATIAL_H
    00028 #define  __TERRALIB_INTERNAL_ORACLESPATIAL_H
    00029
    00030 #include "TeOCIOracle.h"
    00031
    00032 #include <TeDatabaseFactory.h>
    00033
    00034 #include "TeOracleDefines.h"
    00035
    00036 #ifdef AFX_DLL
    00037 #define EXPORT_WIN __declspec( dllexport )
    00038 #else
    00039 #define EXPORT_WIN
    00040 #endif
    00041
    00045 enum TeSDOGType
    00046 { TeSDOUNKNOWN, TeSDOPOINT, TeSDOLINE, TeSDOPOLYGON,TeSDOCOLLECTION,
    00047   TeSDOMULTIPOINT, TeSDOMULTILINE, TeSDOMULTIPOLYGON};
    00048
    00058 class TLORACLE_DLL TeOracleSpatial : public TeOCIOracle
    00059 {
    00060
    00061 friend class TeOracleSpatialPortal;
    00062
    00063 private:
    00064
    00066            bool       deleteMetadata(const string &table, const string &column);
    00067
    00069            bool       rebuildSpatialIndex(const string &table);
    00070
    00072            bool       deleteSpatialIndex(const string &table);
    00073
    00074 public:
    00075
    00077            TeOracleSpatial();
    00078
    00080            ~TeOracleSpatial()
    00081            {}
    00082
    00084            bool connect (const string& host, const string& user, const string& password, const string& database, int port = -1);
    00085
    00087     bool createTable (const string& table, TeAttributeList &attr);
    00088
    00090            bool createSpatialIndex(const string &table, const string &column,TeSpatialIndexType type= TeRTREE,short level=0,short tile=0);
    00091
    00093            bool insertMetadata(const string &table, const string &column, double tolx,double toly,TeBox &box,short srid=0);
    00094
    00096            string getSpatialIdxColumn(TeGeomRep rep);
    00097
    00099            TeDatabasePortal* getPortal ();
    00100
    00102            bool generateLabelPositions      (TeTheme *theme, const std::string& objectId = "");
    00103
    00107            bool insertPolygon               (const string& table, TePolygon &p);
    00108            bool updatePolygon               (const string& table, TePolygon &p);
    00109            bool locatePolygon               (const string& table, TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
    00110            bool selectPolygonSet (const string& table, const string& criteria, TePolygonSet &ps);
    00111            bool loadPolygonSet              (const string& table, const string& geoid, TePolygonSet &ps);
    00112            bool loadPolygonSet              (const string& table, TeBox &box, TePolygonSet &ps);
    00113            bool loadPolygonSet              (TeTheme* theme, TePolygonSet &ps);
    00114            TeDatabasePortal*                loadPolygonSet(const string& table, TeBox &box);
    00115            bool allocateOrdinatesObject(TePolygon &poly, string& elInfo, TeOCICursor* cursor=0);
    00116
    00117            bool insertLine                  (const string& table, TeLine2D &l);
    00118            bool updateLine                  (const string& table, TeLine2D &l);
    00119            bool locateLine                  (const string& table, TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
    00120            bool loadLineSet      (const string& table, const string& geoid, TeLineSet &ls);
    00121            bool loadLineSet      (const string& table, TeBox &box, TeLineSet &linSet);
    00122            TeDatabasePortal*   loadLineSet (const string& table, TeBox &box);
    00123            bool allocateOrdinatesObject(TeLine2D &line, TeOCICursor* cursor=0);
    00124
    00125     bool insertPoint  (const string& table, TePoint &p);
    00126            bool updatePoint      (const string& table, TePoint &p);
    00127            bool locatePoint      (const string& table, TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
    00128
    00129            bool insertText                  (const string& table, TeText &t);
    00130
    00131            bool insertArc                   (const string& table,TeArc &arc);
    00132            bool insertNode                  (const string& table, TeNode &node);
    00133            bool updateNode                  (const string& table, TeNode &node);
    00134
    00135            bool insertCell                  (const string& table, TeCell &c);
    00136            bool updateCell                  (const string& table, TeCell &c);
    00137            bool locateCell                  (const string& table, TeCoord2D &pt, TeCell &cell, const double& tol = 0.0);
    00138
    00140            virtual bool removeGeometry(const string& tableName, const TeGeomRep& rep, const int& geomId);
    00141
    00142            bool insertRasterBlock(const string& table, const string& blockId, const TeCoord2D& ll, const TeCoord2D& ur, unsigned char *buf,unsigned long size, int band=0, unsigned int res=1, unsigned int subband=0);
    00144
    00148
    00150            virtual std::string getSQLOrderBy(const TeGeomRep& rep) const;
    00151
    00152            string getSQLBoxWhere (const TeBox& box, const TeGeomRep rep, const std::string& tableName);
    00153
    00155            virtual string getSQLBoxWhere(const TeBox& box, const TeGeomRep rep, const std::string& tableName, const std::string& columnName);
    00156
    00157            string getSQLBoxWhere (const string& table1, const string& table2, TeGeomRep rep2, TeGeomRep rep1);
    00158            string getSQLBoxSelect (const string& tableName, TeGeomRep rep);
    00160
    00161            bool getMBRSelectedObjects(string geomTable,string colGeom, string fromClause, string whereClause, string afterWhereClause, TeGeomRep repType,TeBox &bout, const double& tol = 0.0);
    00162            bool getMBRGeom(string tableGeom, string object_id, TeBox& box, string colGeom);
    00163
    00167            bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeDatabasePortal *portal, int relate, const string& actCollTable="");
    00168            bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, const string& visGeomTable, TeGeomRep visRep, TeDatabasePortal *portal, int relate, const string& visCollTable="");
    00169            bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, TeDatabasePortal *portal, int relate, const string& actCollTable="");
    00170            bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, TeKeys& actIdsOut, int relate, const string& actCollTable="");
    00171            bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, const string& visGeomTable, TeGeomRep visRep, TeKeys& visIdsOut, int relate, const string& visCollTable="");
    00172            bool spatialRelation(const string& actGeomTable, TeGeomRep actRep, TeGeometry* geom, TeKeys& actIdsOut, int relate, const string& actCollTable="");
    00174
    00178            bool calculateArea(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsOut, double &area);
    00179            bool calculateLength(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIdsIn, double &length);
    00180            bool calculateDistance(const string& actGeomTable, TeGeomRep actRep, TeKeys& Ids, double& distance);
    00181            bool calculateDistance(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, TeGeomRep visRep, const string& objId2, double& distance);
    00183
    00187            bool buffer(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TePolygonSet& bufferSet, double dist);
    00188            bool convexHull(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TePolygonSet& convexHullSet);
    00189            bool centroid(const string&  actGeomTable , TeGeomRep actRep, TePointSet& centroidSet, TeKeys actIds = vector<string>(), const string& actCollTable = "");
    00191
    00195            bool nearestNeighbors(const string& actGeomTable, const string& actCollTable, TeGeomRep actRep, const string& objId1, TeKeys& actIdsOut, int numRes=1);
    00196            bool nearestNeighbors(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, const string& visCollTable, TeGeomRep visRep, TeKeys& visIdsOut, int numRes=1);
    00197            bool nearestNeighbors(const string& actGeomTable, const string& actCollTable, TeGeomRep actRep, const string& objId1, TeDatabasePortal* portal, int numRes=1);
    00198            bool nearestNeighbors(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, const string& visCollTable, TeGeomRep visRep, TeDatabasePortal* portal, int numRes=1);
    00200
    00204            bool geomIntersection(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeGeometryVect& geomVect);
    00205            bool geomIntersection(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
    00206            bool geomDifference(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& objId2, TeGeometryVect& geomVect);
    00207            bool geomDifference(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
    00208            bool geomUnion(const string& actGeomTable, TeGeomRep actRep, TeKeys& actIds, TeGeometryVect& geomVect);
    00209            bool geomUnion(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
    00210            bool geomXOr(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& objId2, TeGeometryVect& geomVect);
    00211            bool geomXOr(const string& actGeomTable, TeGeomRep actRep, const string& objId1, const string& visGeomTable, TeGeomRep visRep, const string& objId2, TeGeometryVect& geomVect);
    00213 };
    00214
    00225 class TLORACLE_DLL TeOracleSpatialPortal : public TeOCIOraclePortal
    00226 {
    00227
    00228            friend class TeOracleSpatial;
    00229
    00230 protected:
    00232            int                              getDimArraySize();
    00234            bool                  getDimElement(int i,int &elem);
    00236            int                              numberOfOrdinates();
    00238            bool                  getCoordinates(int i,TeCoord2D& coord);
    00240            bool                  getGeometryType(TeSDOGType& gType);
    00242            int                              getSpatialReferenceId();
    00244            bool                  getPointXYZ (double& x,double& y);
    00245
    00246 public:
    00247
    00249            TeOracleSpatialPortal(TeOracleSpatial* pDatabase) : TeOCIOraclePortal(pDatabase)
    00250            {}
    00251
    00253            virtual ~TeOracleSpatialPortal()
    00254            {}
    00255
    00257            bool querySDO (const string &q);
    00258
    00262            bool getGeometry (TeGeometry** geom, bool& result);
    00263            bool fetchGeometry (TePolygon& poly);
    00264            bool fetchGeometry (TePolygon& poly, const unsigned int& initIndex);
    00265            bool fetchGeometry (TePolygonSet& polySet);
    00266            bool fetchGeometry (TeLine2D& line);
    00267            bool fetchGeometry (TeLine2D& line, const unsigned int& initIndex);
    00268            bool fetchGeometry (TeLineSet& lineSet);
    00269            bool fetchGeometry (TeNode& n);
    00270            bool fetchGeometry (TeNode& n, const unsigned int& initIndex);
    00271            bool fetchGeometry (TePoint& p);
    00272            bool fetchGeometry (TePoint& p, const unsigned int& initIndex);
    00273            bool fetchGeometry (TePointSet& pointSet);
    00274            bool fetchGeometry (TeCell& cell);
    00275            bool fetchGeometry (TeCell& cell, const unsigned int& initIndex);
    00277 };
    00278
    00279
    00285 class TLORACLE_DLL TeOracleSpatialFactory : public TeDatabaseFactory
    00286 {
    00287   public :
    00288
    00292     TeOracleSpatialFactory() : TeDatabaseFactory(
    00293       std::string( "OracleSpatial" ) ) {};
    00294
    00298     ~TeOracleSpatialFactory() {};
    00299
    00300   protected :
    00301
    00309     TeDatabase* build( const TeDatabaseFactoryParams& arg )
    00310     {
    00311       TeOracleSpatial* instance_ptr = new TeOracleSpatial();
    00312
    00313       if( arg.host_ != "" ) {
    00314         instance_ptr->connect( arg.host_, arg.user_, arg.password_,
    00315           arg.database_, arg.port_ );
    00316       }
    00317
    00318       return (TeDatabase*)instance_ptr;
    00319     }
    00320 };
    00321
    00322 namespace {
    00323   static TeOracleSpatialFactory TeOracleSpatialFactory_instance;
    00324 };
    00325
    00326 #endif
    00327
    00328
    00329

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines