OmniSciDB  bf83d84833
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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
 
- 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
}
 
- 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 147 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 714 of file Types.cpp.

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

716  {
717  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbMultiPolygon);
718  OGRMultiPolygon* multipoly = dynamic_cast<OGRMultiPolygon*>(geom_);
719  CHECK(multipoly);
720 
721  size_t ring_ctr = 0;
722  size_t coords_ctr = 0;
723  for (const auto& rings_in_poly : poly_rings) {
724  OGRPolygon poly;
725  for (auto r = 0; r < rings_in_poly; r++) {
726  OGRLinearRing ring;
727  const auto ring_sz = ring_sizes[ring_ctr];
728  for (auto i = 0; i < 2 * ring_sz; i += 2) {
729  ring.addPoint(coords[coords_ctr + i], coords[coords_ctr + i + 1]);
730  }
731  ring.addPoint(coords[coords_ctr], coords[coords_ctr + 1]);
732  coords_ctr += 2 * ring_sz;
733  poly.addRing(&ring);
734  ring_ctr++;
735  }
736  multipoly->addGeometry(&poly);
737  }
738 }
OGRGeometry * geom_
Definition: Types.h:90
#define CHECK(condition)
Definition: Logger.h:197
GeoMultiPolygon::GeoMultiPolygon ( const std::string &  wkt)

Definition at line 740 of file Types.cpp.

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

740  {
741  const auto err = GeoBase::createFromWktString(wkt, &geom_);
742  if (err != OGRERR_NONE) {
743  throw GeoTypesError("MultiPolygon", err);
744  }
745  CHECK(geom_);
746  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbMultiPolygon) {
747  throw GeoTypesError("MultiPolygon",
748  "Unexpected geometry type from WKT string: " +
749  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
750  }
751 }
OGRGeometry * geom_
Definition: Types.h:90
static int createFromWktString(const std::string &wkt, OGRGeometry **geom)
Definition: Types.cpp:154
#define CHECK(condition)
Definition: Logger.h:197

+ Here is the call graph for this function:

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

Definition at line 161 of file Types.h.

162  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

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

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

756  {
757  const auto mpoly = dynamic_cast<OGRMultiPolygon*>(geom_);
758  CHECK(mpoly);
759 
760  if (mpoly->IsEmpty()) {
761  // until the run-time can handle empties
762  throw GeoTypesError("MultiPolygon", "'EMPTY' not supported");
763  // return null bounds
764  bounds.push_back(NULL_DOUBLE);
765  bounds.push_back(NULL_DOUBLE);
766  bounds.push_back(NULL_DOUBLE);
767  bounds.push_back(NULL_DOUBLE);
768  return;
769  }
770 
771  BoundingBox bbox;
772  for (auto p = 0; p < mpoly->getNumGeometries(); p++) {
773  const auto mpoly_geom = mpoly->getGeometryRef(p);
774  CHECK(mpoly_geom);
775  const auto poly_geom = dynamic_cast<OGRPolygon*>(mpoly_geom);
776  if (!poly_geom) {
777  throw GeoTypesError("MultiPolygon",
778  "Failed to read polygon geometry from multipolygon");
779  }
780  const auto exterior_ring = poly_geom->getExteriorRing();
781  CHECK(exterior_ring);
782  // All exterior rings are imported CCW
783  if (exterior_ring->isClockwise()) {
784  exterior_ring->reverseWindingOrder();
785  }
786  const auto num_points_added = process_poly_ring(exterior_ring, coords, &bbox);
787  ring_sizes.push_back(num_points_added);
788 
789  for (auto r = 0; r < poly_geom->getNumInteriorRings(); r++) {
790  auto interior_ring = poly_geom->getInteriorRing(r);
791  CHECK(interior_ring);
792  // All interior rings are imported CW
793  if (!interior_ring->isClockwise()) {
794  interior_ring->reverseWindingOrder();
795  }
796  const auto num_points_added = process_poly_ring(interior_ring, coords, nullptr);
797  ring_sizes.push_back(num_points_added);
798  }
799  poly_rings.push_back(poly_geom->getNumInteriorRings() + 1);
800  }
801  bounds.push_back(bbox.min.x);
802  bounds.push_back(bbox.min.y);
803  bounds.push_back(bbox.max.x);
804  bounds.push_back(bbox.max.y);
805 }
OGRGeometry * geom_
Definition: Types.h:90
#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:197

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


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