| 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/ado/TeAdoSqlServerSpatial.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_ADOSQLSERVER_SPATIAL_H
    00027 #define  __TERRALIB_INTERNAL_ADOSQLSERVER_SPATIAL_H
    00028
    00029 #include <TeDatabaseFactory.h>
    00030
    00031 #ifdef WIN32
    00032 #pragma warning ( disable: 4192 )
    00033 #pragma warning ( disable: 4146 )
    00034 #include <atldbcli.h>
    00035 #include <iostream>
    00036 #include <comdef.h>
    00037
    00038 /*
    00039  *   Lets use the import directive to create some smart pointers for us
    00040  */
    00041 #import "msado26.tlb"  rename("EOF", "IsEOF") rename("BOF", "IsBOF")
    00042 #import <msadox.dll>
    00043 #import <oledb32.dll> rename_namespace("OLEDB")
    00044 #else
    00045 #error ONLY FOR WINDOWS OPERATIONAL SYSTEM
    00046 #endif
    00047
    00048 #include <TeDatabase.h>
    00049 #include <TeAdoDB.h>
    00050 #include <TeAdoSqlServer.h>
    00051
    00052
    00053 #ifdef AFX_DLL
    00054 #define EXPORT_WIN __declspec( dllexport )
    00055 #else
    00056 #define EXPORT_WIN
    00057 #endif
    00058
    00060 class  TLADO_DLL  TeSqlServerSpatial : public TeSqlServer
    00061 {
    00062 friend class TeSqlServerSpatialPortal;
    00063
    00064 protected:
    00065
    00066            virtual std::string STGeomFromWkb(const TePolygon &polygon);
    00067
    00069
    00073            virtual std::string STGeomFromText(const TePolygon &polygon);
    00074
    00076
    00080            virtual std::string STGeomFromText(const TeLine2D &line);
    00081
    00083
    00087            virtual std::string STGeomFromText(const TePoint &point);
    00088
    00090
    00095            virtual bool PutBinaryIntoVariant(VARIANT &ovData, BYTE * pBuf,unsigned long cBufLen);
    00096
    00097 public:
    00098
    00100            TeSqlServerSpatial();
    00101
    00103            ~TeSqlServerSpatial();
    00104
    00105            virtual bool connect (const string& host, const string& user, const string& password, const string& database,  int port = -1);
    00106
    00107
    00108            // Methods to manipulate a table
    00109
    00111
    00117     bool columnExist(const string& table, const string& column, TeAttribute& attr);
    00118
    00120
    00125            bool createTable(const string& table, TeAttributeList &attr);
    00126
    00128
    00134            bool alterTable (const string& table, TeAttributeRep &rep, const string& oldColName="");
    00135
    00136            // Insert an attribute table
    00138
    00144            bool generateLabelPositions (TeTheme *theme, const std::string& objectId = "");
    00145
    00147
    00152            bool insertPolygonSet (const string& table, TePolygonSet &ps);
    00153
    00155
    00160     bool insertPolygon (const string& table, TePolygon &p);
    00161
    00163
    00168            bool insertLineSet(const string& table, TeLineSet &ls);
    00169
    00171
    00176            bool insertLine(const string& table, TeLine2D &l);
    00177
    00179
    00184            bool insertPointSet(const string& table, TePointSet &ps);
    00185
    00187
    00192            bool insertPoint(const string& table, TePoint &p);
    00193
    00195
    00200            bool insertTextSet(const string& table, TeTextSet &ts);
    00201
    00203
    00208            bool insertText(const string& table, TeText &t);
    00209
    00211
    00215            virtual bool createTextGeometry(const string& table);
    00216
    00218
    00223            virtual string  getSQLBoxWhere(const TeBox& box, const TeGeomRep rep, const std::string& );
    00224
    00226
    00230            virtual std::string getSQLOrderBy(const TeGeomRep& rep) const;
    00231
    00233
    00236     TeDatabasePortal* getPortal ();
    00237
    00239
    00241            bool       createSpatialIndex(const string& table, const string& columns, TeSpatialIndexType type, short level, short tile);
    00242
    00244            virtual bool          getMBRSelectedObjects(string geomTable,string colGeom, string fromClause, string whereClause, string afterWhereClause, TeGeomRep repType,TeBox &bout, const double& tol);
    00245
    00246            virtual bool locatePoint (const string& table, TeCoord2D &pt, TePoint &point, const double& tol);
    00247
    00248            virtual bool locatePolygon (const string& table, TeCoord2D &pt, TePolygon &polygon, const double& tol);
    00249
    00250            virtual bool locatePolygonSet (const string& table, TeCoord2D &pt, double tol, TePolygonSet &polygons);
    00251
    00252            virtual bool locateLine                     (const string& table, TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
    00253
    00254            virtual bool locateLineSet       (const string& table, TeCoord2D &pt, TeLineSet & ls, const double& tol = 0.0);
    00255
    00256 };
    00257
    00259 class  TLADO_DLL  TeSqlServerSpatialPortal : public TeAdoPortal
    00260 {
    00261
    00262 public :
    00263
    00264            // Constructor / Destructor
    00265            TeSqlServerSpatialPortal ();
    00266            TeSqlServerSpatialPortal (TeDatabase* pDatabase);
    00267            ~TeSqlServerSpatialPortal ();
    00268
    00269            TeTime getDate (int i);
    00270            TeTime getDate (const string& s);
    00271
    00272            string getDateAsString(int i);
    00273            string getDateAsString(const string& s);
    00274            bool       fetchGeometry(TePolygon& pol);
    00275            bool       fetchGeometry(TeLine2D& line);
    00276            bool       fetchGeometry(TePoint& p);
    00277            bool       fetchGeometry(TePoint& p, const unsigned int& initIndex);
    00278 };
    00279
    00280
    00286 class TLADO_DLL TeSqlServerSpatialFactory : public TeDatabaseFactory
    00287 {
    00288   public :
    00289
    00293     TeSqlServerSpatialFactory() : TeDatabaseFactory(
    00294       std::string( "SqlServerAdoSpatial" ) ) {};
    00295
    00299     ~TeSqlServerSpatialFactory() {};
    00300
    00301   protected :
    00302
    00310     TeDatabase* build( const TeDatabaseFactoryParams& arg )
    00311     {
    00312       TeSqlServerSpatial* instance_ptr = new TeSqlServerSpatial();
    00313
    00314       if( arg.host_ != "" ) {
    00315         instance_ptr->connect( arg.host_, arg.user_, arg.password_,
    00316           arg.database_, arg.port_ );
    00317       }
    00318
    00319       return (TeDatabase*)instance_ptr;
    00320     }
    00321 };
    00322
    00323 namespace {
    00324   static TeSqlServerSpatialFactory TeSqlServerSpatialFactory_instance;
    00325 };
    00326
    00327
    00328 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines