OmniSciDB  8a228a1076
Geo_namespace::GeoLineString Class Reference

#include <geo_types.h>

+ Inheritance diagram for Geo_namespace::GeoLineString:
+ Collaboration diagram for Geo_namespace::GeoLineString:

Public Member Functions

 GeoLineString (const std::vector< double > &coords)
 
 GeoLineString (const std::string &wkt)
 
void getColumns (std::vector< double > &coords, std::vector< double > &bounds) 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

 GeoLineString (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 107 of file geo_types.h.

Constructor & Destructor Documentation

◆ GeoLineString() [1/3]

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

Definition at line 375 of file geo_types.cpp.

References CHECK.

375  {
376  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbLineString);
377  OGRLineString* line = dynamic_cast<OGRLineString*>(geom_);
378  CHECK(line);
379  for (size_t i = 0; i < coords.size(); i += 2) {
380  line->addPoint(coords[i], coords[i + 1]);
381  }
382 }
OGRGeometry * geom_
Definition: geo_types.h:84
#define CHECK(condition)
Definition: Logger.h:197

◆ GeoLineString() [2/3]

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

Definition at line 384 of file geo_types.cpp.

References CHECK.

384  {
385  const auto err = GeoBase::createFromWktString(wkt, &geom_);
386  if (err != OGRERR_NONE) {
387  throw GeoTypesError("LineString", err);
388  }
389  CHECK(geom_);
390  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbLineString) {
391  throw GeoTypesError("LineString",
392  "Unexpected geometry type from WKT string: " +
393  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
394  }
395 }
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

◆ GeoLineString() [3/3]

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

Definition at line 116 of file geo_types.h.

117  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

◆ getColumns()

void GeoLineString::getColumns ( std::vector< double > &  coords,
std::vector< double > &  bounds 
) const

Definition at line 397 of file geo_types.cpp.

References CHECK, and NULL_DOUBLE.

398  {
399  auto linestring_geom = dynamic_cast<OGRLineString*>(geom_);
400  CHECK(linestring_geom);
401 
402  if (linestring_geom->IsEmpty()) {
403  // until the run-time can handle empties
404  throw GeoTypesError("LineString", "'EMPTY' not supported");
405  // return null bounds
406  bounds.push_back(NULL_DOUBLE);
407  bounds.push_back(NULL_DOUBLE);
408  bounds.push_back(NULL_DOUBLE);
409  bounds.push_back(NULL_DOUBLE);
410  return;
411  }
412 
413  BoundingBox bbox;
414  for (auto i = 0; i < linestring_geom->getNumPoints(); i++) {
415  OGRPoint point;
416  linestring_geom->getPoint(i, &point);
417  double x = point.getX();
418  double y = point.getY();
419  coords.push_back(x);
420  coords.push_back(y);
421  bbox.update(x, y);
422  }
423  bounds.push_back(bbox.min.x);
424  bounds.push_back(bbox.min.y);
425  bounds.push_back(bbox.max.x);
426  bounds.push_back(bbox.max.y);
427 }
#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::GeoLineString::getType ( ) const
inlinefinalvirtual

Implements Geo_namespace::GeoBase.

Definition at line 113 of file geo_types.h.

References kLINESTRING.

Friends And Related Function Documentation

◆ GeoTypesFactory

friend class GeoTypesFactory
friend

Definition at line 119 of file geo_types.h.


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