Geometry.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/geometry/Geometry.h
22 
23  \brief Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_GEOMETRY_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_GEOMETRY_H
28 
29 // TerraLib
30 #include "../common/BaseVisitable.h"
31 #include "../common/Enums.h"
32 #include "../datatype/AbstractData.h"
33 #include "Enums.h"
34 #include "Exception.h"
35 #include "Visitor.h"
36 
37 // STL
38 #include <exception>
39 #include <map>
40 #include <string>
41 
42 // Boost
43 #include <boost/shared_ptr.hpp>
44 
45 namespace te
46 {
47  namespace gm
48  {
49 // Forward declarations
50  class Envelope;
51 
52  /*!
53  \class Geometry
54 
55  \brief Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
56 
57  The geometry model follows OGC Simple Feature
58  Specification - SFS (Simple Feature Access - Part 1: Common Architecture)
59  and ISO SQL/MM Spatial.
60 
61  \ingroup geometry
62 
63  \sa AbstractPoint, Point, PointM, PointZ, PointZM, PointKd,
64  Curve, LineString, LinearRing, Line, CircularString, CompoundCurve,
65  Surface, CurvePolygon, Polygon, Triangle, PolyhedralSurface, TIN,
66  GeometryCollection, MultiCurve, MultiSurface,
67  MultiPoint, MultiLineString, MultiPolygon
68 
69  \note Methods marked as <b>extended</b> are not from OGC or ISO specifications, but they enhances the TerraLib API.
70 
71  \note Methods performed by another library are marked as <b>Performed by Library-Name</b>.
72  */
74  {
75  public:
76 
78 
79  /** @name Initializer methods on geometric objects
80  * Methods for initializing a geometric object.
81  */
82  //@{
83 
84  /*!
85  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
86 
87  \param t The internal geometry type.
88  \param srid The Spatial Reference System ID associated to the geometry.
89  \param mbr The envelope (minimum bounding rectangle of this geometry).
90 
91  \note The geometry will take the ownership of the given mbr.
92  */
93  Geometry(GeomType t, int srid = -1, Envelope* mbr = 0) throw();
94 
95  /*!
96  \brief Copy constructor.
97 
98  \param rhs The other geometry.
99  */
100  Geometry(const Geometry& rhs) throw();
101 
102  /*! \brief Virtual destructor. */
103  virtual ~Geometry();
104 
105  /*!
106  \brief Assignment operator.
107 
108  \param rhs The right-hand-side geometry.
109 
110  \return A reference for this.
111  */
112  virtual Geometry& operator=(const Geometry& rhs) throw();
113 
114  //@}
115 
116  /** @name Basic Geometry Methods
117  * Basic methods on geometric objects.
118  */
119  //@{
120 
121  /*!
122  \brief It returns the geometric object dimension (0, 1 or 2).
123 
124  For a GeometryCollection it returns the largest topological
125  dimension of the contained objects. For Point and MultiPoint this will return 0.
126  For Curves and MultiCurves (LineString, LinearRing and MultiLineString) it will
127  return 1. For Surfaces (Polygon, Triangle, PolyhedralSurface, TIN) and
128  MultiSurfaces (MultiPolygon) it will return 2.
129 
130  \return The geometric object dimension (0, 1 or 2).
131  */
132  virtual Dimensionality getDimension() const throw() = 0;
133 
134  /*!
135  \brief It returns the number of measurements or axes needed to describe a position in a coordinate system.
136 
137  It returns:
138  <ul>
139  <li>2 for a coordinate with x, y;</li>
140  <li>3 for a coordinate with x, y and z or x, y and m;</li>
141  <li>4 for a coordinate with x, y, z and m.</li>
142  </ul>
143 
144  \return The number of measurements or axes needed to describe a position in a coordinate system.
145 
146  \note This is NOT the same as getDimension() method!
147  */
148  int getCoordinateDimension() const throw();
149 
150  /*!
151  \brief It returns the name of the geometry subclass.
152 
153  The name of the geometry subclass may be one of the following:
154  <ul>
155  <li>Point</li>
156  <li>LineString</li>
157  <li>Polygon</li>
158  <li>GeometryCollection</li>
159  <li>MultiPoint</li>
160  <li>MultiLineString</li>
161  <li>MultiPolygon</li>
162  <li>Tin</li>
163  </ul>
164 
165  \return The name of the geometry subclass type ide.
166  */
167  virtual const std::string& getGeometryType() const throw() = 0;
168 
169  /*!
170  \brief It returns the geometry subclass type identifier.
171 
172  \return The geometry subclass type identifier
173 
174  \note Please, see GeomType enumeration for possible return values.
175 
176  \note TerraLib extended method.
177  */
178  GeomType getGeomTypeId() const throw() { return m_gType; }
179 
180  /*!
181  \brief It returns the Spatial Reference System ID associated to this geometric object.
182 
183  This value can be used to identify the associated Spatial Reference System.
184 
185  \return The Spatial Reference System ID associated to this geometric object.
186 
187  \note When not set this value will be -1.
188  */
189  int getSRID() const throw() { return m_srid; }
190 
191  /*!
192  \brief It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollection (or a Multi).
193 
194  \param srid The Spatial Reference System ID to be associated to the geometric object.
195 
196  \note This method just set the srid, it doesn't perform conversions over coordinate values.
197 
198  \note TerraLib extended method.
199  */
200  virtual void setSRID(int srid) throw() = 0;
201 
202  /*!
203  \brief It converts the coordinate values of the geometry to the new spatial reference system.
204 
205  After calling this method the geometry will be associated to the new SRID.
206 
207  \param srid The new Spatial Reference System ID used to transform the coordinates of the geometry.
208 
209  \exception Exception It will throw an exception if it can not do the transformation.
210 
211  \note The geometry must be associated to a valid SRID before calling this method.
212 
213  \note If the geometry already has an associated MBR, this method will automatically update it (i. e. automatically recompute it).
214  */
215  virtual void transform(int srid) throw(te::common::Exception) = 0;
216 
217  /*!
218  \brief It returns the minimum bounding rectangle (MBR) for the geometry.
219 
220  As one can notice, the mbr is returned as a geometry, actually a polygon
221  defined by the corner points of the bounding box [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
222 
223  \return The geometry envelope (or mbr).
224 
225  \note The caller of this method will take the ownership of the returned geometry.
226 
227  \note If the MBR was not computed previously, it will compute it. Successive
228  calls to this method will not compute the mbr anymore.
229  */
230  Geometry* getEnvelope() const throw();
231 
232  /*!
233  \brief It returns the minimum bounding rectangle for the geometry in an internal representation.
234 
235  The mbr can be constructed when reading a geometry from a database or
236  it can be computed internally. So, if the mbr is not already set
237  it will compute it just when this method is called. Successive
238  calls to this method will not compute the mbr anymore.
239 
240  \return The envelope of this geometry (i.e., the minimum bounding rectangle).
241 
242  \note It is supposed to be faster and more useful than getting the box as a polygon geometry.
243 
244  \note TerraLib extended method.
245  */
246  const Envelope* getMBR() const throw();
247 
248  /*!
249  \brief It computes the minimum bounding rectangle for the geometry.
250 
251  Subclasses must implement this method in order
252  to be able to compute the minimum bounding box of
253  a specific geometry.
254 
255  \param cascade If true it will update the MBR for its sub-geometries.
256 
257  \note You can use this method in order to update the MBR of the Geometry.
258 
259  \note TerraLib extended method.
260  */
261  virtual void computeMBR(bool cascade) const throw() = 0;
262 
263  /*!
264  \brief It returns an string with the Well-Known Text Representation for the geometry.
265 
266  \return The WKT for the Geometry.
267  */
268  std::string asText() const throw();
269 
270  /*!
271  \brief It serializes the geometric object to a Well-known Binary Representation (WKB).
272 
273  \param size The size in bytes of the returned WKB.
274 
275  \return The WKB representation for this object.
276 
277  \exception Exception It will throw an exception if the operation could not be performed.
278 
279  \note The WKB will be on machine byte order.
280 
281  \note The caller of this method will take the ownership of the returned wkb.
282  You must use "delete [] pointer" in order to free the memory pointed by returned pointer.
283  */
284  char* asBinary(std::size_t& size) const throw(Exception);
285 
286  /*!
287  \brief It returns the size required by a WKB representation for this geometric object.
288 
289  This is the preferred method for creating a WKB. First of all,
290  it gives you the possibility to use a pre-allocated buffer. So,
291  this method can be used in conjunction with the getWkb method.
292 
293  \return The size required by a WKB representation for the geometry object.
294 
295  \note TerraLib extended method.
296  */
297  std::size_t getWkbSize() const throw();
298 
299  /*!
300  \brief It serializes the geometry to a WKB representation into the specified buffer.
301 
302  The wkb parameter must have at least getWkbSize() in order to be used. Don't
303  pass a NULL pointer or a buffer smaller than the size needed. Note that
304  the WKB will be on the specified byte order.
305 
306  \param wkb The buffer where the Geometry will be serialized.
307  \param byteOrder The byte order used to store/serialize the geometry.
308 
309  \exception Exception It will throw an exception if the operation could not be performed.
310 
311  \note TerraLib extended method.
312  */
313  void getWkb(char* wkb, te::common::MachineByteOrder byteOrder) const throw(Exception);
314 
315  /*!
316  \brief It returns true if this geometric object is the empty Geometry.
317 
318  If true, then this geometric object represents the empty point set
319  for the coordinate space.
320 
321  \return True if this geometric object is the empty Geometry.
322 
323  \exception std::exception It will throw an exception if the operation could not be performed.
324 
325  \note Performed by GEOS.
326  */
327  virtual bool isEmpty() const throw(std::exception);
328 
329  /*!
330  \brief It returns true if this geometric object has no anomalous points, such as self intersection or self tangency.
331 
332  See the ISO and OGC documentation for an explanation about specific conditions
333  of each type of geometry to be considered not simple.
334 
335  \return True if this geometric object has no anomalous geometric points.
336 
337  \exception std::exception It will throw an exception if the operation could not be performed.
338 
339  \note Performed by GEOS.
340  */
341  virtual bool isSimple() const throw(std::exception);
342 
343  /*!
344  \brief It tells if the geometry is well formed.
345 
346  \exception std::exception It will throw an exception if the operation could not be performed.
347 
348  \note TerraLib extended method.
349 
350  \note Performed by GEOS.
351  */
352  virtual bool isValid() const throw(std::exception);
353 
354  /*!
355  \brief It returns true if this geometric object has z coordinate values.
356 
357  \return True if this geometric object has z coordinate values.
358  */
359  bool is3D() const throw();
360 
361  /*!
362  \brief It returns true if this geometric object has m coordinate values.
363 
364  \return True if this geometric object has m coordinate values.
365  */
366  bool isMeasured() const throw();
367 
368  /*!
369  \brief It returns the geometry boundary.
370 
371  \return The geometry that makes the boundary of this geometry. The caller of this method will
372  take the ownership of the returned geometry.
373 
374  \exception std::exception It will throw an exception if the operation could not be performed.
375 
376  \note The caller of this method will take the ownership of the returned Geometry.
377 
378  \note Performed by GEOS.
379  */
380  virtual Geometry* getBoundary() const throw(std::exception);
381 
382  /*!
383  \brief it returns the number of points (vertexes) in the geometry.
384 
385  \return The number of points (vertexes) in the geometry.
386 
387  \note TerraLib extended method.
388  */
389  virtual std::size_t getNPoints() const throw() = 0;
390 
391  //@}
392 
393  /** @name Spatial Relations
394  * Methods for testing spatial relations between geometric objects.
395  * Please, see OGC specification for a in depth definition of each spatial operation.
396  */
397  //@{
398 
399  /*!
400  \brief It returns true if the geometry object is spatially equal to rhs geometry.
401 
402  \param rhs The another geometry to be compared.
403  \param exact If true checks if this geometric object has the same vertexes in the same order of rhs geometry.
404 
405  \return True if the geometry is spatially equal to the other geometry.
406 
407  \exception std::exception It will throw an exception if the operation could not be performed.
408 
409  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise an exception will be thrown.
410 
411  \note Performed by GEOS.
412  */
413  virtual bool equals(const Geometry* const rhs, const bool exact = false) const throw(std::exception);
414 
415  /*!
416  \brief It returns true if the geometry object is spatially disjoint from rhs geometry.
417 
418  \param rhs The other geometry to be compared.
419 
420  \return True if the geometry is spatially disjoint from the other geometry.
421 
422  \exception std::exception It will throw an exception if the operation could not be performed.
423 
424  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
425 
426  \note Performed by GEOS.
427  */
428  virtual bool disjoint(const Geometry* const rhs) const throw(std::exception);
429 
430  /*!
431  \brief It returns true if the geometry object spatially intersects rhs geometry.
432 
433  \param rhs The other geometry to be compared.
434 
435  \return True if the geometry intersects the other geometry.
436 
437  \exception std::exception It will throw an exception if the operation could not be performed.
438 
439  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
440 
441  \note Performed by GEOS.
442  */
443  virtual bool intersects(const Geometry* const rhs) const throw(std::exception);
444 
445  /*!
446  \brief It returns true if the geometry object spatially touches rhs geometry.
447 
448  \param rhs The other geometry to be compared.
449 
450  \return True if the geometry spatially touches the other geometry.
451 
452  \exception std::exception It will throw an exception if the operation could not be performed.
453 
454  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
455 
456  \note Performed by GEOS.
457  */
458  virtual bool touches(const Geometry* const rhs) const throw(std::exception);
459 
460  /*!
461  \brief It returns true if the geometry object spatially crosses rhs geometry.
462 
463  \param rhs The other geometry to be compared.
464 
465  \return True if the geometry spatially crosses the other geometry.
466 
467  \exception std::exception It will throw an exception if the operation could not be performed.
468 
469  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
470 
471  \note Performed by GEOS.
472  */
473  virtual bool crosses(const Geometry* const rhs) const throw(std::exception);
474 
475  /*!
476  \brief It returns true if the geometry object is spatially within rhs geometry.
477 
478  \param rhs The other geometry to be compared.
479 
480  \return True if the geometry is spatially within the other geometry.
481 
482  \exception std::exception It will throw an exception if the operation could not be performed.
483 
484  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
485 
486  \note Performed by GEOS.
487  */
488  virtual bool within(const Geometry* const rhs) const throw(std::exception);
489 
490  /*!
491  \brief It returns true if this geometry object spatially contains rhs geometry.
492 
493  \param rhs The other geometry to be compared.
494 
495  \return True if the geometry spatially contains the other geometry.
496 
497  \exception std::exception It will throw an exception if the operation could not be performed.
498 
499  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
500 
501  \note Performed by GEOS.
502  */
503  virtual bool contains(const Geometry* const rhs) const throw(std::exception);
504 
505  /*!
506  \brief It returns true if this geometry object spatially overlaps rhs geometry.
507 
508  \param rhs The other geometry to be compared.
509 
510  \return True if the geometry spatially overlaps the other geometry.
511 
512  \exception std::exception It will throw an exception if the operation could not be performed.
513 
514  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
515 
516  \note Performed by GEOS.
517  */
518  virtual bool overlaps(const Geometry* const rhs) const throw(std::exception);
519 
520  /*!
521  \brief It returns true if this geometry object is spatially related to rhs geometry according to the pattern expressed by the intersection matrix.
522 
523  It does this by testing for intersections between the interior,
524  boundary and exterior of the two geometric objects as specified
525  by the values in the matrix.
526 
527  \param rhs The other geometry to be compared.
528  \param matrix The intersection matrix.
529 
530  \return True if the geometry is spatially related to the other geometry according to the pattern expressed by the intersection matrix.
531 
532  \exception std::exception It will throw an exception if the operation could not be performed.
533 
534  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
535 
536  \note Performed by GEOS.
537  */
538  virtual bool relate(const Geometry* const rhs, const std::string& matrix) const throw(std::exception);
539 
540  /*!
541  \brief It returns the spatial relation between this geometry object and the rhs geometry.
542 
543  \param rhs The another geometry to be compared.
544 
545  \return A string where each byte is a intersection in the pattern intersection matrix of the relationship of the two objects.
546 
547  \exception std::exception It will throw an exception if the operation could not be performed.
548 
549  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
550 
551  \note TerraLib extended method.
552 
553  \note This method will be handy when you don't know the spatial relation in advance.
554 
555  \note Performed by GEOS.
556  */
557  virtual std::string relate(const Geometry* const rhs) const throw(std::exception);
558 
559  /*!
560  \brief It returns true if this geometry object spatially covers the rhs geometry.
561 
562  \param rhs The other geometry to be compared.
563 
564  \return True if the geometry spatially covers the other geometry.
565 
566  \exception std::exception It will throw an exception if the operation could not be performed.
567 
568  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
569 
570  \note TerraLib extended method.
571 
572  \note This is not the same as contains. See Max Egenhofer paper on 9-intersection matrix.
573 
574  \note Performed by GEOS.
575  */
576  virtual bool covers(const Geometry* const rhs) const throw(std::exception);
577 
578  /*!
579  \brief It returns true if this geometry object is spatially covered by rhs geometry.
580 
581  \param rhs The other geometry to be compared.
582 
583  \return True if the geometry is spatially covered by the other geometry.
584 
585  \exception std::exception It will throw an exception if the operation could not be performed.
586 
587  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
588 
589  \note TerraLib extended method.
590 
591  \note This is not the same as within. See Max Egenhofer paper on 9-intersection matrix.
592 
593  \note Performed by GEOS.
594  */
595  virtual bool coveredBy(const Geometry* const rhs) const throw(std::exception);
596 
597  /*!
598  \brief It returns a derived GeometryCollection value according to the specified coordinate value.
599 
600  \param mValue The coordinate value.
601 
602  \return A GeometryCollection value.
603 
604  \exception Exception It will throw an exception if the operation could not be performed.
605 
606  \note The caller of this method will take the ownership of the returned geometry.
607 
608  \note This method only applies to Point and Line geometries, including homogeneu collections of points or lines.
609  For polygons this will return a NULL value.
610  */
611  virtual Geometry* locateAlong(const double& mValue) const throw(Exception) { return locateBetween(mValue, mValue); };
612 
613  /*!
614  \brief It returns a derived geometry collection value according to the range of coordinate values inclusively.
615 
616  \param mStart The initial coordinate value.
617  \param mEnd The final coordinate value.
618 
619  \return A GeometryCollection value.
620 
621  \exception Exception It will throw an exception if the operation could not be performed.
622 
623  \note This method only applies to Point and Line geometries, including homogeneous collections of points or lines.
624  For polygons this will return a NULL value.
625 
626  \note The caller of this method will take the ownership of the returned Geometry.
627  */
628  virtual Geometry* locateBetween(const double& mStart, const double& mEnd) const throw(Exception);
629 
630  //@}
631 
632  /** @name Spatial Analysis
633  * Methods that support spatial analysis.
634  */
635  //@{
636 
637  /*!
638  \brief It returns the shortest distance between any two points in the two geometry objects.
639 
640  \param rhs The other geometry.
641 
642  \return The shortest distance between any two points in the two geometries.
643 
644  \exception std::exception It will throw an exception if the operation could not be performed.
645 
646  \note Performed by GEOS.
647  */
648  virtual double distance(const Geometry* const rhs) const throw(std::exception);
649 
650  /*!
651  \brief This method calculates the buffer of a geometry.
652 
653  \param distance Distance value.
654 
655  \return A geometry representing all points less than or equal to the specified distance.
656 
657  \exception std::exception It will throw an exception if the operation could not be performed.
658 
659  \note The caller of this method will take the ownership of the returned geometry.
660 
661  \note Performed by GEOS.
662  */
663  virtual Geometry* buffer(const double& distance) const throw(std::exception);
664 
665  /*!
666  \brief This method calculates the buffer of a geometry.
667 
668  \param distance Distance value.
669  \param quadrantSegments A specified number of segments used to approximate the curves.
670 
671  \return A geometry representing all points less than or equal to the specified distance.
672 
673  \exception std::exception It will throw an exception if the operation could not be performed.
674 
675  \note The caller of this method will take the ownership of the returned geometry.
676 
677  \note TerraLib extended method.
678 
679  \note Performed by GEOS.
680  */
681  virtual Geometry* buffer(const double& distance, int quadrantSegments) const throw(std::exception);
682 
683  /*!
684  \brief This method calculates the buffer of a geometry.
685 
686  As in GEOS, the quadrantSegments argument allows controlling the
687  accuracy of the approximation by specifying the number of line
688  segments used to represent a quadrant of a circle.
689 
690  \param distance Distance value.
691  \param quadrantSegments A specified number of segments used to approximate the curves.
692  \param endCapStyle It specifies the shape used at the ends of linestrings.
693 
694  \return A geometry representing all points less than or equal to the specified distance.
695 
696  \exception std::exception It will throw an exception if the operation could not be performed.
697 
698  \note The caller of this method will take the ownership of the returned Geometry.
699 
700  \note TerraLib extended method.
701 
702  \note Performed by GEOS.
703  */
704  virtual Geometry* buffer(const double& distance,
705  int quadrantSegments,
706  BufferCapStyle endCapStyle) const throw(std::exception);
707 
708  /*!
709  \brief This method calculates the Convex Hull of a geometry.
710 
711  \return A geometry representing the convex hull.
712 
713  \exception std::exception It will throw an exception if the operation could not be performed.
714 
715  \note The caller of this method will take the ownership of the returned geometry.
716 
717  \note Performed by GEOS.
718  */
719  virtual Geometry* convexHull() const throw(std::exception);
720 
721  /*!
722  \brief It returns a geometric object that represents the point set intersection with another geometry
723 
724  \param rhs The other Geometry whose intersection with this Geometry will be calculated.
725 
726  \return A Geometry representing the intersection with this Geometry.
727 
728  \exception std::exception It will throw an exception if the operation could not be performed.
729 
730  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
731 
732  \note The caller of this method will take the ownership of the returned Geometry.
733 
734  \note Performed by GEOS.
735  */
736  virtual Geometry* intersection(const Geometry* const rhs) const throw(std::exception);
737 
738  /*!
739  \brief It returns a geometric object that represents the point set union with another geometry
740 
741  \param rhs Another geometry whose union with this geometry will be calculated.
742 
743  \return A geometry representing the union with this geometry.
744 
745  \exception std::exception It will throw an exception if the operation could not be performed.
746 
747  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
748 
749  \note The caller of this method will take the ownership of the returned Geometry.
750 
751  \note Performed by GEOS.
752  */
753  virtual Geometry* Union(const Geometry* const rhs) const throw(std::exception);
754 
755  /*!
756  \brief It returns a geometric object that represents the point set difference with another geometry
757 
758  \param rhs Another geometry whose difference with this geometry will be calculated.
759 
760  \return A geometry representing the difference between the geometries.
761 
762  \exception std::exception It will throw an exception if the operation could not be performed.
763 
764  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
765 
766  \note The caller of this method will take the ownership of the returned Geometry.
767 
768  \note Performed by GEOS.
769  */
770  virtual Geometry* difference(const Geometry* const rhs) const throw(std::exception);
771 
772  /*!
773  \brief It returns a geometric object that represents the point set symetric difference with another geometry
774 
775  \param rhs The other geometry whose symetric difference with this geometry will be calculated.
776 
777  \return A geometry representing the symetric difference with this geometry.
778 
779  \exception std::exception It will throw an exception if the operation could not be performed.
780 
781  \warning Don't call this method for a Heterogeneous GeometryCollection, otherwise, an exception will be thrown.
782 
783  \note The caller of this method will take the ownership of the returned Geometry.
784 
785  \note Performed by GEOS.
786  */
787  virtual Geometry* symDifference(const Geometry* const rhs) const throw(std::exception);
788 
789  /*!
790  \brief It returns true if the geometries are within the specified distance.
791 
792  \param rhs The other geometry whose symetric difference with this geometry will be calculated.
793  \param distance The distance.
794 
795  \return True if the geometries are within the specified distance.
796 
797  \exception std::exception It will throw an exception if the operation could not be performed.
798 
799  \note TerraLib extended method.
800 
801  \note Performed by GEOS.
802  */
803  virtual bool dWithin(const Geometry* const rhs, const double& distance) const throw(std::exception);
804 
805  //@}
806 
807  /** @name Auxiliary Methods
808  * Auxiliary Methods.
809  */
810  //@{
811 
812  /*!
813  \brief It returns the TerraLib geometry type id given a type string (the type string must be in capital letters).
814 
815  \param stype The geometry type name.
816 
817  \return The geometry type id equivalent to the string name.
818 
819  \note If the type is unknow it returns UnknownGeometryType.
820  */
821  static GeomType getGeomTypeId(const std::string& gtype);
822 
823  /*!
824  \brief It tells if the given string is a geometry data type.
825 
826  \param stype The geometry type to be checked.
827 
828  \return True if the given string corresponds to a geometry type.
829  */
830  static bool isGeomType(const std::string& stype);
831 
832  /*!
833  \brief It loads the internal MAP of geometry type names to geometry type ids.
834 
835  \warning Ths method will be automatically called when geometry module is initialized!
836  */
837  static void loadGeomTypeId();
838 
839  //@}
840 
841  /** @name AbstractData Re-implementation
842  * Methods re-implemneted from AbstractData.
843  */
844  //@{
845 
846  /*!
847  \brief It returns the data type code associated to the data value.
848 
849  \return The data type code associated to the data value.
850  */
851  int getTypeCode() const;
852 
853  /*!
854  \brief It returns the data value in a WKT representation.
855 
856  \return The data value in a WKT representation.
857  */
858  std::string toString() const { return asText(); }
859 
860  //@}
861 
862  protected:
863 
864  GeomType m_gType; //!< Internal geometry type.
865  int m_srid; //!< The Spatial Reference System code associated to the Geometry.
866  mutable Envelope* m_mbr; //!< The geometry minimum bounding rectangle.
867 
868  static std::map<std::string, GeomType> sm_geomTypeMap; //!< A set of geometry type names (in UPPER CASE).
869  };
870 
871  //Typedef
872  typedef boost::shared_ptr<Geometry> GeometryShrPtr;
873  } // end namespace gm
874 } // end namespace te
875 
876 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMETRY_H
877 
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:189
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
BufferCapStyle
Buffer end cap style.
Definition: Enums.h:162
The root of all hierarchies that can be visited.
Definition: BaseVisitable.h:53
Base exception class for plugin module.
Definition: Exception.h:42
int m_srid
The Spatial Reference System code associated to the Geometry.
Definition: Geometry.h:865
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
Dimensionality
From Wikipedia: "in mathematics, the dimension of an object is an intrinsic property, independent of the space in which the object may happen to be embedded".
Definition: Enums.h:147
URI C++ Library.
General enumerations.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
MachineByteOrder
Endianness.
Definition: Enums.h:116
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Definition: Geometry.h:178
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
Envelope * m_mbr
The geometry minimum bounding rectangle.
Definition: Geometry.h:866
An exception class for the Geometry module.
GeomType m_gType
Internal geometry type.
Definition: Geometry.h:864
TEGEOMEXPORT Coord2D * locateAlong(const LineString *line, double initial, double final, double target)
Make the line interpolation to find a target.
boost::shared_ptr< Geometry > GeometryShrPtr
Definition: Geometry.h:872
static std::map< std::string, GeomType > sm_geomTypeMap
A set of geometry type names (in UPPER CASE).
Definition: Geometry.h:868
A visitor interface for the Geometry hierarchy.