OmniSciDB  2e3a973ef4
Geospatial::GeoPoint Class Reference

#include <Types.h>

+ Inheritance diagram for Geospatial::GeoPoint:
+ Collaboration diagram for Geospatial::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 Geospatial::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 Geospatial::GeoBase
 GeoBase (OGRGeometry *geom, const bool owns_geom_obj)
 

Friends

class GeoTypesFactory
 

Additional Inherited Members

- Public Types inherited from Geospatial::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 Geospatial::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 Geospatial::GeoBase
OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Detailed Description

Definition at line 92 of file Types.h.

Constructor & Destructor Documentation

◆ GeoPoint() [1/3]

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

Definition at line 332 of file Types.cpp.

References CHECK, and to_string().

332  {
333  if (coords.size() != 2) {
334  throw GeoTypesError("Point",
335  "Incorrect coord size of " + std::to_string(coords.size()) +
336  " supplied. Expected 2.");
337  }
338  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPoint);
339  OGRPoint* point = dynamic_cast<OGRPoint*>(geom_);
340  CHECK(point);
341  point->setX(coords[0]);
342  point->setY(coords[1]);
343 }
OGRGeometry * geom_
Definition: Types.h:83
std::string to_string(char const *&&v)
#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 345 of file Types.cpp.

References CHECK.

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

◆ GeoPoint() [3/3]

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

Definition at line 101 of file Types.h.

101 : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

◆ getColumns()

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

Definition at line 358 of file Types.cpp.

References CHECK, and NULL_DOUBLE.

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

◆ getType()

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

Implements Geospatial::GeoBase.

Definition at line 98 of file Types.h.

References kPOINT.

Friends And Related Function Documentation

◆ GeoTypesFactory

friend class GeoTypesFactory
friend

Definition at line 103 of file Types.h.


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