OmniSciDB  04ee39c94c
Geo_namespace::GeoBase Class Referenceabstract

#include <geo_types.h>

+ Inheritance diagram for Geo_namespace::GeoBase:

Public Types

enum  GeoType { GeoType::kPOINT, GeoType::kLINESTRING, GeoType::kPOLYGON, GeoType::kMULTIPOLYGON }
 

Public Member Functions

 GeoBase ()
 
virtual ~GeoBase ()
 
std::string getWktString () const
 
virtual GeoType getType () const =0
 
virtual bool operator== (const GeoBase &other) const
 

Protected Member Functions

 GeoBase (OGRGeometry *geom, const bool owns_geom_obj)
 

Static Protected Member Functions

static int createFromWktString (const std::string &wkt, OGRGeometry **geom)
 

Protected Attributes

OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Friends

class GeoTypesFactory
 

Detailed Description

Definition at line 45 of file geo_types.h.

Member Enumeration Documentation

◆ GeoType

Enumerator
kPOINT 
kLINESTRING 
kPOLYGON 
kMULTIPOLYGON 

Definition at line 51 of file geo_types.h.

Constructor & Destructor Documentation

◆ GeoBase() [1/2]

Geo_namespace::GeoBase::GeoBase ( )
inline

Definition at line 47 of file geo_types.h.

47 : owns_geom_obj_(true) {}

◆ ~GeoBase()

Geo_namespace::GeoBase::~GeoBase ( )
virtual

Definition at line 138 of file geo_types.cpp.

138  {
139  // Note: Removing the geometry object that was pulled from an OGRFeature results in a
140  // segfault. If we are wrapping around a pre-existing OGRGeometry object, we let the
141  // caller manage the memory.
142  if (geom_ && owns_geom_obj_) {
143  OGRGeometryFactory::destroyGeometry(geom_);
144  }
145 }
OGRGeometry * geom_
Definition: geo_types.h:59

◆ GeoBase() [2/2]

Geo_namespace::GeoBase::GeoBase ( OGRGeometry *  geom,
const bool  owns_geom_obj 
)
inlineprotected

Definition at line 57 of file geo_types.h.

58  : geom_(geom), owns_geom_obj_(owns_geom_obj) {}
OGRGeometry * geom_
Definition: geo_types.h:59

Member Function Documentation

◆ createFromWktString()

OGRErr Geo_namespace::GeoBase::createFromWktString ( const std::string &  wkt,
OGRGeometry **  geom 
)
staticprotected

Definition at line 147 of file geo_types.cpp.

147  {
148 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 3)
149  OGRErr ogr_status = OGRGeometryFactory::createFromWkt(wkt.c_str(), nullptr, geom);
150 #else
151  auto data = (char*)wkt.c_str();
152  OGRErr ogr_status = OGRGeometryFactory::createFromWkt(&data, NULL, geom);
153 #endif
154  return ogr_status;
155 }

◆ getType()

virtual GeoType Geo_namespace::GeoBase::getType ( ) const
pure virtual

◆ getWktString()

std::string Geo_namespace::GeoBase::getWktString ( ) const

Definition at line 157 of file geo_types.cpp.

References CHECK.

Referenced by GeoWktSerializer< kPOINT >::serialize(), GeoWktSerializer< kLINESTRING >::serialize(), GeoWktSerializer< kPOLYGON >::serialize(), and GeoWktSerializer< kMULTIPOLYGON >::serialize().

157  {
158  char* wkt = nullptr;
159  geom_->exportToWkt(&wkt);
160  CHECK(wkt);
161  std::string wkt_str(wkt);
162  CPLFree(wkt);
163  return wkt_str;
164 }
OGRGeometry * geom_
Definition: geo_types.h:59
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the caller graph for this function:

◆ operator==()

bool Geo_namespace::GeoBase::operator== ( const GeoBase other) const
virtual

Definition at line 166 of file geo_types.cpp.

References geom_.

166  {
167  if (!this->geom_ || !other.geom_) {
168  return false;
169  }
170  return this->geom_->Equals(other.geom_);
171  // return const_cast<const OGRGeometry*>(this->geom_) == const_cast<const
172  // OGRGeometry*>(other.geom_);
173 }
OGRGeometry * geom_
Definition: geo_types.h:59

Friends And Related Function Documentation

◆ GeoTypesFactory

friend class GeoTypesFactory
friend

Definition at line 64 of file geo_types.h.

Member Data Documentation

◆ geom_

OGRGeometry* Geo_namespace::GeoBase::geom_ = nullptr
protected

Definition at line 59 of file geo_types.h.

Referenced by operator==().

◆ owns_geom_obj_

bool Geo_namespace::GeoBase::owns_geom_obj_
protected

Definition at line 60 of file geo_types.h.


The documentation for this class was generated from the following files: