OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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
 
std::unique_ptr< GeoBaseclone () 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
 
int32_t getBestPlanarSRID () const
 
bool transform (int32_t srid0, int32_t srid1)
 
bool transform (SQLTypeInfo &ti)
 
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, GeoOp::kEQUALS = 7
}
 
- Static Public Member Functions inherited from Geospatial::GeoBase
static std::shared_ptr
< OGRCoordinateTransformation > 
getTransformation (int32_t srid0, int32_t srid1)
 
- 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 135 of file Types.h.

Constructor & Destructor Documentation

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

Definition at line 649 of file Types.cpp.

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

Referenced by clone().

650  {
651  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPolygon);
652  OGRPolygon* poly = dynamic_cast<OGRPolygon*>(geom_);
653  CHECK(poly);
654 
655  size_t coords_ctr = 0;
656  for (size_t r = 0; r < ring_sizes.size(); r++) {
657  OGRLinearRing ring;
658  const auto ring_sz = ring_sizes[r];
659  for (auto i = 0; i < 2 * ring_sz; i += 2) {
660  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
661  }
662  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
663  coords_ctr += 2 * ring_sz;
664  poly->addRing(&ring);
665  }
666 }
OGRGeometry * geom_
Definition: Types.h:93
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

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

Definition at line 668 of file Types.cpp.

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

668  {
669  const auto err = GeoBase::createFromWktString(wkt, &geom_);
670  if (err != OGRERR_NONE) {
671  throw GeoTypesError("Polygon", err);
672  }
673  CHECK(geom_);
674  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPolygon) {
675  throw GeoTypesError("Polygon",
676  "Unexpected geometry type from WKT string: " +
677  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
678  }
679 }
OGRGeometry * geom_
Definition: Types.h:93
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: Types.cpp:154
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

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

Definition at line 150 of file Types.h.

151  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

std::unique_ptr< GeoBase > GeoPolygon::clone ( ) const
finalvirtual

Implements Geospatial::GeoBase.

Definition at line 644 of file Types.cpp.

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

644  {
645  CHECK(geom_);
646  return std::unique_ptr<GeoBase>(new GeoPolygon(geom_->clone(), true));
647 }
OGRGeometry * geom_
Definition: Types.h:93
#define CHECK(condition)
Definition: Logger.h:209
GeoPolygon(const std::vector< double > &coords, const std::vector< int32_t > &ring_sizes)
Definition: Types.cpp:649

+ Here is the call graph for this function:

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

Definition at line 681 of file Types.cpp.

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

683  {
684  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
685  CHECK(poly_geom);
686 
687  if (poly_geom->IsEmpty()) {
688  // until the run-time can handle empties
689  throw GeoTypesError("Polygon", "'EMPTY' not supported");
690  // return null bounds
691  bounds.push_back(NULL_DOUBLE);
692  bounds.push_back(NULL_DOUBLE);
693  bounds.push_back(NULL_DOUBLE);
694  bounds.push_back(NULL_DOUBLE);
695  return;
696  }
697 
698  BoundingBox bbox;
699  const auto exterior_ring = poly_geom->getExteriorRing();
700  CHECK(exterior_ring);
701  // All exterior rings are imported CCW
702  if (exterior_ring->isClockwise()) {
703  exterior_ring->reverseWindingOrder();
704  }
705  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
706  ring_sizes.push_back(num_points_added);
707  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
708  auto interior_ring = poly_geom->getInteriorRing(r);
709  CHECK(interior_ring);
710  // All interior rings are imported CW
711  if (!interior_ring->isClockwise()) {
712  interior_ring->reverseWindingOrder();
713  }
714  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
715  ring_sizes.push_back(num_points_added);
716  }
717  bounds.push_back(bbox.min.x);
718  bounds.push_back(bbox.min.y);
719  bounds.push_back(bbox.max.x);
720  bounds.push_back(bbox.max.y);
721 }
OGRGeometry * geom_
Definition: Types.h:93
#define NULL_DOUBLE
int process_poly_ring(OGRLinearRing *ring, std::vector< double > &coords, BoundingBox *bbox)
Definition: Types.cpp:70
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

int32_t GeoPolygon::getNumInteriorRings ( ) const

Definition at line 723 of file Types.cpp.

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

723  {
724  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
725  CHECK(poly_geom);
726  return poly_geom->getNumInteriorRings();
727 }
OGRGeometry * geom_
Definition: Types.h:93
#define CHECK(condition)
Definition: Logger.h:209
GeoType Geospatial::GeoPolygon::getType ( ) const
inlinefinalvirtual

Implements Geospatial::GeoBase.

Definition at line 143 of file Types.h.

References Geospatial::GeoBase::kPOLYGON.

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 153 of file Types.h.


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