OmniSciDB  72180abbfe
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Geo_namespace::GeoPolygon Class Reference

#include <geo_types.h>

+ Inheritance diagram for Geo_namespace::GeoPolygon:
+ Collaboration diagram for Geo_namespace::GeoPolygon:

Public Member Functions

 GeoPolygon (const std::vector< double > &coords, const std::vector< int32_t > &ring_sizes)
 
 GeoPolygon (const std::string &wkt)
 
void getColumns (std::vector< double > &coords, std::vector< int32_t > &ring_sizes, std::vector< double > &bounds) const
 
GeoType getType () const final
 
int32_t getNumInteriorRings () const
 
- 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

 GeoPolygon (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 122 of file geo_types.h.

Constructor & Destructor Documentation

GeoPolygon::GeoPolygon ( const std::vector< double > &  coords,
const std::vector< int32_t > &  ring_sizes 
)

Definition at line 429 of file geo_types.cpp.

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

430  {
431  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPolygon);
432  OGRPolygon* poly = dynamic_cast<OGRPolygon*>(geom_);
433  CHECK(poly);
434 
435  size_t coords_ctr = 0;
436  for (size_t r = 0; r < ring_sizes.size(); r++) {
437  OGRLinearRing ring;
438  const auto ring_sz = ring_sizes[r];
439  for (auto i = 0; i < 2 * ring_sz; i += 2) {
440  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
441  }
442  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
443  coords_ctr += 2 * ring_sz;
444  poly->addRing(&ring);
445  }
446 }
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:84

+ Here is the call graph for this function:

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

Definition at line 448 of file geo_types.cpp.

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

448  {
449  const auto err = GeoBase::createFromWktString(wkt, &geom_);
450  if (err != OGRERR_NONE) {
451  throw GeoTypesError("Polygon", err);
452  }
453  CHECK(geom_);
454  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPolygon) {
455  throw GeoTypesError("Polygon",
456  "Unexpected geometry type from WKT string: " +
457  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
458  }
459 }
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: geo_types.cpp:147
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:84

+ Here is the call graph for this function:

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

Definition at line 135 of file geo_types.h.

136  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

void GeoPolygon::getColumns ( std::vector< double > &  coords,
std::vector< int32_t > &  ring_sizes,
std::vector< double > &  bounds 
) const

Definition at line 461 of file geo_types.cpp.

References CHECK(), Geo_namespace::GeoBase::geom_, NULL_DOUBLE, and anonymous_namespace{geo_types.cpp}::process_poly_ring().

463  {
464  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
465  CHECK(poly_geom);
466 
467  if (poly_geom->IsEmpty()) {
468  // until the run-time can handle empties
469  throw GeoTypesError("Polygon", "'EMPTY' not supported");
470  // return null bounds
471  bounds.push_back(NULL_DOUBLE);
472  bounds.push_back(NULL_DOUBLE);
473  bounds.push_back(NULL_DOUBLE);
474  bounds.push_back(NULL_DOUBLE);
475  return;
476  }
477 
478  BoundingBox bbox;
479  const auto exterior_ring = poly_geom->getExteriorRing();
480  CHECK(exterior_ring);
481  // All exterior rings are imported CCW
482  if (exterior_ring->isClockwise()) {
483  exterior_ring->reverseWindingOrder();
484  }
485  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
486  ring_sizes.push_back(num_points_added);
487  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
488  auto interior_ring = poly_geom->getInteriorRing(r);
489  CHECK(interior_ring);
490  // All interior rings are imported CW
491  if (!interior_ring->isClockwise()) {
492  interior_ring->reverseWindingOrder();
493  }
494  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
495  ring_sizes.push_back(num_points_added);
496  }
497  bounds.push_back(bbox.min.x);
498  bounds.push_back(bbox.min.y);
499  bounds.push_back(bbox.max.x);
500  bounds.push_back(bbox.max.y);
501 }
#define NULL_DOUBLE
Definition: sqltypes.h:184
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:84
int process_poly_ring(OGRLinearRing *ring, std::vector< double > &coords, BoundingBox *bbox)
Definition: geo_types.cpp:67

+ Here is the call graph for this function:

int32_t GeoPolygon::getNumInteriorRings ( ) const

Definition at line 503 of file geo_types.cpp.

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

503  {
504  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
505  CHECK(poly_geom);
506  return poly_geom->getNumInteriorRings();
507 }
CHECK(cgen_state)
OGRGeometry * geom_
Definition: geo_types.h:84

+ Here is the call graph for this function:

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

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 138 of file geo_types.h.


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