OmniSciDB  a5dc49c757
 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 791 of file Types.cpp.

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

Referenced by clone().

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

+ Here is the caller graph for this function:

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

Definition at line 810 of file Types.cpp.

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

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

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

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

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

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

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

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

+ Here is the call graph for this function:

int32_t GeoPolygon::getNumInteriorRings ( ) const

Definition at line 865 of file Types.cpp.

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

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

Implements Geospatial::GeoBase.

Definition at line 189 of file Types.h.

References kPOLYGON.

189 { return GeoType::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: