OmniSciDB  a5dc49c757
 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 71 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().

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

Referenced by compute_bounds_of_coords().