OmniSciDB  a987f07e93
 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, GeoType::kMULTILINESTRING, GeoType::kMULTIPOINT
}
 
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,
  GeoOp::kCONCAVEHULL = 8, GeoOp::kCONVEXHULL = 9
}
 
- 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 createFromWkbView (OGRGeometry **geom, WkbView const)
 
- Protected Attributes inherited from Geospatial::GeoBase
OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Detailed Description

Definition at line 181 of file Types.h.

Constructor & Destructor Documentation

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

Definition at line 790 of file Types.cpp.

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

Referenced by clone().

791  {
792  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbPolygon);
793  OGRPolygon* poly = dynamic_cast<OGRPolygon*>(geom_);
794  CHECK(poly);
795 
796  size_t coords_ctr = 0;
797  for (size_t r = 0; r < ring_sizes.size(); r++) {
798  OGRLinearRing ring;
799  const auto ring_sz = ring_sizes[r];
800  for (auto i = 0; i < 2 * ring_sz; i += 2) {
801  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
802  }
803  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
804  coords_ctr += 2 * ring_sz;
805  poly->addRing(&ring);
806  }
807 }
OGRGeometry * geom_
Definition: Types.h:102
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the caller graph for this function:

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

Definition at line 809 of file Types.cpp.

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

809  {
810  const auto err = GeoBase::createFromWktString(wkt, &geom_);
811  if (err != OGRERR_NONE) {
812  throw GeoTypesError("Polygon", err);
813  }
814  CHECK(geom_);
815  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbPolygon) {
816  throw GeoTypesError("Polygon",
817  "Unexpected geometry type from WKT string: " +
818  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
819  }
820 }
OGRGeometry * geom_
Definition: Types.h:102
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: Types.cpp:154
#define CHECK(condition)
Definition: Logger.h:289

+ Here is the call graph for this function:

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

Definition at line 196 of file Types.h.

197  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

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

Implements Geospatial::GeoBase.

Definition at line 785 of file Types.cpp.

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

785  {
786  CHECK(geom_);
787  return std::unique_ptr<GeoBase>(new GeoPolygon(geom_->clone(), true));
788 }
OGRGeometry * geom_
Definition: Types.h:102
#define CHECK(condition)
Definition: Logger.h:289
GeoPolygon(const std::vector< double > &coords, const std::vector< int32_t > &ring_sizes)
Definition: Types.cpp:790

+ 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 822 of file Types.cpp.

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

824  {
825  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
826  CHECK(poly_geom);
827 
828  if (poly_geom->IsEmpty()) {
829  // until the run-time can handle empties
830  throw GeoTypesError("Polygon", "'EMPTY' not supported");
831  // return null bounds
832  bounds.push_back(NULL_DOUBLE);
833  bounds.push_back(NULL_DOUBLE);
834  bounds.push_back(NULL_DOUBLE);
835  bounds.push_back(NULL_DOUBLE);
836  return;
837  }
838 
839  BoundingBox bbox;
840  const auto exterior_ring = poly_geom->getExteriorRing();
841  CHECK(exterior_ring);
842  // All exterior rings are imported CCW
843  if (exterior_ring->isClockwise()) {
844  exterior_ring->reverseWindingOrder();
845  }
846  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
847  ring_sizes.push_back(num_points_added);
848  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
849  auto interior_ring = poly_geom->getInteriorRing(r);
850  CHECK(interior_ring);
851  // All interior rings are imported CW
852  if (!interior_ring->isClockwise()) {
853  interior_ring->reverseWindingOrder();
854  }
855  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
856  ring_sizes.push_back(num_points_added);
857  }
858  bounds.push_back(bbox.min.x);
859  bounds.push_back(bbox.min.y);
860  bounds.push_back(bbox.max.x);
861  bounds.push_back(bbox.max.y);
862 }
OGRGeometry * geom_
Definition: Types.h:102
#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:289

+ Here is the call graph for this function:

int32_t GeoPolygon::getNumInteriorRings ( ) const

Definition at line 864 of file Types.cpp.

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

864  {
865  const auto poly_geom = dynamic_cast<OGRPolygon*>(geom_);
866  CHECK(poly_geom);
867  return poly_geom->getNumInteriorRings();
868 }
OGRGeometry * geom_
Definition: Types.h:102
#define CHECK(condition)
Definition: Logger.h:289
GeoType Geospatial::GeoPolygon::getType ( ) const
inlinefinalvirtual

Implements Geospatial::GeoBase.

Definition at line 189 of file Types.h.

References Geospatial::GeoBase::kPOLYGON.

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 199 of file Types.h.


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