| 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/kernel/TeLayer.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_LAYER_H
    00027 #define __TERRALIB_INTERNAL_LAYER_H
    00028
    00029 #include "TeGeometry.h"
    00030 #include "TeDataTypes.h"
    00031 #include "TeTable.h"
    00032 #include "TeRepresentation.h"
    00033
    00034 #include <string>
    00035 #include <list>
    00036 #include <map>
    00037
    00038 class TeRaster;
    00039 class TeDatabase;
    00040 class TeRasterParams;
    00041 class TeProjection;
    00042
    00044
    00053 class TL_DLL TeLayer {
    00054
    00055 public:
    00056
    00058            TeLayer():
    00059                       id_(-1),
    00060                       db_(0),
    00061                       projection_ ( 0 ),
    00062                       raster_(0)
    00063                       { }
    00064
    00065
    00067            /*
    00068                       \param name layer name (should be unique)
    00069                       \param db a TerraLib database connection w
    00070                       \param proj layer projection
    00071                       \note
    00072                                  \par If no database is informed, layer will exist only in memory.
    00073                                  \par If a layer with this name doesn´t exist a layer will be
    00074                                   created and stored. If no projection is informed a default TeNoProjection
    00075                                   will be used as layer projection.
    00076             \par If a layer with this name already exists it will be retrieved
    00077            */
    00078            TeLayer(const string& name, TeDatabase* db=0, TeProjection* proj=0);
    00079
    00081            /*
    00082                       \param name layer name (should be unique)
    00083                       \param db TerraLib database connection where layer will be stored
    00084                       \param box layer bounding box
    00085                       \param proj layer projection
    00086                       \note
    00087                                  \par If no database is informed, layer will exist only in memory.
    00088                                  \par If a layer with this name doesn´t exist a layer will be
    00089                                   created and stored. If no projection is informed a default TeNoProjection
    00090                                   will be used as layer projection.
    00091             \par If a layer with this name already exists it will be retrieved
    00092            */
    00093            TeLayer(const string& name, TeDatabase* db, TeBox& box, TeProjection* proj = 0);
    00094
    00096            virtual ~TeLayer();
    00097
    00099            TeLayer ( const TeLayer& other );
    00100
    00102            TeLayer& operator= ( const TeLayer& other );
    00103
    00105            virtual TeDatabase* const database()
    00106            { return db_; }
    00107
    00109            virtual void setDatabase(TeDatabase* db)
    00110            { db_ = db; }
    00111
    00113            virtual int id()
    00114            { return id_; }
    00115
    00117            virtual void id(int id)
    00118            { id_ = id; }
    00119
    00121            virtual string name()
    00122            { return name_; }
    00123
    00125            virtual void name(const string &name)
    00126            {  name_ = name; }
    00127
    00129            virtual void  setProjection ( TeProjection* proj );
    00130
    00132            virtual TeProjection* projection()
    00133            {          return projection_; }
    00134
    00136            virtual TeBox&        box()
    00137            {          return box_; }
    00138
    00140            virtual void setLayerBox ( const TeBox& box );
    00141
    00143            virtual void updateLayerBox(const TeBox& box);
    00144
    00146            virtual void updateLayerBox();
    00147
    00149            virtual int getNewObjectId();
    00150
    00155
    00157            virtual int nObjects(const string& tName);
    00158
    00160            virtual TeAttrTableVector& attrTables ()
    00161            { return attTables_; }
    00162
    00164            virtual const TeAttrTableVector& attrTables () const
    00165            { return attTables_; }
    00166
    00168            virtual bool createAttributeTable(TeTable& table);
    00169
    00171            virtual bool addAttributeTable(TeTable& table);
    00172
    00174            virtual bool removeAttributeTable(string tableName);
    00175
    00177            virtual void updateAttributeTable(TeTable& table);
    00178
    00180            virtual bool loadLayerTables();
    00181
    00183            virtual bool saveAttributeTable(TeTable& table);
    00184
    00186            virtual bool getAttrTables(TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
    00187
    00189            /*
    00190                       \param tableNames a vector that contains the name of the tables that are being searched
    00191                       \param attType type of table that is being searched
    00192                       \param atts returns a vector of tables found
    00193                       \return true if at least one table was found and false otherwise
    00194            */
    00195            virtual bool getAttrTablesByName(vector<string> &tableNames, TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
    00196
    00198            /*
    00199                       \param tableName name of the table being searched
    00200                       \param attType type of table being searched
    00201                       \param table returns the table found
    00202                       \return true if table was found and false otherwise
    00203            */
    00204            virtual bool getAttrTablesByName(const string& tableName, TeTable& table, TeAttrTableType attType = TeAllAttrTypes);
    00205
    00207            virtual string mediaTable();
    00208
    00210            virtual void mediaTable(const string& name);
    00212
    00216
    00217
    00222            virtual TeRaster* raster(const string& objectId="",const char& mode = 'r');
    00223
    00225            virtual void raster( TeRaster* raster);
    00226
    00228            virtual bool getPolygons(TePolygonSet &ps, const string& whereClause = "");
    00229
    00231            virtual bool getLines(TeLineSet &ls, const string& whereClause = "");
    00232
    00234            virtual bool getPoints(TePointSet &ps, const string& whereClause = "");
    00235
    00237            virtual bool getText(TeTextSet &ts, const string& whereClause = "");
    00238
    00240            virtual bool getCells(TeCellSet &cs, const string& whereClause = "");
    00241
    00243            virtual bool locatePolygon(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
    00244
    00246            virtual bool locateLine(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
    00247
    00249            virtual bool locatePoint(TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
    00250
    00252            virtual bool locateText(TeCoord2D &pt, TeText &text, const double& tol = 0.0);
    00253
    00255            virtual bool locateCell(TeCoord2D &pt, TeCell &cell, const double& tol = 0.0);
    00256
    00258            virtual bool loadGeometrySet     (const string& geoid, TePolygonSet &ps);
    00259
    00261            virtual bool loadGeometrySet (const string& geoid, TeLineSet &ls);
    00262
    00264            virtual bool loadGeometrySet (const string& geoid, TePointSet &ps);
    00265
    00267            virtual bool loadGeometrySet (const string& geoid, TeCellSet &cs);
    00268
    00270            virtual bool loadGeometrySet (const string& geoid, TeTextSet &cs);
    00271
    00273            virtual bool addGeometrySet(TePolygonSet& polySet, const string& /* tName */ = "")
    00274            { return addPolygons(polySet); }
    00275
    00277            virtual bool addGeometrySet(TeLineSet& lineSet, const string& /* tName */ = "")
    00278            { return addLines(lineSet); }
    00279
    00281            virtual bool addGeometrySet(TePointSet& pointSet, const string& /* tName */ = "")
    00282            { return addPoints(pointSet); }
    00283
    00285            virtual bool addGeometrySet(TeTextSet& textSet, const string& tName = "")
    00286            { return addText(textSet,tName); }
    00287
    00289            virtual bool addGeometrySet(TeCellSet& cellSet, const string& /* tName */ = "")
    00290            { return addCells(cellSet); }
    00291
    00293            virtual bool addPolygons(TePolygonSet& polySet);
    00294
    00296            virtual bool addLines (TeLineSet& lineSet);
    00297
    00299            virtual bool addPoints (TePointSet& pointSet);
    00300
    00302            virtual bool addText (TeTextSet& textSet,const string& tName);
    00303
    00305            virtual bool addCells(TeCellSet& cellSet);
    00306
    00308            virtual bool updatePolygons(TePolygonSet& polySet);
    00309
    00311            virtual bool updateLines (TeLineSet& lineSet);
    00312
    00314            virtual bool updatePoints (TePointSet& pointSet);
    00315
    00317            virtual bool updateText (TeTextSet& textSet,const string& tName);
    00318
    00320            virtual bool updateCells(TeCellSet& cellSet);
    00321
    00323            virtual bool removeGeometries(const std::vector<int>& vecGeomIds, const TeGeomRep& rep);
    00324
    00326
    00330
    00331            virtual bool removeGeometry (TeGeomRep repType, const string& tName="");
    00332
    00334            virtual bool hasGeometry (TeGeomRep rep);
    00335
    00337
    00341            virtual string tableName(TeGeomRep rep);
    00342
    00344
    00347            virtual int nGeometries(TeGeomRep rep);
    00348
    00350            virtual bool getRepresentation(TeGeomRep repType, TeRepresPointerVector& result);
    00351
    00353
    00359            virtual TeRepresentation* getRepresentation(TeGeomRep repType, const string& tableName="");
    00360
    00362            /*
    00363                       \param repType the geometrical representation being searched
    00364                       \param tableName name of the table that will stored the geometries
    00365                       \param desc description of the representation
    00366                       \return true if success and false otherwise
    00367            */
    00368            virtual bool addGeometry ( TeGeomRep repType, const string& tableName="", const string& desc = "");
    00369
    00371            /*
    00372                       \param par raster parameters
    00373                       \param objectId identifier of the object that has the raster geometry
    00374                       \param tableName name of the table that will stored the geometries
    00375                       \param desc description of the representation
    00376                       \return true if success and false otherwise
    00377            */
    00378            virtual bool addRasterGeometry(TeRasterParams& par, const string& objectId,
    00379                                                                      const string& tableName="", const string& desc="");
    00380
    00382            /*
    00383                       \param raster a pointer to a raster object
    00384                       \param objectId identifier of the object that has the raster geometry
    00385                       \param tableName the name of the table that will store the geometry (optional)
    00386                       \return true if success and false otherwise
    00387                       \note if there is already raster geometry associated to the object with id
    00388                       object id, this reference is deleted.
    00389            */
    00390            bool addRasterGeometry(TeRaster* raster, const string& objectId="");
    00391
    00393            /*
    00394                       \param raster a pointer to a raster object
    00395                       \param objectId identifier of the object that has the raster geometry
    00396                       \param desc the description of the geometry (optional)
    00397                       \return true if success and false otherwise
    00398                       \note if there is already raster geometry associated to the object with id
    00399                       object id, this reference is deleted.
    00400            */
    00401            bool addRasterFileGeometry(TeRaster* raster, const string& objectId="", const string& desc="");
    00402
    00403
    00405            /*
    00406                       \param objectIds a vector to return the identification of the objects with a raster representation
    00407                       \param tilingType used to express that only some types of representations are looked for:
    00408                                     0 any kind, 1 only the expansible and 2 only the non-expansible
    00409                       \param box box spatial restriction
    00410                       \return true if layer has at least one raster object and false otherwise
    00411            */
    00412            virtual bool getRasterGeometries(vector<string>& objectIds, unsigned int tilingType=0, const TeBox& box = TeBox());
    00413
    00415            virtual int geomRep();
    00416
    00418            virtual void addVectRepres(TeRepresentation* rep)
    00419            {          repVector_.push_back(rep); }
    00420
    00422            virtual TeRepresPointerVector& vectRepres()
    00423            {          return repVector_; }
    00424
    00425   virtual const TeRepresPointerVector& vectRepres() const
    00426            {          return repVector_; }
    00427
    00429            virtual TeTime getEditionTime() const;
    00430
    00432            virtual void setEditionTime(const TeTime& editionTime);
    00433
    00435            virtual bool updateLayerEditionTime(const bool& setEditionToNow = true);
    00436
    00438            virtual bool reloadLayerEditionTime();
    00439
    00441
    00442 private:
    00443
    00444 // -- Members
    00445
    00446 // -- General Description of a layer
    00447
    00448            string                name_;
    00449            int                              id_;
    00450            TeDatabase*           db_;
    00451            TeProjection*         projection_;
    00452            TeBox                 box_;
    00453            TeRaster*  raster_;
    00454
    00455            TeAttrTableVector     attTables_;
    00456            TeRepresPointerVector repVector_;
    00457            TeTime                editionTime_;
    00458 };
    00459
    00461 typedef map<int,TeLayer*> TeLayerMap;
    00462
    00470 #endif
    00471
    00472
    00473

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines