OmniSciDB  8a228a1076
Geo_namespace::GeoPoint Class Reference

#include <geo_types.h>

+ Inheritance diagram for Geo_namespace::GeoPoint:
+ Collaboration diagram for Geo_namespace::GeoPoint:

Public Member Functions

 GeoPoint (const std::vector< double > &coords)
 
 GeoPoint (const std::string &wkt)
 
void getColumns (std::vector< double > &coords) const
 
GeoType getType () const final
 
- Public Member Functions inherited from Geo_namespace::GeoBase
 GeoBase ()
 
virtual ~GeoBase ()
 
std::string getWktString () const
 
bool getWkb (std::vector< uint8_t > &) const
 
const OGRGeometry * getOGRGeometry () const
 
virtual bool operator== (const GeoBase &other) const
 
bool isEmpty () const
 
std::unique_ptr< GeoBaserun (GeoOp op, const GeoBase &other) const
 
std::unique_ptr< GeoBaseoptimized_run (GeoOp op, const GeoBase &other) const
 
std::unique_ptr< GeoBaserun (GeoOp op, double param) const
 
bool run (GeoOp op) const
 

Protected Member Functions

 GeoPoint (OGRGeometry *geom, const bool owns_geom_obj)
 
- Protected Member Functions inherited from Geo_namespace::GeoBase
 GeoBase (OGRGeometry *geom, const bool owns_geom_obj)
 

Friends

class GeoTypesFactory
 

Additional Inherited Members

- Public Types inherited from Geo_namespace::GeoBase
enum  GeoType {
  GeoType::kPOINT, GeoType::kLINESTRING, GeoType::kPOLYGON, GeoType::kMULTIPOLYGON,
  GeoType::kGEOMETRY, GeoType::kGEOMETRYCOLLECTION
}
 
enum  GeoOp {
  GeoOp::kPROJECTION = 0, GeoOp::kINTERSECTION = 1, GeoOp::kDIFFERENCE = 2, GeoOp::kUNION = 3,
  GeoOp::kBUFFER = 4, GeoOp::kISVALID = 5, GeoOp::kISEMPTY = 6
}
 
- Static Protected Member Functions inherited from Geo_namespace::GeoBase
static int createFromWktString (const std::string &wkt, OGRGeometry **geom)
 
static int createFromWkb (const std::vector< uint8_t > &wkb, OGRGeometry **geom)
 
- Protected Attributes inherited from Geo_namespace::GeoBase
OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Detailed Description

Definition at line 93 of file geo_types.h.

Constructor & Destructor Documentation

◆ GeoPoint() [1/3]

GeoPoint::GeoPoint ( const std::vector< double > &  coords)

Definition at line 331 of file geo_types.cpp.

References CHECK, and to_string().

331  {
332  if (coords.size() != 2) {
333  throw GeoTypesError("Point",
334  "Incorrect coord size of " + std::to_string(coords.size()) +
335  " supplied. Expected 2.");
336  }
337  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPoint);
338  OGRPoint* point = dynamic_cast<OGRPoint*>(geom_);
339  CHECK(point);
340  point->setX(coords[0]);
341  point->setY(coords[1]);
342 }
std::string to_string(char const *&&v)
OGRGeometry * geom_
Definition: geo_types.h:84
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:

◆ GeoPoint() [2/3]

GeoPoint::GeoPoint ( const std::string &  wkt)

Definition at line 344 of file geo_types.cpp.

References CHECK.

344  {
345  const auto err = GeoBase::createFromWktString(wkt, &geom_);
346  if (err != OGRERR_NONE) {
347  throw GeoTypesError("Point", err);
348  }
349  CHECK(geom_);
350  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPoint) {
351  throw GeoTypesError("Point",
352  "Unexpected geometry type from WKT string: " +
353  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
354  }
355 }
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: geo_types.cpp:147
OGRGeometry * geom_
Definition: geo_types.h:84
#define CHECK(condition)
Definition: Logger.h:197

◆ GeoPoint() [3/3]

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

Definition at line 102 of file geo_types.h.

102 : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

◆ getColumns()

void GeoPoint::getColumns ( std::vector< double > &  coords) const

Definition at line 357 of file geo_types.cpp.

References CHECK, and NULL_DOUBLE.

357  {
358  const auto point_geom = dynamic_cast<OGRPoint*>(geom_);
359  CHECK(point_geom);
360 
361  if (point_geom->IsEmpty()) {
362  // until the run-time can handle empties
363  throw GeoTypesError("Point", "'EMPTY' not supported");
364  // we cannot yet handle NULL fixed-length array
365  // so we have to store sentinel values instead
366  coords.push_back(NULL_DOUBLE);
367  coords.push_back(NULL_DOUBLE);
368  return;
369  }
370 
371  coords.push_back(point_geom->getX());
372  coords.push_back(point_geom->getY());
373 }
#define NULL_DOUBLE
Definition: sqltypes.h:186
OGRGeometry * geom_
Definition: geo_types.h:84
#define CHECK(condition)
Definition: Logger.h:197

◆ getType()

GeoType Geo_namespace::GeoPoint::getType ( ) const
inlinefinalvirtual

Implements Geo_namespace::GeoBase.

Definition at line 99 of file geo_types.h.

References kPOINT.

Friends And Related Function Documentation

◆ GeoTypesFactory

friend class GeoTypesFactory
friend

Definition at line 104 of file geo_types.h.


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