/usr/include/terralib/kernel/TeLayer.h is in libterralib-dev 4.0.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | /************************************************************************************
TerraLib - a library for developing GIS applications.
Copyright © 2001-2007 INPE and Tecgraf/PUC-Rio.
This code is part of the TerraLib library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
You should have received a copy of the GNU Lesser General Public
License along with this library.
The authors reassure the license terms regarding the warranties.
They specifically disclaim any warranties, including, but not limited to,
the implied warranties of merchantability and fitness for a particular purpose.
The library provided hereunder is on an "as is" basis, and the authors have no
obligation to provide maintenance, support, updates, enhancements, or modifications.
In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
indirect, special, incidental, or consequential damages arising out of the use
of this library and its documentation.
*************************************************************************************/
/*! \file TeLayer.h
\brief This file contains structures and definitions to deal with a layer
*/
#ifndef __TERRALIB_INTERNAL_LAYER_H
#define __TERRALIB_INTERNAL_LAYER_H
#include "TeGeometry.h"
#include "TeDataTypes.h"
#include "TeTable.h"
#include "TeRepresentation.h"
#include <string>
#include <list>
#include <map>
class TeRaster;
class TeDatabase;
class TeRasterParams;
class TeProjection;
//! A class for supporting a layer.
/*!
In TerraLib, a layer is a collection of geometries that share the same
geographical projection, and are related in some way (e.g. a shapefile).
A layer has a pointer to a database that effectively stores its atributes
and geometries.
\sa
TeGeometry, TeProjection, TeBox, TeDatabase, TeTheme, TeTable
*/
class TL_DLL TeLayer {
public:
//! Empty constructor
TeLayer():
id_(-1),
db_(0),
projection_ ( 0 ),
raster_(0)
{ }
//! Constructor with parameters
/*
\param name layer name (should be unique)
\param db a TerraLib database connection w
\param proj layer projection
\note
\par If no database is informed, layer will exist only in memory.
\par If a layer with this name doesn´t exist a layer will be
created and stored. If no projection is informed a default TeNoProjection
will be used as layer projection.
\par If a layer with this name already exists it will be retrieved
*/
TeLayer(const string& name, TeDatabase* db=0, TeProjection* proj=0);
//! Constructor with parameters
/*
\param name layer name (should be unique)
\param db TerraLib database connection where layer will be stored
\param box layer bounding box
\param proj layer projection
\note
\par If no database is informed, layer will exist only in memory.
\par If a layer with this name doesn´t exist a layer will be
created and stored. If no projection is informed a default TeNoProjection
will be used as layer projection.
\par If a layer with this name already exists it will be retrieved
*/
TeLayer(const string& name, TeDatabase* db, TeBox& box, TeProjection* proj = 0);
//! Destructor
virtual ~TeLayer();
//! Copy Constructor
TeLayer ( const TeLayer& other );
//! Operator =
TeLayer& operator= ( const TeLayer& other );
//! Retrieves the database associated to this layer
virtual TeDatabase* const database()
{ return db_; }
//! Sets the layer database
virtual void setDatabase(TeDatabase* db)
{ db_ = db; }
//! Returns the layer id
virtual int id()
{ return id_; }
//! Sets the layer id
virtual void id(int id)
{ id_ = id; }
//! Returns the layer name
virtual string name()
{ return name_; }
//! Sets the layer name
virtual void name(const string &name)
{ name_ = name; }
//! Sets the layer projection
virtual void setProjection ( TeProjection* proj );
//! Retrieves the layer projection
virtual TeProjection* projection()
{ return projection_; }
//! Returns the layer bounding box
virtual TeBox& box()
{ return box_; }
//! Sets the bounding box of a layer
virtual void setLayerBox ( const TeBox& box );
//! Updates the bounding box of a layer
virtual void updateLayerBox(const TeBox& box);
//! Refreshes the bounding box of a layer according to its representation
virtual void updateLayerBox();
//! Returns a possible new object id based on the objects stored in database
virtual int getNewObjectId();
/** @name Attribute Tables
* Methods to deal with the attribute tables of the layer
*/
//@{
//! Returns the number of distinct objects in the layer
virtual int nObjects(const string& tName);
//! Returns a vector with the definition of all attribute tables associated to layer
virtual TeAttrTableVector& attrTables ()
{ return attTables_; }
//! Returns a vector with the definition of all attribute tables associated to layer
virtual const TeAttrTableVector& attrTables () const
{ return attTables_; }
//! Creates a new attribute table for the layer
virtual bool createAttributeTable(TeTable& table);
//! Adds an attribute table definition to layer vector of attribute tables (in memory)
virtual bool addAttributeTable(TeTable& table);
//! Remove an attribute table definition to layer vector of attribute tables (in memory)
virtual bool removeAttributeTable(string tableName);
//! Update an attribute table definition to layer vector of attribute tables (in memory)
virtual void updateAttributeTable(TeTable& table);
//! Reload the tables definition from database to memory
virtual bool loadLayerTables();
//! Saves an attribute table into the database where layer is stored
virtual bool saveAttributeTable(TeTable& table);
//! Gets all attribute tables associated to this layer that are of a certain type
virtual bool getAttrTables(TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
//! Gets a set of attribute table specifications associated to this layer that are of a certain type
/*
\param tableNames a vector that contains the name of the tables that are being searched
\param attType type of table that is being searched
\param atts returns a vector of tables found
\return true if at least one table was found and false otherwise
*/
virtual bool getAttrTablesByName(vector<string> &tableNames, TeAttrTableVector& atts, TeAttrTableType attType = TeAllAttrTypes);
//! Gets an attribute table associated to a layer
/*
\param tableName name of the table being searched
\param attType type of table being searched
\param table returns the table found
\return true if table was found and false otherwise
*/
virtual bool getAttrTablesByName(const string& tableName, TeTable& table, TeAttrTableType attType = TeAllAttrTypes);
//! Gets the name of the media table associated to layer
virtual string mediaTable();
//! Sets the name of the media table associated to layer
virtual void mediaTable(const string& name);
//@}
/** @name Geometries
* Methods to deal with the geometries of the objects of a layer
*/
//! Returns a pointer to the raster geometry associated to an object of this layer
/*!
\param objectId unique identification of the object (if empty it will look
for the first raster geometry found)
\param mode permission access ('r', 'w')
*/
virtual TeRaster* raster(const string& objectId="",const char& mode = 'r');
//! Sets the pointer to the raster representation
virtual void raster( TeRaster* raster);
//! Retrieves a polygon set given a selection criteria, expressed as a where clause
virtual bool getPolygons(TePolygonSet &ps, const string& whereClause = "");
//! Retrieves a line set given a selection criteria, expressed as a where clause
virtual bool getLines(TeLineSet &ls, const string& whereClause = "");
//! Retrieves a point set given a selection criteria, expressed as a where clause
virtual bool getPoints(TePointSet &ps, const string& whereClause = "");
//! Retrieve a point set given a selection criteria, expressed as a where clause
virtual bool getText(TeTextSet &ts, const string& whereClause = "");
//! Retrieve a cell set given a selection criteria, expressed as a where clause
virtual bool getCells(TeCellSet &cs, const string& whereClause = "");
//! Locates a polygon that cointains a certain coordinate
virtual bool locatePolygon(TeCoord2D &pt, TePolygon &polygon, const double& tol = 0.0);
//! Locates a line that cointains a certain coordinate
virtual bool locateLine(TeCoord2D &pt, TeLine2D &line, const double& tol = 0.0);
//! Retrieves a point that cointains a certain coordinate
virtual bool locatePoint(TeCoord2D &pt, TePoint &point, const double& tol = 0.0);
//! Retrieves a TeText that cointains a certain coordinate
virtual bool locateText(TeCoord2D &pt, TeText &text, const double& tol = 0.0);
//! Retrieves a point that cointains a certain coordinate
virtual bool locateCell(TeCoord2D &pt, TeCell &cell, const double& tol = 0.0);
//! Retrieves the set of polygons with a certain geoid
virtual bool loadGeometrySet (const string& geoid, TePolygonSet &ps);
//! Retrieves the set of lines with a certain geoid
virtual bool loadGeometrySet (const string& geoid, TeLineSet &ls);
//! Retrieves the set of points with a certain geoid
virtual bool loadGeometrySet (const string& geoid, TePointSet &ps);
//! Retrieves the set of points with a certain geoid
virtual bool loadGeometrySet (const string& geoid, TeCellSet &cs);
//! Retrieves the set of texts with a certain geoid
virtual bool loadGeometrySet (const string& geoid, TeTextSet &cs);
//! Adds a set of polygons to a layer
virtual bool addGeometrySet(TePolygonSet& polySet, const string& /* tName */ = "")
{ return addPolygons(polySet); }
//! Adds a set of lines to a layer
virtual bool addGeometrySet(TeLineSet& lineSet, const string& /* tName */ = "")
{ return addLines(lineSet); }
//! Adds a set of points to a layer
virtual bool addGeometrySet(TePointSet& pointSet, const string& /* tName */ = "")
{ return addPoints(pointSet); }
//! Adds a set of text to a layer
virtual bool addGeometrySet(TeTextSet& textSet, const string& tName = "")
{ return addText(textSet,tName); }
//! Adds a set of cells to a layer
virtual bool addGeometrySet(TeCellSet& cellSet, const string& /* tName */ = "")
{ return addCells(cellSet); }
//! Adds a set of polygons to a layer
virtual bool addPolygons(TePolygonSet& polySet);
//! Adds a set of lines to a layer
virtual bool addLines (TeLineSet& lineSet);
//! Adds a set of points to a layer
virtual bool addPoints (TePointSet& pointSet);
//! Adds a set of text to a layer
virtual bool addText (TeTextSet& textSet,const string& tName);
//! Adds a set of cells to a layer
virtual bool addCells(TeCellSet& cellSet);
//! Updates a set of polygons to a layer
virtual bool updatePolygons(TePolygonSet& polySet);
//! Updates a set of lines to a layer
virtual bool updateLines (TeLineSet& lineSet);
//! Updates a set of points to a layer
virtual bool updatePoints (TePointSet& pointSet);
//! Updates a set of text to a layer
virtual bool updateText (TeTextSet& textSet,const string& tName);
//! Updates a set of cells to a layer
virtual bool updateCells(TeCellSet& cellSet);
//! Removes the geometries from the layer
virtual bool removeGeometries(const std::vector<int>& vecGeomIds, const TeGeomRep& rep);
//@}
/** @name Geometries
* Methods to deal with geometrical representations of a layer
*/
//! Removes a geometry from layer
virtual bool removeGeometry (TeGeomRep repType, const string& tName="");
//! Indicates if layer has a geometry representation
virtual bool hasGeometry (TeGeomRep rep);
//! Retrieves the table name associated to a geometry representation
/*! \param rep geometrical representation
\note When there is more than one representation of a given type
returns the table name associated to the first one encountered
*/
virtual string tableName(TeGeomRep rep);
//! Retrieves the number of geometries of a type
/*!
\param rep geometrical representation
*/
virtual int nGeometries(TeGeomRep rep);
//! Gets all information about a representation
virtual bool getRepresentation(TeGeomRep repType, TeRepresPointerVector& result);
//! Gets an specific representation
/*!
\param repType the geometrical representation being searched
\param tableName the table associated to this representation
\return the representation associated to a geometry with the given table name
\note if no table name is specified the first found is returned
*/
virtual TeRepresentation* getRepresentation(TeGeomRep repType, const string& tableName="");
//! Creates a new geometry representation to a layer
/*
\param repType the geometrical representation being searched
\param tableName name of the table that will stored the geometries
\param desc description of the representation
\return true if success and false otherwise
*/
virtual bool addGeometry ( TeGeomRep repType, const string& tableName="", const string& desc = "");
//! Creates a new raster geometry to a layer
/*
\param par raster parameters
\param objectId identifier of the object that has the raster geometry
\param tableName name of the table that will stored the geometries
\param desc description of the representation
\return true if success and false otherwise
*/
virtual bool addRasterGeometry(TeRasterParams& par, const string& objectId,
const string& tableName="", const string& desc="");
//! Inserts a raster as a geometry of an object of the layer
/*
\param raster a pointer to a raster object
\param objectId identifier of the object that has the raster geometry
\param tableName the name of the table that will store the geometry (optional)
\return true if success and false otherwise
\note if there is already raster geometry associated to the object with id
object id, this reference is deleted.
*/
bool addRasterGeometry(TeRaster* raster, const string& objectId="");
//! Inserts a reference to a raster file as a raster geometry of an object of the layer
/*
\param raster a pointer to a raster object
\param objectId identifier of the object that has the raster geometry
\param desc the description of the geometry (optional)
\return true if success and false otherwise
\note if there is already raster geometry associated to the object with id
object id, this reference is deleted.
*/
bool addRasterFileGeometry(TeRaster* raster, const string& objectId="", const string& desc="");
//! Returns a vector with the identification of all objects of the layer that has a raster representation
/*
\param objectIds a vector to return the identification of the objects with a raster representation
\param tilingType used to express that only some types of representations are looked for:
0 any kind, 1 only the expansible and 2 only the non-expansible
\param box box spatial restriction
\return true if layer has at least one raster object and false otherwise
*/
virtual bool getRasterGeometries(vector<string>& objectIds, unsigned int tilingType=0, const TeBox& box = TeBox());
//! Returns a combination of all representations in the layer
virtual int geomRep();
//! Adds a representation to vector of representation of the layer
virtual void addVectRepres(TeRepresentation* rep)
{ repVector_.push_back(rep); }
//! Returns a vector with all representations in the layer
virtual TeRepresPointerVector& vectRepres()
{ return repVector_; }
virtual const TeRepresPointerVector& vectRepres() const
{ return repVector_; }
//!< Returns the dateTime that the layer was last edited.
virtual TeTime getEditionTime() const;
//!< Sets in memory the edition time of the layer
virtual void setEditionTime(const TeTime& editionTime);
//!< Updates the layer last edition time in memory and in the database
virtual bool updateLayerEditionTime(const bool& setEditionToNow = true);
//!< Reloads the edition time from the database
virtual bool reloadLayerEditionTime();
//@}
private:
// -- Members
// -- General Description of a layer
string name_; //!< layer name
int id_; //!< layer unique identification
TeDatabase* db_; //!< database connection to this layer
TeProjection* projection_; //!< layer projection
TeBox box_; //!< layer bounding box
TeRaster* raster_; //!< layer raster representation
TeAttrTableVector attTables_; //!< Attributes associated to a layer
TeRepresPointerVector repVector_; //!< vector of representations associated to this layer
TeTime editionTime_; //!< Stores the last time that the layer was edited.
};
//! A map from a integer unique identifier to a pointer to layer
typedef map<int,TeLayer*> TeLayerMap;
/** \example createLayer.cpp
Shows how to create a layer in a TerraLib database, and insert some vectorial data in this new layer
*/
/** \example addGeomRepresentation.cpp
Shows how to create a point representation (centroid of polygons) to a layer in a TerraLib database.
*/
#endif
|