OmniSciDB  2e3a973ef4
Geospatial::GeoLineString Class Reference

#include <Types.h>

+ Inheritance diagram for Geospatial::GeoLineString:
+ Collaboration diagram for Geospatial::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 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

 GeoLineString (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 106 of file Types.h.

Constructor & Destructor Documentation

◆ GeoLineString() [1/3]

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

Definition at line 376 of file Types.cpp.

References CHECK, and parse_ast::line.

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

◆ GeoLineString() [2/3]

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

Definition at line 385 of file Types.cpp.

References CHECK.

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

◆ GeoLineString() [3/3]

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

Definition at line 115 of file Types.h.

116  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

◆ getColumns()

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

Definition at line 398 of file Types.cpp.

References CHECK, and NULL_DOUBLE.

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

◆ getType()

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

Implements Geospatial::GeoBase.

Definition at line 112 of file Types.h.

References kLINESTRING.

Friends And Related Function Documentation

◆ GeoTypesFactory

friend class GeoTypesFactory
friend

Definition at line 118 of file Types.h.


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