OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 
virtual bool operator== (const GeoBase &other) 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 }
 
- Static Protected Member Functions inherited from Geo_namespace::GeoBase
static int createFromWktString (const std::string &wkt, OGRGeometry **geom)
 
- Protected Attributes inherited from Geo_namespace::GeoBase
OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Detailed Description

Definition at line 67 of file geo_types.h.

Constructor & Destructor Documentation

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

Definition at line 175 of file geo_types.cpp.

References CHECK(), Geo_namespace::GeoBase::geom_, and to_string().

175  {
176  if (coords.size() != 2) {
177  throw GeoTypesError("Point",
178  "Incorrect coord size of " + std::to_string(coords.size()) +
179  " supplied. Expected 2.");
180  }
181  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPoint);
182  OGRPoint* point = dynamic_cast<OGRPoint*>(geom_);
183  CHECK(point);
184  point->setX(coords[0]);
185  point->setY(coords[1]);
186 }
std::string to_string(char const *&&v)
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:59

+ Here is the call graph for this function:

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

Definition at line 188 of file geo_types.cpp.

References CHECK(), Geo_namespace::GeoBase::createFromWktString(), and Geo_namespace::GeoBase::geom_.

188  {
189  const auto err = GeoBase::createFromWktString(wkt, &geom_);
190  if (err != OGRERR_NONE) {
191  throw GeoTypesError("Point", err);
192  }
193  CHECK(geom_);
194  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPoint) {
195  throw GeoTypesError("Point",
196  "Unexpected geometry type from WKT string: " +
197  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
198  }
199 }
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: geo_types.cpp:147
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:59

+ Here is the call graph for this function:

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

Definition at line 76 of file geo_types.h.

76 : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

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

Definition at line 201 of file geo_types.cpp.

References CHECK(), Geo_namespace::GeoBase::geom_, and NULL_DOUBLE.

201  {
202  const auto point_geom = dynamic_cast<OGRPoint*>(geom_);
203  CHECK(point_geom);
204 
205  if (point_geom->IsEmpty()) {
206  // until the run-time can handle empties
207  throw GeoTypesError("Point", "'EMPTY' not supported");
208  // we cannot yet handle NULL fixed-length array
209  // so we have to store sentinel values instead
210  coords.push_back(NULL_DOUBLE);
211  coords.push_back(NULL_DOUBLE);
212  return;
213  }
214 
215  coords.push_back(point_geom->getX());
216  coords.push_back(point_geom->getY());
217 }
#define NULL_DOUBLE
Definition: sqltypes.h:179
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:59

+ Here is the call graph for this function:

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

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 78 of file geo_types.h.


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