OmniSciDB  6686921089
 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
}
 
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
}
 
- 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 156 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 734 of file Types.cpp.

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

Referenced by clone().

736  {
737  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbMultiPolygon);
738  OGRMultiPolygon* multipoly = dynamic_cast<OGRMultiPolygon*>(geom_);
739  CHECK(multipoly);
740 
741  size_t ring_ctr = 0;
742  size_t coords_ctr = 0;
743  for (const auto& rings_in_poly : poly_rings) {
744  OGRPolygon poly;
745  for (auto r = 0; r < rings_in_poly; r++) {
746  OGRLinearRing ring;
747  const auto ring_sz = ring_sizes[ring_ctr];
748  for (auto i = 0; i < 2 * ring_sz; i += 2) {
749  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
750  }
751  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
752  coords_ctr += 2 * ring_sz;
753  poly.addRing(&ring);
754  ring_ctr++;
755  }
756  multipoly->addGeometry(&poly);
757  }
758 }
OGRGeometry * geom_
Definition: Types.h:93
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

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

Definition at line 760 of file Types.cpp.

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

760  {
761  const auto err = GeoBase::createFromWktString(wkt, &geom_);
762  if (err != OGRERR_NONE) {
763  throw GeoTypesError("MultiPolygon", err);
764  }
765  CHECK(geom_);
766  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbMultiPolygon) {
767  throw GeoTypesError("MultiPolygon",
768  "Unexpected geometry type from WKT string: " +
769  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
770  }
771 }
OGRGeometry * geom_
Definition: Types.h:93
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: Types.cpp:154
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

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

Definition at line 172 of file Types.h.

173  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

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

Implements Geospatial::GeoBase.

Definition at line 729 of file Types.cpp.

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

729  {
730  CHECK(geom_);
731  return std::unique_ptr<GeoBase>(new GeoMultiPolygon(geom_->clone(), true));
732 }
OGRGeometry * geom_
Definition: Types.h:93
GeoMultiPolygon(const std::vector< double > &coords, const std::vector< int32_t > &ring_sizes, const std::vector< int32_t > &poly_rings)
Definition: Types.cpp:734
#define CHECK(condition)
Definition: Logger.h:209

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

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

776  {
777  const auto mpoly = dynamic_cast<OGRMultiPolygon*>(geom_);
778  CHECK(mpoly);
779 
780  if (mpoly->IsEmpty()) {
781  // until the run-time can handle empties
782  throw GeoTypesError("MultiPolygon", "'EMPTY' not supported");
783  // return null bounds
784  bounds.push_back(NULL_DOUBLE);
785  bounds.push_back(NULL_DOUBLE);
786  bounds.push_back(NULL_DOUBLE);
787  bounds.push_back(NULL_DOUBLE);
788  return;
789  }
790 
791  BoundingBox bbox;
792  for (auto p = 0; p < mpoly->getNumGeometries(); p++) {
793  const auto mpoly_geom = mpoly->getGeometryRef(p);
794  CHECK(mpoly_geom);
795  const auto poly_geom = dynamic_cast<OGRPolygon*>(mpoly_geom);
796  if (!poly_geom) {
797  throw GeoTypesError("MultiPolygon",
798  "Failed to read polygon geometry from multipolygon");
799  }
800  const auto exterior_ring = poly_geom->getExteriorRing();
801  CHECK(exterior_ring);
802  // All exterior rings are imported CCW
803  if (exterior_ring->isClockwise()) {
804  exterior_ring->reverseWindingOrder();
805  }
806  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
807  ring_sizes.push_back(num_points_added);
808 
809  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
810  auto interior_ring = poly_geom->getInteriorRing(r);
811  CHECK(interior_ring);
812  // All interior rings are imported CW
813  if (!interior_ring->isClockwise()) {
814  interior_ring->reverseWindingOrder();
815  }
816  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
817  ring_sizes.push_back(num_points_added);
818  }
819  poly_rings.push_back(poly_geom->getNumInteriorRings() + 1);
820  }
821  bounds.push_back(bbox.min.x);
822  bounds.push_back(bbox.min.y);
823  bounds.push_back(bbox.max.x);
824  bounds.push_back(bbox.max.y);
825 }
OGRGeometry * geom_
Definition: Types.h:93
#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:209

+ 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 175 of file Types.h.


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