OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 
virtual bool operator== (const GeoBase &other) 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 }
 
- 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 81 of file geo_types.h.

Constructor & Destructor Documentation

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

Definition at line 219 of file geo_types.cpp.

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

219  {
220  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbLineString);
221  OGRLineString* line = dynamic_cast<OGRLineString*>(geom_);
222  CHECK(line);
223  for (size_t i = 0; i < coords.size(); i += 2) {
224  line->addPoint(coords[i], coords[i + 1]);
225  }
226 }
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:59

+ Here is the call graph for this function:

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

Definition at line 228 of file geo_types.cpp.

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

228  {
229  const auto err = GeoBase::createFromWktString(wkt, &geom_);
230  if (err != OGRERR_NONE) {
231  throw GeoTypesError("LineString", err);
232  }
233  CHECK(geom_);
234  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbLineString) {
235  throw GeoTypesError("LineString",
236  "Unexpected geometry type from WKT string: " +
237  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
238  }
239 }
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::GeoLineString::GeoLineString ( OGRGeometry *  geom,
const bool  owns_geom_obj 
)
inlineprotected

Definition at line 90 of file geo_types.h.

91  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

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

Definition at line 241 of file geo_types.cpp.

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

242  {
243  auto linestring_geom = dynamic_cast<OGRLineString*>(geom_);
244  CHECK(linestring_geom);
245 
246  if (linestring_geom->IsEmpty()) {
247  // until the run-time can handle empties
248  throw GeoTypesError("LineString", "'EMPTY' not supported");
249  // return null bounds
250  bounds.push_back(NULL_DOUBLE);
251  bounds.push_back(NULL_DOUBLE);
252  bounds.push_back(NULL_DOUBLE);
253  bounds.push_back(NULL_DOUBLE);
254  return;
255  }
256 
257  BoundingBox bbox;
258  for (auto i = 0; i < linestring_geom->getNumPoints(); i++) {
259  OGRPoint point;
260  linestring_geom->getPoint(i, &point);
261  double x = point.getX();
262  double y = point.getY();
263  coords.push_back(x);
264  coords.push_back(y);
265  bbox.update(x, y);
266  }
267  bounds.push_back(bbox.min.x);
268  bounds.push_back(bbox.min.y);
269  bounds.push_back(bbox.max.x);
270  bounds.push_back(bbox.max.y);
271 }
#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::GeoLineString::getType ( ) const
inlinefinalvirtual

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 93 of file geo_types.h.


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