OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{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{Types.cpp}::process_poly_ring ( OGRLinearRing *  ring,
std::vector< double > &  coords,
BoundingBox *  bbox 
)

Definition at line 70 of file Types.cpp.

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

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

72  {
73  double last_x = DOUBLE_MAX, last_y = DOUBLE_MAX;
74  size_t first_index = coords.size();
75  int num_points_added = 0;
76  int num_points_in_ring = ring->getNumPoints();
77  if (num_points_in_ring < 3) {
79  "PolyRing",
80  "All poly rings must have more than 3 points. Found ring with " +
81  std::to_string(num_points_in_ring) + " points.");
82  }
83  for (auto i = 0; i < num_points_in_ring; i++) {
84  OGRPoint point;
85  ring->getPoint(i, &point);
86  last_x = point.getX();
87  last_y = point.getY();
88  coords.push_back(last_x);
89  coords.push_back(last_y);
90  if (bbox) {
91  bbox->update(last_x, last_y);
92  }
93  num_points_added++;
94  }
95  // Store all rings as open rings (implicitly assumes all rings are closed)
96  if ((coords[first_index] == last_x) && (coords[first_index + 1] == last_y)) {
97  coords.pop_back();
98  coords.pop_back();
99  num_points_added--;
100  if (num_points_added < 3) {
102  "PolyRing",
103  "All exterior rings must have more than 3 points. Found ring with " +
104  std::to_string(num_points_added) + " points.");
105  }
106  }
107  return num_points_added;
108 }
constexpr auto DOUBLE_MAX
Definition: Types.cpp:40
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{Types.cpp}::DOUBLE_MAX = std::numeric_limits<double>::max()

Definition at line 40 of file Types.cpp.

Referenced by compute_bounds_of_coords(), and process_poly_ring().

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

Definition at line 41 of file Types.cpp.

Referenced by compute_bounds_of_coords().