OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Geospatial::GeoPolygon Class Reference

#include <Types.h>

+ Inheritance diagram for Geospatial::GeoPolygon:
+ Collaboration diagram for Geospatial::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 Geospatial::GeoBase
 GeoBase ()
 
virtual ~GeoBase ()
 
std::string getWktString () const
 
bool getWkb (std::vector< uint8_t > &) const
 
const OGRGeometry * getOGRGeometry () const
 
int32_t getBestPlanarSRID () const
 
bool transform (int32_t srid0, int32_t srid1)
 
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 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 124 of file Types.h.

Constructor & Destructor Documentation

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

Definition at line 593 of file Types.cpp.

References CHECK, and Geospatial::GeoBase::geom_.

594  {
595  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPolygon);
596  OGRPolygon* poly = dynamic_cast<OGRPolygon*>(geom_);
597  CHECK(poly);
598 
599  size_t coords_ctr = 0;
600  for (size_t r = 0; r < ring_sizes.size(); r++) {
601  OGRLinearRing ring;
602  const auto ring_sz = ring_sizes[r];
603  for (auto i = 0; i < 2 * ring_sz; i += 2) {
604  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
605  }
606  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
607  coords_ctr += 2 * ring_sz;
608  poly->addRing(&ring);
609  }
610 }
OGRGeometry * geom_
Definition: Types.h:86
#define CHECK(condition)
Definition: Logger.h:197
GeoPolygon::GeoPolygon ( const std::string &  wkt)

Definition at line 612 of file Types.cpp.

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

612  {
613  const auto err = GeoBase::createFromWktString(wkt, &geom_);
614  if (err != OGRERR_NONE) {
615  throw GeoTypesError("Polygon", err);
616  }
617  CHECK(geom_);
618  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPolygon) {
619  throw GeoTypesError("Polygon",
620  "Unexpected geometry type from WKT string: " +
621  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
622  }
623 }
OGRGeometry * geom_
Definition: Types.h:86
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: Types.cpp:148
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

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

Definition at line 137 of file Types.h.

138  : 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 625 of file Types.cpp.

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

627  {
628  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
629  CHECK(poly_geom);
630 
631  if (poly_geom->IsEmpty()) {
632  // until the run-time can handle empties
633  throw GeoTypesError("Polygon", "'EMPTY' not supported");
634  // return null bounds
635  bounds.push_back(NULL_DOUBLE);
636  bounds.push_back(NULL_DOUBLE);
637  bounds.push_back(NULL_DOUBLE);
638  bounds.push_back(NULL_DOUBLE);
639  return;
640  }
641 
642  BoundingBox bbox;
643  const auto exterior_ring = poly_geom->getExteriorRing();
644  CHECK(exterior_ring);
645  // All exterior rings are imported CCW
646  if (exterior_ring->isClockwise()) {
647  exterior_ring->reverseWindingOrder();
648  }
649  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
650  ring_sizes.push_back(num_points_added);
651  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
652  auto interior_ring = poly_geom->getInteriorRing(r);
653  CHECK(interior_ring);
654  // All interior rings are imported CW
655  if (!interior_ring->isClockwise()) {
656  interior_ring->reverseWindingOrder();
657  }
658  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
659  ring_sizes.push_back(num_points_added);
660  }
661  bounds.push_back(bbox.min.x);
662  bounds.push_back(bbox.min.y);
663  bounds.push_back(bbox.max.x);
664  bounds.push_back(bbox.max.y);
665 }
OGRGeometry * geom_
Definition: Types.h:86
#define NULL_DOUBLE
Definition: sqltypes.h:186
int process_poly_ring(OGRLinearRing *ring, std::vector< double > &coords, BoundingBox *bbox)
Definition: Types.cpp:68
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

int32_t GeoPolygon::getNumInteriorRings ( ) const

Definition at line 667 of file Types.cpp.

References CHECK, and Geospatial::GeoBase::geom_.

667  {
668  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
669  CHECK(poly_geom);
670  return poly_geom->getNumInteriorRings();
671 }
OGRGeometry * geom_
Definition: Types.h:86
#define CHECK(condition)
Definition: Logger.h:197
GeoType Geospatial::GeoPolygon::getType ( ) const
inlinefinalvirtual

Implements Geospatial::GeoBase.

Definition at line 132 of file Types.h.

References Geospatial::GeoBase::kPOLYGON.

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 140 of file Types.h.


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