OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
anonymous_namespace{geo_types.cpp} Namespace Reference

Classes

struct  Coords
 
struct  BoundingBox
 

Functions

int process_poly_ring (OGRLinearRing *ring, std::vector< double > &coords, BoundingBox *bbox)
 

Variables

constexpr auto DOUBLE_MAX = std::numeric_limits<double>::max()
 
constexpr auto DOUBLE_MIN = std::numeric_limits<double>::lowest()
 

Detailed Description

Note: We use dynamic_cast to convert the OGRGeometry pointer from the base class into appropriate OGR<<type>> objects in derived clases to ensure GDAL is creating the proper geometry type for all possibly inputs. Since we check the output type after creating a new OGRGeometry object via the OGRGeometryFactor, we could theoretically move some dynamic_cast to static_cast. The performance impact and safety of going from RTTI to compile time casting needs to be investigated.

Function Documentation

int anonymous_namespace{geo_types.cpp}::process_poly_ring ( OGRLinearRing *  ring,
std::vector< double > &  coords,
BoundingBox *  bbox 
)

Definition at line 67 of file geo_types.cpp.

References DOUBLE_MAX, to_string(), and anonymous_namespace{geo_types.cpp}::BoundingBox::update().

Referenced by Geo_namespace::GeoPolygon::getColumns(), and Geo_namespace::GeoMultiPolygon::getColumns().

69  {
70  double last_x = DOUBLE_MAX, last_y = DOUBLE_MAX;
71  size_t first_index = coords.size();
72  int num_points_added = 0;
73  int num_points_in_ring = ring->getNumPoints();
74  if (num_points_in_ring < 3) {
76  "PolyRing",
77  "All poly rings must have more than 3 points. Found ring with " +
78  std::to_string(num_points_in_ring) + " points.");
79  }
80  for (auto i = 0; i < num_points_in_ring; i++) {
81  OGRPoint point;
82  ring->getPoint(i, &point);
83  last_x = point.getX();
84  last_y = point.getY();
85  coords.push_back(last_x);
86  coords.push_back(last_y);
87  if (bbox) {
88  bbox->update(last_x, last_y);
89  }
90  num_points_added++;
91  }
92  // Store all rings as open rings (implicitly assumes all rings are closed)
93  if ((coords[first_index] == last_x) && (coords[first_index + 1] == last_y)) {
94  coords.pop_back();
95  coords.pop_back();
96  num_points_added--;
97  if (num_points_added < 3) {
99  "PolyRing",
100  "All exterior rings must have more than 3 points. Found ring with " +
101  std::to_string(num_points_added) + " points.");
102  }
103  }
104  return num_points_added;
105 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

constexpr auto anonymous_namespace{geo_types.cpp}::DOUBLE_MAX = std::numeric_limits<double>::max()

Definition at line 37 of file geo_types.cpp.

Referenced by compute_bounds_of_coords(), and process_poly_ring().

constexpr auto anonymous_namespace{geo_types.cpp}::DOUBLE_MIN = std::numeric_limits<double>::lowest()

Definition at line 38 of file geo_types.cpp.

Referenced by compute_bounds_of_coords().