OmniSciDB  72c90bc290
 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 876 of file Types.cpp.

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

Referenced by clone().

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

+ Here is the caller graph for this function:

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

Definition at line 902 of file Types.cpp.

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

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

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

871  {
872  CHECK(geom_);
873  return std::unique_ptr<GeoBase>(new GeoMultiPolygon(geom_->clone(), true));
874 }
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:876
#define CHECK(condition)
Definition: Logger.h:291

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

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

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

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

Implements Geospatial::GeoBase.

Definition at line 213 of file Types.h.

References kMULTIPOLYGON.

213 { return GeoType::kMULTIPOLYGON; }

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: