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

#include <Types.h>

+ Inheritance diagram for Geospatial::GeoMultiLineString:
+ Collaboration diagram for Geospatial::GeoMultiLineString:

Public Member Functions

 GeoMultiLineString (const std::vector< double > &coords, const std::vector< int32_t > &linestring_sizes)
 
 GeoMultiLineString (const std::string &wkt)
 
void getColumns (std::vector< double > &coords, std::vector< int32_t > &linestring_sizes, 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

 GeoMultiLineString (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 161 of file Types.h.

Constructor & Destructor Documentation

Geospatial::GeoMultiLineString::GeoMultiLineString ( const std::vector< double > &  coords,
const std::vector< int32_t > &  linestring_sizes 
)

Definition at line 710 of file Types.cpp.

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

Referenced by clone().

711  {
712  geom_ = OGRGeometryFactory::createGeometry(OGRwkbGeometryType::wkbMultiLineString);
713  OGRMultiLineString* multilinestring = dynamic_cast<OGRMultiLineString*>(geom_);
714  CHECK(multilinestring);
715 
716  size_t coords_ctr = 0;
717  for (const auto linestring_sz : linestring_sizes) {
718  OGRLineString linestring;
719  auto next_coords_ctr = coords_ctr + 2 * linestring_sz;
720  CHECK(next_coords_ctr <= coords.size());
721  for (auto i = coords_ctr; i < next_coords_ctr; i += 2) {
722  linestring.addPoint(coords[i], coords[i + 1]);
723  }
724  coords_ctr = next_coords_ctr;
725  multilinestring->addGeometry(&linestring);
726  }
727 }
OGRGeometry * geom_
Definition: Types.h:102
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

Geospatial::GeoMultiLineString::GeoMultiLineString ( const std::string &  wkt)

Definition at line 729 of file Types.cpp.

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

729  {
730  const auto err = GeoBase::createFromWktString(wkt, &geom_);
731  if (err != OGRERR_NONE) {
732  throw GeoTypesError("MultiLineString", err);
733  }
734  CHECK(geom_);
735  if (wkbFlatten(geom_->getGeometryType()) != OGRwkbGeometryType::wkbMultiLineString) {
736  throw GeoTypesError("MultiLineString",
737  "Unexpected geometry type from WKT string: " +
738  std::string(OGRGeometryTypeToName(geom_->getGeometryType())));
739  }
740 }
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::GeoMultiLineString::GeoMultiLineString ( OGRGeometry *  geom,
const bool  owns_geom_obj 
)
inlineprotected

Definition at line 175 of file Types.h.

176  : GeoBase(geom, owns_geom_obj) {}

Member Function Documentation

std::unique_ptr< GeoBase > Geospatial::GeoMultiLineString::clone ( ) const
finalvirtual

Implements Geospatial::GeoBase.

Definition at line 705 of file Types.cpp.

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

705  {
706  CHECK(geom_);
707  return std::unique_ptr<GeoBase>(new GeoMultiLineString(geom_->clone(), true));
708 }
OGRGeometry * geom_
Definition: Types.h:102
GeoMultiLineString(const std::vector< double > &coords, const std::vector< int32_t > &linestring_sizes)
Definition: Types.cpp:710
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void Geospatial::GeoMultiLineString::getColumns ( std::vector< double > &  coords,
std::vector< int32_t > &  linestring_sizes,
std::vector< double > &  bounds 
) const

Definition at line 742 of file Types.cpp.

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

744  {
745  auto multilinestring = dynamic_cast<OGRMultiLineString*>(geom_);
746  CHECK(multilinestring);
747 
748  if (multilinestring->IsEmpty()) {
749  // until the run-time can handle empties
750  throw GeoTypesError("MultiLineString", "'EMPTY' not supported");
751  // return null bounds
752  bounds.push_back(NULL_DOUBLE);
753  bounds.push_back(NULL_DOUBLE);
754  bounds.push_back(NULL_DOUBLE);
755  bounds.push_back(NULL_DOUBLE);
756  return;
757  }
758 
759  BoundingBox bbox;
760  for (auto l = 0; l < multilinestring->getNumGeometries(); l++) {
761  const auto geom = multilinestring->getGeometryRef(l);
762  CHECK(geom);
763  const auto linestring = dynamic_cast<OGRLineString*>(geom);
764  if (!linestring) {
765  throw GeoTypesError("MultiLineString",
766  "Failed to read linestring geometry from multilinestring");
767  }
768  auto linestring_sz = linestring->getNumPoints();
769  linestring_sizes.push_back(linestring_sz);
770  for (auto i = 0; i < linestring_sz; i++) {
771  OGRPoint point;
772  linestring->getPoint(i, &point);
773  double x = point.getX();
774  double y = point.getY();
775  coords.push_back(x);
776  coords.push_back(y);
777  bbox.update(x, y);
778  }
779  }
780  bounds.push_back(bbox.min.x);
781  bounds.push_back(bbox.min.y);
782  bounds.push_back(bbox.max.x);
783  bounds.push_back(bbox.max.y);
784 }
OGRGeometry * geom_
Definition: Types.h:102
#define NULL_DOUBLE
#define CHECK(condition)
Definition: Logger.h:291
GeoType Geospatial::GeoMultiLineString::getType ( ) const
inlinefinalvirtual

Implements Geospatial::GeoBase.

Definition at line 170 of file Types.h.

References kMULTILINESTRING.

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 178 of file Types.h.


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