OmniSciDB  a667adc9c8
 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)
 
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
}
 
- 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 128 of file Types.h.

Constructor & Destructor Documentation

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

Definition at line 634 of file Types.cpp.

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

635  {
636  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPolygon);
637  OGRPolygon* poly = dynamic_cast<OGRPolygon*>(geom_);
638  CHECK(poly);
639 
640  size_t coords_ctr = 0;
641  for (size_t r = 0; r < ring_sizes.size(); r++) {
642  OGRLinearRing ring;
643  const auto ring_sz = ring_sizes[r];
644  for (auto i = 0; i < 2 * ring_sz; i += 2) {
645  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
646  }
647  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
648  coords_ctr += 2 * ring_sz;
649  poly->addRing(&ring);
650  }
651 }
OGRGeometry * geom_
Definition: Types.h:90
tuple r
Definition: test_fsi.py:16
#define CHECK(condition)
Definition: Logger.h:197
GeoPolygon::GeoPolygon ( const std::string &  wkt)

Definition at line 653 of file Types.cpp.

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

653  {
654  const auto err = GeoBase::createFromWktString(wkt, &geom_);
655  if (err != OGRERR_NONE) {
656  throw GeoTypesError("Polygon", err);
657  }
658  CHECK(geom_);
659  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPolygon) {
660  throw GeoTypesError("Polygon",
661  "Unexpected geometry type from WKT string: " +
662  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
663  }
664 }
OGRGeometry * geom_
Definition: Types.h:90
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: Types.cpp:154
#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 141 of file Types.h.

142  : 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 666 of file Types.cpp.

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

668  {
669  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
670  CHECK(poly_geom);
671 
672  if (poly_geom->IsEmpty()) {
673  // until the run-time can handle empties
674  throw GeoTypesError("Polygon", "'EMPTY' not supported");
675  // return null bounds
676  bounds.push_back(NULL_DOUBLE);
677  bounds.push_back(NULL_DOUBLE);
678  bounds.push_back(NULL_DOUBLE);
679  bounds.push_back(NULL_DOUBLE);
680  return;
681  }
682 
683  BoundingBox bbox;
684  const auto exterior_ring = poly_geom->getExteriorRing();
685  CHECK(exterior_ring);
686  // All exterior rings are imported CCW
687  if (exterior_ring->isClockwise()) {
688  exterior_ring->reverseWindingOrder();
689  }
690  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
691  ring_sizes.push_back(num_points_added);
692  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
693  auto interior_ring = poly_geom->getInteriorRing(r);
694  CHECK(interior_ring);
695  // All interior rings are imported CW
696  if (!interior_ring->isClockwise()) {
697  interior_ring->reverseWindingOrder();
698  }
699  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
700  ring_sizes.push_back(num_points_added);
701  }
702  bounds.push_back(bbox.min.x);
703  bounds.push_back(bbox.min.y);
704  bounds.push_back(bbox.max.x);
705  bounds.push_back(bbox.max.y);
706 }
OGRGeometry * geom_
Definition: Types.h:90
#define NULL_DOUBLE
tuple r
Definition: test_fsi.py:16
int process_poly_ring(OGRLinearRing *ring, std::vector< double > &coords, BoundingBox *bbox)
Definition: Types.cpp:70
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

int32_t GeoPolygon::getNumInteriorRings ( ) const

Definition at line 708 of file Types.cpp.

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

708  {
709  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
710  CHECK(poly_geom);
711  return poly_geom->getNumInteriorRings();
712 }
OGRGeometry * geom_
Definition: Types.h:90
#define CHECK(condition)
Definition: Logger.h:197
GeoType Geospatial::GeoPolygon::getType ( ) const
inlinefinalvirtual

Implements Geospatial::GeoBase.

Definition at line 136 of file Types.h.

References Geospatial::GeoBase::kPOLYGON.

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 144 of file Types.h.


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