All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geometry.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 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.cpp
22 
23  \brief Geometry is the root class of the geometries hierarchy, it follows OGC Simple Feature Specification - SFS (Simple Feature Access - Part 1: Common Architecture) and ISO SQL/MM Spatial.
24 */
25 
26 // TerraLib
27 #include "../common/Globals.h"
28 #include "../common/Translator.h"
29 #include "../datatype/Enums.h"
30 #include "Envelope.h"
31 #include "Exception.h"
32 #include "Geometry.h"
33 #include "GEOSReader.h"
34 #include "GEOSWriter.h"
35 #include "Utils.h"
36 #include "WKTReader.h"
37 #include "WKTWriter.h"
38 #include "WKBSize.h"
39 #include "WKBWriter.h"
40 
41 // STL
42 #include <cassert>
43 #include <cstring>
44 #include <memory>
45 #include <sstream>
46 
47 #if TE_USE_GEOS
48 // GEOS
49 #include <geos/geom/Geometry.h>
50 #include <geos/geom/IntersectionMatrix.h>
51 #include <geos/operation/buffer/OffsetCurveBuilder.h>
52 #include <geos/operation/union/CascadedPolygonUnion.h>
53 #include <geos/util/GEOSException.h>
54 #endif
55 
56 std::map<std::string, te::gm::GeomType> te::gm::Geometry::sm_geomTypeMap;
57 
58 te::gm::Geometry::Geometry(GeomType t, int srid, Envelope* mbr) throw()
59  : m_gType(t),
60  m_srid(srid),
61  m_mbr(mbr)
62 {
63 }
64 
66  : m_gType(rhs.m_gType),
67  m_srid(rhs.m_srid),
68  m_mbr(0)
69 {
70 }
71 
73 {
74  delete m_mbr;
75 }
76 
78 {
79  if(this != &rhs)
80  {
81  m_gType = rhs.m_gType;
82 
83  m_srid = rhs.m_srid;
84 
85  delete m_mbr;
86 
87  m_mbr = rhs.m_mbr ? new Envelope(*rhs.m_mbr) : 0;
88  }
89 
90  return *this;
91 }
92 
94 {
95  return GetCoordDimension(m_gType);
96 }
97 
99 {
100  return GetGeomFromEnvelope(getMBR(), m_srid);
101 }
102 
104 {
105  if(m_mbr == 0)
106  computeMBR(true);
107 
108  return m_mbr;
109 }
110 
111 std::string te::gm::Geometry::asText() const throw()
112 {
113  std::stringstream stream(std::ios_base::in | std::ios_base::out);
114 
115  stream.precision(18);
116 
117  WKTWriter::write(this, stream);
118 
119  return stream.str();
120 }
121 
122 char* te::gm::Geometry::asBinary(std::size_t& size) const throw(Exception)
123 {
124  size = WKBSize::size(this);
125 
126  char* wkb = new char[size];
127 
129 
130  return wkb;
131 }
132 
133 std::size_t te::gm::Geometry::getWkbSize() const throw()
134 {
135  return WKBSize::size(this);
136 }
137 
138 void te::gm::Geometry::getWkb(char* wkb, te::common::MachineByteOrder byteOrder) const throw(Exception)
139 {
140  WKBWriter::write(this, wkb, byteOrder);
141 }
142 
143 bool te::gm::Geometry::isEmpty() const throw(std::exception)
144 {
145 #if TE_USE_GEOS
146  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
147 
148  return g->isEmpty();
149 
150 #else
151  throw Exception(TR_GEOM("isEmpty routine is supported by GEOS! Please, enable the GEOS support."));
152 #endif
153 }
154 
155 bool te::gm::Geometry::isSimple() const throw(std::exception)
156 {
157 #if TE_USE_GEOS
158  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
159 
160  return g->isSimple();
161 
162 #else
163  throw Exception(TR_GEOM("isSimple routine is supported by GEOS! Please, enable the GEOS support."));
164 #endif
165 }
166 
167 bool te::gm::Geometry::isValid() const throw(std::exception)
168 {
169 #if TE_USE_GEOS
170  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
171 
172  return g->isValid();
173 
174 #else
175  throw Exception(TR_GEOM("isValid routine is supported by GEOS! Please, enable the GEOS support."));
176 #endif
177 }
178 
179 bool te::gm::Geometry::is3D() const throw()
180 {
181  if((m_gType & 0xF00) == 0xB00) // it is zm
182  return true;
183 
184  if((m_gType & 0x0F00) == 0x300) // it is z
185  return true;
186 
187  return false; // it is 2D or M
188 }
189 
190 bool te::gm::Geometry::isMeasured() const throw()
191 {
192  if((m_gType & 0xF00) == 0xB00) // it is zm
193  return true;
194 
195  if((m_gType & 0xF00) == 0x700) // it is m
196  return true;
197 
198  return false; // it is 2D or z
199 }
200 
201 te::gm::Geometry* te::gm::Geometry::getBoundary() const throw(std::exception)
202 {
203 #if TE_USE_GEOS
204  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
205  std::auto_ptr<geos::geom::Geometry> b(g->getBoundary());
206  return GEOSReader::read(b.get());
207 
208 #else
209  throw te::common::Exception(TR_GEOM("getBoundary routine is supported by GEOS! Please, enable the GEOS support."));
210 #endif
211 }
212 
213 bool te::gm::Geometry::equals(const Geometry* const rhs, const bool exact) const throw(std::exception)
214 {
215 #if TE_USE_GEOS
216  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
217 
218  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
219 
220  if(exact == true)
221  return thisGeom->equalsExact(rhsGeom.get());
222  else
223  return thisGeom->equals(rhsGeom.get());
224 #else
225  throw te::common::Exception(TR_GEOM("equals routine is supported by GEOS! Please, enable the GEOS support."));
226 #endif
227 }
228 
229 bool te::gm::Geometry::disjoint(const Geometry* const rhs) const throw(std::exception)
230 {
231 #if TE_USE_GEOS
232  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
233 
234  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
235 
236  return thisGeom->disjoint(rhsGeom.get());
237 
238 #else
239  throw te::common::Exception(TR_GEOM("disjoint routine is supported by GEOS! Please, enable the GEOS support."));
240 #endif
241 }
242 
243 bool te::gm::Geometry::intersects(const Geometry* const rhs) const throw(std::exception)
244 {
245 #if TE_USE_GEOS
246  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
247 
248  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
249 
250  return thisGeom->intersects(rhsGeom.get());
251 
252 #else
253  throw te::common::Exception(TR_GEOM("intersects routine is supported by GEOS! Please, enable the GEOS support."));
254 #endif
255 }
256 
257 bool te::gm::Geometry::touches(const Geometry* const rhs) const throw(std::exception)
258 {
259 #if TE_USE_GEOS
260  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
261 
262  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
263 
264  return thisGeom->touches(rhsGeom.get());
265 
266 #else
267  throw te::common::Exception(TR_GEOM("touches routine is supported by GEOS! Please, enable the GEOS support."));
268 #endif
269 }
270 
271 bool te::gm::Geometry::crosses(const Geometry* const rhs) const throw(std::exception)
272 {
273 #if TE_USE_GEOS
274  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
275 
276  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
277 
278  return thisGeom->crosses(rhsGeom.get());
279 
280 #else
281  throw te::common::Exception(TR_GEOM("crosses routine is supported by GEOS! Please, enable the GEOS support."));
282 #endif
283 }
284 
285 bool te::gm::Geometry::within(const Geometry* const rhs) const throw(std::exception)
286 {
287 #if TE_USE_GEOS
288  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
289 
290  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
291 
292  return thisGeom->within(rhsGeom.get());
293 
294 #else
295  throw te::common::Exception(TR_GEOM("within routine is supported by GEOS! Please, enable the GEOS support."));
296 #endif
297 }
298 
299 bool te::gm::Geometry::contains(const Geometry* const rhs) const throw(std::exception)
300 {
301 #if TE_USE_GEOS
302  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
303 
304  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
305 
306  return thisGeom->contains(rhsGeom.get());
307 
308 #else
309  throw te::common::Exception(TR_GEOM("contains routine is supported by GEOS! Please, enable the GEOS support."));
310 #endif
311 }
312 
313 bool te::gm::Geometry::overlaps(const Geometry* const rhs) const throw(std::exception)
314 {
315 #if TE_USE_GEOS
316  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
317 
318  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
319 
320  return thisGeom->overlaps(rhsGeom.get());
321 
322 #else
323  throw te::common::Exception(TR_GEOM("overlaps routine is supported by GEOS! Please, enable the GEOS support."));
324 #endif
325 }
326 
327 bool te::gm::Geometry::relate(const Geometry* const rhs, const std::string& matrix) const throw(std::exception)
328 {
329  assert(matrix.size() == 9);
330 
331 #if TE_USE_GEOS
332  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
333 
334  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
335 
336  return thisGeom->relate(rhsGeom.get(), matrix);
337 
338 #else
339  throw te::common::Exception(TR_GEOM("relate routine is supported by GEOS! Please, enable the GEOS support."));
340 #endif
341 }
342 
343 std::string te::gm::Geometry::relate(const Geometry* const rhs) const throw(std::exception)
344 {
345 #if TE_USE_GEOS
346  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
347 
348  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
349 
350  std::auto_ptr<geos::geom::IntersectionMatrix> m(thisGeom->relate(rhsGeom.get()));
351 
352  return m->toString();
353 
354 #else
355  throw te::common::Exception(TR_GEOM("relate routine is supported by GEOS! Please, enable the GEOS support."));
356 #endif
357 }
358 
359 bool te::gm::Geometry::covers(const Geometry* const rhs) const throw(std::exception)
360 {
361 #if TE_USE_GEOS
362  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
363 
364  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
365 
366  return thisGeom->covers(rhsGeom.get());
367 
368 #else
369  throw te::common::Exception(TR_GEOM("covers routine is supported by GEOS! Please, enable the GEOS support."));
370 #endif
371 }
372 
373 bool te::gm::Geometry::coveredBy(const Geometry* const rhs) const throw(std::exception)
374 {
375 #if TE_USE_GEOS
376  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
377 
378  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
379 
380  return thisGeom->coveredBy(rhsGeom.get());
381 
382 #else
383  throw te::common::Exception(TR_GEOM("coveredBy routine is supported by GEOS! Please, enable the GEOS support."));
384 #endif
385 }
386 
387 te::gm::Geometry* te::gm::Geometry::locateBetween(const double& /*mStart*/, const double& /*mEnd*/) const throw(Exception)
388 {
389  return 0;
390 }
391 
392 double te::gm::Geometry::distance(const Geometry* const rhs) const throw(std::exception)
393 {
394 #if TE_USE_GEOS
395  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
396 
397  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
398 
399  return thisGeom->distance(rhsGeom.get());
400 
401 #else
402  throw te::common::Exception(TR_GEOM("distance routine is supported by GEOS! Please, enable the GEOS support."));
403 #endif
404 }
405 
406 te::gm::Geometry* te::gm::Geometry::buffer(const double& distance) const throw(std::exception)
407 {
408 #if TE_USE_GEOS
409  return buffer(distance, TE_GEOS_DEFAULT_QUADRANT_SEGMENTS, CapRoundType);
410 #else
411  return buffer(distance, 16, CapRoundType);
412 #endif
413 }
414 
415 te::gm::Geometry* te::gm::Geometry::buffer(const double& distance, int quadrantSegments) const throw(std::exception)
416 {
417  return buffer(distance, quadrantSegments, CapRoundType);
418 }
419 
421  int quadrantSegments,
422  BufferCapStyle endCapStyle) const throw(std::exception)
423 {
424 #if TE_USE_GEOS
425  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
426 
427  std::auto_ptr<geos::geom::Geometry> bg(g->buffer(distance, quadrantSegments, static_cast<int>(endCapStyle)));
428 
429  bg->setSRID(m_srid);
430 
431  return GEOSReader::read(bg.get());
432 
433 
434 #else
435  throw te::common::Exception(TR_GEOM("buffer routine is supported by GEOS! Please, enable the GEOS support."));
436 #endif
437 }
438 
439 te::gm::Geometry* te::gm::Geometry::convexHull() const throw(std::exception)
440 {
441 #if TE_USE_GEOS
442  std::auto_ptr<geos::geom::Geometry> g(GEOSWriter::write(this));
443 
444  std::auto_ptr<geos::geom::Geometry> hull(g->convexHull());
445 
446  hull->setSRID(m_srid);
447 
448  return GEOSReader::read(hull.get());
449 
450 #else
451  throw te::common::Exception(TR_GEOM("convexHull routine is supported by GEOS! Please, enable the GEOS support."));
452 #endif
453 }
454 
455 te::gm::Geometry* te::gm::Geometry::intersection(const Geometry* const rhs) const throw(std::exception)
456 {
457 #if TE_USE_GEOS
458  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
459 
460  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
461 
462  std::auto_ptr<geos::geom::Geometry> intersectionGeom(thisGeom->intersection(rhsGeom.get()));
463 
464  intersectionGeom->setSRID(m_srid);
465 
466  return GEOSReader::read(intersectionGeom.get());
467 
468 #else
469  throw te::common::Exception(TR_GEOM("intersection routine is supported by GEOS! Please, enable the GEOS support."));
470 #endif
471 }
472 
473 te::gm::Geometry* te::gm::Geometry::Union(const Geometry* const rhs) const throw(std::exception)
474 {
475 #if TE_USE_GEOS
476 
477  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
478 
479  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
480 
481  std::auto_ptr<geos::geom::Geometry> unionGeom(thisGeom-> Union(rhsGeom.get()));
482 
483  unionGeom->setSRID(m_srid);
484 
485  return GEOSReader::read(unionGeom.get());
486 
487 #else
488  throw te::common::Exception(TR_GEOM("Union routine is supported by GEOS! Please, enable the GEOS support."));
489 #endif
490 }
491 
492 te::gm::Geometry* te::gm::Geometry::difference(const Geometry* const rhs) const throw(std::exception)
493 {
494 #if TE_USE_GEOS
495  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
496 
497  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
498 
499  std::auto_ptr<geos::geom::Geometry> differenceGeom(thisGeom->difference(rhsGeom.get()));
500 
501  differenceGeom->setSRID(m_srid);
502 
503  return GEOSReader::read(differenceGeom.get());
504 
505 #else
506  throw te::common::Exception(TR_GEOM("difference routine is supported by GEOS! Please, enable the GEOS support."));
507 #endif
508 }
509 
510 te::gm::Geometry* te::gm::Geometry::symDifference(const Geometry* const rhs) const throw(std::exception)
511 {
512 #if TE_USE_GEOS
513  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
514 
515  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
516 
517  std::auto_ptr<geos::geom::Geometry> symDifferenceGeom(thisGeom->symDifference(rhsGeom.get()));
518 
519  symDifferenceGeom->setSRID(m_srid);
520 
521  return GEOSReader::read(symDifferenceGeom.get());
522 #else
523  throw te::common::Exception(TR_GEOM("symDifference routine is supported by GEOS! Please, enable the GEOS support."));
524 #endif
525 }
526 
527 bool te::gm::Geometry::dWithin(const Geometry* const rhs, const double& distance) const throw(std::exception)
528 {
529  assert(distance >= 0.0);
530 
531 #if TE_USE_GEOS
532  std::auto_ptr<geos::geom::Geometry> thisGeom(GEOSWriter::write(this));
533 
534  std::auto_ptr<geos::geom::Geometry> rhsGeom(GEOSWriter::write(rhs));
535 
536  return thisGeom->isWithinDistance(rhsGeom.get(), distance);
537 
538 #else
539  throw te::common::Exception(TR_GEOM("dWithin routine is supported by GEOS! Please, enable the GEOS support."));
540 #endif
541 }
542 
544 {
545  std::map<std::string, GeomType>::const_iterator it = sm_geomTypeMap.find(gtype);
546 
547  if(it != sm_geomTypeMap.end())
548  return it->second;
549 
551 }
552 
553 bool te::gm::Geometry::isGeomType(const std::string& stype)
554 {
555  return getGeomTypeId(stype) != te::gm::UnknownGeometryType;
556 }
557 
559 {
560  if(!sm_geomTypeMap.empty())
561  return;
562 
563  sm_geomTypeMap["GEOMETRY"] = te::gm::GeometryType;
564  sm_geomTypeMap["GEOMETRYZ"] = te::gm::GeometryZType;
565  sm_geomTypeMap["GEOMETRYM"] = te::gm::GeometryMType;
566  sm_geomTypeMap["GEOMETRYZM"] = te::gm::GeometryZMType;
567 
568  sm_geomTypeMap["POINT"] = te::gm::PointType;
569  sm_geomTypeMap["POINTM"] = te::gm::PointMType;
570  sm_geomTypeMap["POINTZ"] = te::gm::PointZType;
571  sm_geomTypeMap["POINTZM"] = te::gm::PointZMType;
572 
573  sm_geomTypeMap["LINESTRING"] = te::gm::LineStringType;
574  sm_geomTypeMap["LINESTRINGM"] = te::gm::LineStringMType;
575  sm_geomTypeMap["LINESTRINGZ"] = te::gm::LineStringZType;
576  sm_geomTypeMap["LINESTRINGZM"] = te::gm::LineStringZMType;
577 
578  sm_geomTypeMap["POLYGON"] = te::gm::PolygonType;
579  sm_geomTypeMap["POLYGONM"] = te::gm::PolygonMType;
580  sm_geomTypeMap["POLYGONZ"] = te::gm::PolygonZType;
581  sm_geomTypeMap["POLYGONZM"] = te::gm::PolygonZMType;
582 
583  sm_geomTypeMap["MULTIPOINT"] = te::gm::MultiPointType;
584  sm_geomTypeMap["MULTIPOINTM"] = te::gm::MultiPointMType;
585  sm_geomTypeMap["MULTIPOINTZ"] = te::gm::MultiPointZType;
586  sm_geomTypeMap["MULTIPOINTZM"] = te::gm::MultiPointZMType;
587 
588  sm_geomTypeMap["MULTILINESTRING"] = te::gm::MultiLineStringType;
589  sm_geomTypeMap["MULTILINESTRINGM"] = te::gm::MultiLineStringMType;
590  sm_geomTypeMap["MULTILINESTRINGZ"] = te::gm::MultiLineStringZType;
591  sm_geomTypeMap["MULTILINESTRINGZM"] = te::gm::MultiLineStringZMType;
592 
593  sm_geomTypeMap["MULTIPOLYGON"] = te::gm::MultiPolygonType;
594  sm_geomTypeMap["MULTIPOLYGONM"] = te::gm::MultiPolygonMType;
595  sm_geomTypeMap["MULTIPOLYGONZ"] = te::gm::MultiPolygonZType;
596  sm_geomTypeMap["MULTIPOLYGONZM"] = te::gm::MultiPolygonZMType;
597 
598  sm_geomTypeMap["GEOMETRYCOLLECTION"] = te::gm::GeometryCollectionType;
599  sm_geomTypeMap["GEOMETRYCOLLECTIONM"] = te::gm::GeometryCollectionMType;
600  sm_geomTypeMap["GEOMETRYCOLLECTIONZ"] = te::gm::GeometryCollectionZType;
601  sm_geomTypeMap["GEOMETRYCOLLECTIONZM"] = te::gm::GeometryCollectionZMType;
602 }
603 
605 {
606  return te::dt::GEOMETRY_TYPE;
607 }
608 
int GetCoordDimension(GeomType t)
It returns the number of measurements or axes needed to describe a position in a coordinate system...
Definition: Utils.h:55
virtual bool dWithin(const Geometry *const rhs, const double &distance) const
It returns true if the geometries are within the specified distance.
Definition: Geometry.cpp:527
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
Definition: Utils.cpp:35
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
virtual Geometry * getBoundary() const
It returns the geometry boundary.
Definition: Geometry.cpp:201
std::size_t getWkbSize() const
It returns the size required by a WKB representation for this geometric object.
Definition: Geometry.cpp:133
void write(const Geometry *geom)
It serializes the geometry to a WKT representation.
Definition: WKTWriter.cpp:56
void getWkb(char *wkb, te::common::MachineByteOrder byteOrder) const
It serializes the geometry to a WKB representation into the specified buffer.
Definition: Geometry.cpp:138
GeomType m_gType
Internal geometry type.
Definition: Geometry.h:864
static std::size_t size(const Geometry *geom)
It calculates the number of bytes required to encode the geometry in a WKB format.
Definition: WKBSize.cpp:51
virtual Geometry * convexHull() const
This method calculates the Convex Hull of a geometry.
Definition: Geometry.cpp:439
virtual bool isSimple() const
It returns true if this geometric object has no anomalous points, such as self intersection or self t...
Definition: Geometry.cpp:155
virtual bool intersects(const Geometry *const rhs) const
It returns true if the geometry object spatially intersects rhs geometry.
Definition: Geometry.cpp:243
A class that serializes a geometry to the WKB format.
int getTypeCode() const
It returns the data type code associated to the data value.
Definition: Geometry.cpp:604
An exception class for the Geometry module.
virtual double distance(const Geometry *const rhs) const
It returns the shortest distance between any two points in the two geometry objects.
Definition: Geometry.cpp:392
#define TR_GEOM(message)
It marks a string in order to get translated. This is a special mark used in the Vector Geometry modu...
Definition: Config.h:58
A class that converts a TerraLib geometry to a GEOS geometry.
virtual bool within(const Geometry *const rhs) const
It returns true if the geometry object is spatially within rhs geometry.
Definition: Geometry.cpp:285
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
static bool isGeomType(const std::string &stype)
It tells if the given string is a geometry data type.
Definition: Geometry.cpp:553
Geometry(GeomType t, int srid=-1, Envelope *mbr=0)
It initializes the Geometry with the specified spatial reference system id and envelope.
Definition: Geometry.cpp:58
virtual Geometry * buffer(const double &distance) const
This method calculates the buffer of a geometry.
Definition: Geometry.cpp:406
Utility functions for the Geometry Module.
virtual bool isValid() const
It tells if the geometry is well formed.
Definition: Geometry.cpp:167
virtual bool isEmpty() const
It returns true if this geometric object is the empty Geometry.
Definition: Geometry.cpp:143
int getCoordinateDimension() const
It returns the number of measurements or axes needed to describe a position in a coordinate system...
Definition: Geometry.cpp:93
void write(const Geometry *geom)
It serializes the geometry to a WKB representation into the specified buffer.
Definition: WKBWriter.cpp:149
static const MachineByteOrder sm_machineByteOrder
A flag that indicates the machine byte order (Big Endian or Little Endian).
Definition: Globals.h:55
virtual bool contains(const Geometry *const rhs) const
It returns true if this geometry object spatially contains rhs geometry.
Definition: Geometry.cpp:299
MachineByteOrder
Endianness.
Definition: Enums.h:116
virtual Geometry * locateBetween(const double &mStart, const double &mEnd) const
It returns a derived geometry collection value according to the range of coordinate values inclusivel...
Definition: Geometry.cpp:387
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
virtual Geometry * symDifference(const Geometry *const rhs) const
It returns a geometric object that represents the point set symetric difference with another geometry...
Definition: Geometry.cpp:510
virtual Geometry * intersection(const Geometry *const rhs) const
It returns a geometric object that represents the point set intersection with another geometry...
Definition: Geometry.cpp:455
bool is3D() const
It returns true if this geometric object has z coordinate values.
Definition: Geometry.cpp:179
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
static std::map< std::string, GeomType > sm_geomTypeMap
A set of geometry type names (in UPPER CASE).
Definition: Geometry.h:868
virtual Geometry * Union(const Geometry *const rhs) const
It returns a geometric object that represents the point set union with another geometry.
Definition: Geometry.cpp:473
virtual bool crosses(const Geometry *const rhs) const
It returns true if the geometry object spatially crosses rhs geometry.
Definition: Geometry.cpp:271
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Definition: Geometry.h:178
bool isMeasured() const
It returns true if this geometric object has m coordinate values.
Definition: Geometry.cpp:190
virtual bool overlaps(const Geometry *const rhs) const
It returns true if this geometry object spatially overlaps rhs geometry.
Definition: Geometry.cpp:313
char * asBinary(std::size_t &size) const
It serializes the geometric object to a Well-known Binary Representation (WKB).
Definition: Geometry.cpp:122
virtual bool equals(const Geometry *const rhs, const bool exact=false) const
It returns true if the geometry object is spatially equal to rhs geometry.
Definition: Geometry.cpp:213
virtual bool touches(const Geometry *const rhs) const
It returns true if the geometry object spatially touches rhs geometry.
Definition: Geometry.cpp:257
virtual Geometry & operator=(const Geometry &rhs)
Assignment operator.
Definition: Geometry.cpp:77
BufferCapStyle
Buffer end cap style.
Definition: Enums.h:157
A class that serializes a geometry to the WKT format.
virtual bool covers(const Geometry *const rhs) const
It returns true if this geometry object spatially covers the rhs geometry.
Definition: Geometry.cpp:359
A class that computes the number of bytes necessary to encode a geometry in WKB.
virtual Geometry * difference(const Geometry *const rhs) const
It returns a geometric object that represents the point set difference with another geometry...
Definition: Geometry.cpp:492
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
Definition: Geometry.cpp:103
An Envelope defines a 2D rectangular region.
Envelope * m_mbr
The geometry minimum bounding rectangle.
Definition: Geometry.h:866
A class that converts a GEOS geometry to a TerraLib geometry.
Geometry * getEnvelope() const
It returns the minimum bounding rectangle (MBR) for the geometry.
Definition: Geometry.cpp:98
std::string asText() const
It returns an string with the Well-Known Text Representation for the geometry.
Definition: Geometry.cpp:111
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
static void loadGeomTypeId()
It loads the internal MAP of geometry type names to geometry type ids.
Definition: Geometry.cpp:558
virtual ~Geometry()
Virtual destructor.
Definition: Geometry.cpp:72
virtual bool coveredBy(const Geometry *const rhs) const
It returns true if this geometry object is spatially covered by rhs geometry.
Definition: Geometry.cpp:373
virtual bool relate(const Geometry *const rhs, const std::string &matrix) const
It returns true if this geometry object is spatially related to rhs geometry according to the pattern...
Definition: Geometry.cpp:327
virtual bool disjoint(const Geometry *const rhs) const
It returns true if the geometry object is spatially disjoint from rhs geometry.
Definition: Geometry.cpp:229
A class that deserializes a geometry from a valid WKT.
#define TE_GEOS_DEFAULT_QUADRANT_SEGMENTS
Determines the number of default segments used to create buffers.
Definition: Config.h:79