OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geospatial::GeoMultiPolygon Class Reference

#include <Types.h>

+ Inheritance diagram for Geospatial::GeoMultiPolygon:
+ Collaboration diagram for Geospatial::GeoMultiPolygon:

Public Member Functions

 GeoMultiPolygon (const std::vector< double > &coords, const std::vector< int32_t > &ring_sizes, const std::vector< int32_t > &poly_rings)
 
 GeoMultiPolygon (const std::string &wkt)
 
void getColumns (std::vector< double > &coords, std::vector< int32_t > &ring_sizes, std::vector< int32_t > &poly_rings, std::vector< double > &bounds) const
 
GeoType getType () const final
 
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

 GeoMultiPolygon (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 202 of file Types.h.

Constructor & Destructor Documentation

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

Definition at line 875 of file Types.cpp.

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

Referenced by clone().

877  {
878  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbMultiPolygon);
879  OGRMultiPolygon* multipoly = dynamic_cast<OGRMultiPolygon*>(geom_);
880  CHECK(multipoly);
881 
882  size_t ring_ctr = 0;
883  size_t coords_ctr = 0;
884  for (const auto& rings_in_poly : poly_rings) {
885  OGRPolygon poly;
886  for (auto r = 0; r < rings_in_poly; r++) {
887  OGRLinearRing ring;
888  const auto ring_sz = ring_sizes[ring_ctr];
889  for (auto i = 0; i < 2 * ring_sz; i += 2) {
890  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
891  }
892  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
893  coords_ctr += 2 * ring_sz;
894  poly.addRing(&ring);
895  ring_ctr++;
896  }
897  multipoly->addGeometry(&poly);
898  }
899 }
OGRGeometry * geom_
Definition: Types.h:102
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

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

Definition at line 901 of file Types.cpp.

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

901  {
902  const auto err = GeoBase::createFromWktString(wkt, &geom_);
903  if (err != OGRERR_NONE) {
904  throw GeoTypesError("MultiPolygon", err);
905  }
906  CHECK(geom_);
907  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbMultiPolygon) {
908  throw GeoTypesError("MultiPolygon",
909  "Unexpected geometry type from WKT string: " +
910  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
911  }
912 }
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:222

+ Here is the call graph for this function:

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

Definition at line 218 of file Types.h.

219  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

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

Implements Geospatial::GeoBase.

Definition at line 870 of file Types.cpp.

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

870  {
871  CHECK(geom_);
872  return std::unique_ptr<GeoBase>(new GeoMultiPolygon(geom_->clone(), true));
873 }
OGRGeometry * geom_
Definition: Types.h:102
GeoMultiPolygon(const std::vector< double > &coords, const std::vector< int32_t > &ring_sizes, const std::vector< int32_t > &poly_rings)
Definition: Types.cpp:875
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

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

Definition at line 914 of file Types.cpp.

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

917  {
918  const auto mpoly = dynamic_cast<OGRMultiPolygon*>(geom_);
919  CHECK(mpoly);
920 
921  if (mpoly->IsEmpty()) {
922  // until the run-time can handle empties
923  throw GeoTypesError("MultiPolygon", "'EMPTY' not supported");
924  // return null bounds
925  bounds.push_back(NULL_DOUBLE);
926  bounds.push_back(NULL_DOUBLE);
927  bounds.push_back(NULL_DOUBLE);
928  bounds.push_back(NULL_DOUBLE);
929  return;
930  }
931 
932  BoundingBox bbox;
933  for (auto p = 0; p < mpoly->getNumGeometries(); p++) {
934  const auto mpoly_geom = mpoly->getGeometryRef(p);
935  CHECK(mpoly_geom);
936  const auto poly_geom = dynamic_cast<OGRPolygon*>(mpoly_geom);
937  if (!poly_geom) {
938  throw GeoTypesError("MultiPolygon",
939  "Failed to read polygon geometry from multipolygon");
940  }
941  const auto exterior_ring = poly_geom->getExteriorRing();
942  CHECK(exterior_ring);
943  // All exterior rings are imported CCW
944  if (exterior_ring->isClockwise()) {
945  exterior_ring->reverseWindingOrder();
946  }
947  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
948  ring_sizes.push_back(num_points_added);
949 
950  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
951  auto interior_ring = poly_geom->getInteriorRing(r);
952  CHECK(interior_ring);
953  // All interior rings are imported CW
954  if (!interior_ring->isClockwise()) {
955  interior_ring->reverseWindingOrder();
956  }
957  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
958  ring_sizes.push_back(num_points_added);
959  }
960  poly_rings.push_back(poly_geom->getNumInteriorRings() + 1);
961  }
962  bounds.push_back(bbox.min.x);
963  bounds.push_back(bbox.min.y);
964  bounds.push_back(bbox.max.x);
965  bounds.push_back(bbox.max.y);
966 }
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:222

+ Here is the call graph for this function:

GeoType Geospatial::GeoMultiPolygon::getType ( ) const
inlinefinalvirtual

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 221 of file Types.h.


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