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

#include <Types.h>

+ Inheritance diagram for Geospatial::GeoBase:

Public Types

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
}
 

Public Member Functions

 GeoBase ()
 
virtual ~GeoBase ()
 
std::string getWktString () const
 
bool getWkb (std::vector< uint8_t > &) const
 
virtual GeoType getType () const =0
 
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
 
virtual std::unique_ptr< GeoBaseclone () const =0
 

Static Public Member Functions

static std::shared_ptr
< OGRCoordinateTransformation > 
getTransformation (int32_t srid0, int32_t srid1)
 

Protected Member Functions

 GeoBase (OGRGeometry *geom, const bool owns_geom_obj)
 

Static Protected Member Functions

static int createFromWktString (const std::string &wkt, OGRGeometry **geom)
 
static int createFromWkbView (OGRGeometry **geom, WkbView const)
 

Protected Attributes

OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Friends

class GeoTypesFactory
 

Detailed Description

Definition at line 50 of file Types.h.

Member Enumeration Documentation

Enumerator
kPROJECTION 
kINTERSECTION 
kDIFFERENCE 
kUNION 
kBUFFER 
kISVALID 
kISEMPTY 
kEQUALS 
kCONCAVEHULL 
kCONVEXHULL 

Definition at line 67 of file Types.h.

67  {
68  kPROJECTION = 0,
69  kINTERSECTION = 1,
70  kDIFFERENCE = 2,
71  kUNION = 3,
72  kBUFFER = 4,
73  kISVALID = 5,
74  kISEMPTY = 6,
75  kEQUALS = 7,
76  kCONCAVEHULL = 8,
77  kCONVEXHULL = 9
78  };
Enumerator
kPOINT 
kLINESTRING 
kPOLYGON 
kMULTIPOLYGON 
kGEOMETRY 
kGEOMETRYCOLLECTION 
kMULTILINESTRING 
kMULTIPOINT 

Definition at line 57 of file Types.h.

57  {
58  kPOINT,
60  kPOLYGON,
62  kGEOMETRY,
63  kGEOMETRYCOLLECTION,
66  };

Constructor & Destructor Documentation

Geospatial::GeoBase::GeoBase ( )
inline

Definition at line 52 of file Types.h.

52 : owns_geom_obj_(true) {}
bool owns_geom_obj_
Definition: Types.h:103
Geospatial::GeoBase::~GeoBase ( )
virtual

Definition at line 146 of file Types.cpp.

References geom_, and owns_geom_obj_.

146  {
147  // Note: Removing the geometry object that was pulled from an OGRFeature results in a
148  // segfault. If we are wrapping around a pre-existing OGRGeometry object, we let the
149  // caller manage the memory.
150  if (geom_ && owns_geom_obj_) {
151  OGRGeometryFactory::destroyGeometry(geom_);
152  }
153 }
OGRGeometry * geom_
Definition: Types.h:102
bool owns_geom_obj_
Definition: Types.h:103
Geospatial::GeoBase::GeoBase ( OGRGeometry *  geom,
const bool  owns_geom_obj 
)
inlineprotected

Definition at line 100 of file Types.h.

101  : geom_(geom), owns_geom_obj_(owns_geom_obj) {}
OGRGeometry * geom_
Definition: Types.h:102
bool owns_geom_obj_
Definition: Types.h:103

Member Function Documentation

OGRErr Geospatial::GeoBase::createFromWkbView ( OGRGeometry **  geom,
WkbView const  wkb_view 
)
staticprotected

Definition at line 174 of file Types.cpp.

References CHECK, Geospatial::WkbView::ptr_, and Geospatial::WkbView::size_.

Referenced by Geospatial::GeoTypesFactory::createGeoType(), and Geospatial::GeoTypesFactory::createOGRGeometry().

174  {
175 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 3)
176  OGRErr ogr_status =
177  OGRGeometryFactory::createFromWkb(wkb_view.ptr_, nullptr, geom, wkb_view.size_);
178  return ogr_status;
179 #else
180  CHECK(false);
181 #endif
182 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

OGRErr Geospatial::GeoBase::createFromWktString ( const std::string &  wkt,
OGRGeometry **  geom 
)
staticprotected

Definition at line 155 of file Types.cpp.

Referenced by Geospatial::GeoTypesFactory::createOGRGeometry(), Geospatial::GeoGeometryCollection::GeoGeometryCollection(), Geospatial::GeoLineString::GeoLineString(), Geospatial::GeoMultiLineString::GeoMultiLineString(), Geospatial::GeoMultiPoint::GeoMultiPoint(), Geospatial::GeoMultiPolygon::GeoMultiPolygon(), Geospatial::GeoPoint::GeoPoint(), and Geospatial::GeoPolygon::GeoPolygon().

155  {
156 #if (GDAL_VERSION_MAJOR > 2) || (GDAL_VERSION_MAJOR == 2 && GDAL_VERSION_MINOR >= 3)
157  OGRErr ogr_status = OGRGeometryFactory::createFromWkt(wkt.c_str(), nullptr, geom);
158 #else
159  auto data = (char*)wkt.c_str();
160  OGRErr ogr_status = OGRGeometryFactory::createFromWkt(&data, NULL, geom);
161 #endif
162  return ogr_status;
163 }

+ Here is the caller graph for this function:

int32_t Geospatial::GeoBase::getBestPlanarSRID ( ) const

Definition at line 227 of file Types.cpp.

References geom_, SRID_LAEA_START, SRID_NORTH_LAMBERT, SRID_NORTH_UTM_START, SRID_SOUTH_LAMBERT, SRID_SOUTH_UTM_START, and SRID_WORLD_MERCATOR.

227  {
228  if (!this->geom_) {
229  return 0;
230  }
231  double cx, cy, xwidth, ywidth;
232  OGREnvelope envelope;
233  geom_->getEnvelope(&envelope);
234  // Can't use GDAL's Centroid geom_->Centroid(OGRPoint*): requires GEOS
235  // Use center of the bounding box for now.
236  // TODO: hook up our own Centroid implementation
237  cx = (envelope.MaxX + envelope.MinX) / 2.0;
238  cy = (envelope.MaxY + envelope.MinY) / 2.0;
239  xwidth = envelope.MaxX - envelope.MinX;
240  ywidth = envelope.MaxY - envelope.MinY;
241 
242  // Arctic coords: Lambert Azimuthal Equal Area North
243  if (cy > 70.0 && ywidth < 45.0) {
244  return SRID_NORTH_LAMBERT;
245  }
246  // Antarctic coords: Lambert Azimuthal Equal Area South
247  if (cy < -70.0 && ywidth < 45.0) {
248  return SRID_SOUTH_LAMBERT;
249  }
250 
251  // Can geometry fit into a single UTM zone?
252  if (xwidth < 6.0) {
253  int zone = floor((cx + 180.0) / 6.0);
254  if (zone > 59) {
255  zone = 59;
256  }
257  // Below the equator: UTM South
258  // Above the equator: UTM North
259  if (cy < 0.0) {
260  return SRID_SOUTH_UTM_START + zone;
261  } else {
262  return SRID_NORTH_UTM_START + zone;
263  }
264  }
265 
266  // TODO: to be removed once we add custom LAEA zone transforms
267  // Can geometry still fit into 5 consecutive UTM zones?
268  // Then go for the mid-UTM zone, tolerating some limited distortion
269  // in the left and right corners. That's still better than Mercator.
270  if (xwidth < 30.0) {
271  int zone = floor((cx + 180.0) / 6.0);
272  if (zone > 59) {
273  zone = 59;
274  }
275  // Below the equator: UTM South
276  // Above the equator: UTM North
277  if (cy < 0.0) {
278  return SRID_SOUTH_UTM_START + zone;
279  } else {
280  return SRID_NORTH_UTM_START + zone;
281  }
282  }
283 
284  // Can geometry fit into a custom LAEA area 30 degrees high? Allow some overlap.
285  if (ywidth < 25.0) {
286  int xzone = -1;
287  int yzone = 3 + floor(cy / 30.0); // range of 0-5
288  if ((yzone == 2 || yzone == 3) && xwidth < 30.0) {
289  // Equatorial band, 12 zones, 30 degrees wide
290  xzone = 6 + floor(cx / 30.0);
291  } else if ((yzone == 1 || yzone == 4) && xwidth < 45.0) {
292  // Temperate band, 8 zones, 45 degrees wide
293  xzone = 4 + floor(cx / 45.0);
294  } else if ((yzone == 0 || yzone == 5) && xwidth < 90.0) {
295  // Arctic band, 4 zones, 90 degrees wide
296  xzone = 2 + floor(cx / 90.0);
297  }
298  // Found an appropriate xzone to fit in?
299  if (xzone != -1) {
300  return SRID_LAEA_START + 20 * yzone + xzone;
301  }
302  }
303 
304  // Fall-back to Mercator
305  return SRID_WORLD_MERCATOR;
306 }
OGRGeometry * geom_
Definition: Types.h:102
#define SRID_LAEA_START
Definition: Types.cpp:223
#define SRID_NORTH_UTM_START
Definition: Types.cpp:211
#define SRID_SOUTH_UTM_START
Definition: Types.cpp:217
#define SRID_SOUTH_LAMBERT
Definition: Types.cpp:221
#define SRID_WORLD_MERCATOR
Definition: Types.cpp:209
#define SRID_NORTH_LAMBERT
Definition: Types.cpp:215
const OGRGeometry* Geospatial::GeoBase::getOGRGeometry ( ) const
inline

Definition at line 80 of file Types.h.

References geom_.

Referenced by import_export::anonymous_namespace{QueryExporterGDAL.cpp}::insert_geo_column().

80 { return geom_; }
OGRGeometry * geom_
Definition: Types.h:102

+ Here is the caller graph for this function:

std::shared_ptr< OGRCoordinateTransformation > Geospatial::GeoBase::getTransformation ( int32_t  srid0,
int32_t  srid1 
)
static

Definition at line 308 of file Types.cpp.

References Geospatial::GDAL::init(), SRID_LAEA_END, SRID_LAEA_START, SRID_NORTH_LAMBERT, SRID_NORTH_UTM_END, SRID_NORTH_UTM_START, SRID_SOUTH_LAMBERT, SRID_SOUTH_UTM_END, SRID_SOUTH_UTM_START, SRID_WORLD_MERCATOR, Geospatial::transformation_map_, and Geospatial::transformation_map_mutex_.

Referenced by transform().

309  {
310  std::lock_guard<std::mutex> guard(transformation_map_mutex_);
311  std::tuple<int32_t, int32_t> key{srid0, srid1};
312  auto it = transformation_map_.find(key);
313  if (it != transformation_map_.end()) {
314  return it->second;
315  }
316  auto setSpatialReference = [&](OGRSpatialReference* sr, int32_t srid) -> bool {
317  OGRErr status = OGRERR_NONE;
318  if (srid == 4326) {
319  status = sr->importFromEPSG(4326);
320  } else if (srid == SRID_NORTH_LAMBERT) {
321  // +proj=laea +lat_0=90 +lon_0=-40 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m
322  // +no_defs
323  status = sr->importFromEPSG(3574);
324  } else if (srid == SRID_SOUTH_LAMBERT) {
325  // +proj=laea +lat_0=-90 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m
326  // +no_defs
327  status = sr->importFromEPSG(3409);
328  } else if (SRID_SOUTH_UTM_START <= srid && srid <= SRID_SOUTH_UTM_END) {
329  // +proj=utm +zone=%d +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs
330  int32_t zone = srid - SRID_SOUTH_UTM_START;
331  status = sr->importFromEPSG(32701 + zone);
332  } else if (SRID_NORTH_UTM_START <= srid && srid <= SRID_NORTH_UTM_END) {
333  // +proj=utm +zone=%d +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
334  int32_t zone = srid - SRID_NORTH_UTM_START;
335  status = sr->importFromEPSG(32601 + zone);
336  } else if (SRID_LAEA_START <= srid && srid <= SRID_LAEA_END) {
337  // TODO: add support and coordinate operations for custom Lambert zones,
338  // need to calculate lat/lon for the zone, SetCoordinateOperation in options.
339  // +proj=laea +ellps=WGS84 +datum=WGS84 +lat_0=%g +lon_0=%g +units=m +no_defs
340  // Go with Mercator for now
341  status = sr->importFromEPSG(3395);
342  } else if (srid == SRID_WORLD_MERCATOR) {
343  // +proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m
344  // +no_defs
345  status = sr->importFromEPSG(3395);
346  } else if (srid > 0) {
347  // Attempt to import from srid directly
348  status = sr->importFromEPSG(srid);
349  } else {
350  return false;
351  }
352 #if GDAL_VERSION_MAJOR >= 3
353  // GDAL 3.x (really Proj.4 6.x) now enforces lat, lon order
354  // this results in X and Y being transposed for angle-based
355  // coordinate systems. This restores the previous behavior.
356  if (status == OGRERR_NONE) {
357  sr->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
358  }
359 #endif
360  return (status == OGRERR_NONE);
361  };
362 
363  // lazy init GDAL
364  GDAL::init();
365 
366  OGRSpatialReference sr0;
367  if (!setSpatialReference(&sr0, srid0)) {
368  return nullptr;
369  }
370  OGRSpatialReference sr1;
371  if (!setSpatialReference(&sr1, srid1)) {
372  return nullptr;
373  }
374  // GDAL 3 allows specification of advanced transformations in
375  // OGRCoordinateTransformationOptions, including multi-step pipelines.
376  // GDAL 3 would be required to handle Lambert zone proj4 strings.
377  // Using a simple transform for now.
378  std::shared_ptr<OGRCoordinateTransformation> new_transformation;
379  new_transformation.reset(OGRCreateCoordinateTransformation(&sr0, &sr1));
380  transformation_map_[key] = new_transformation;
381  return new_transformation;
382 }
#define SRID_LAEA_START
Definition: Types.cpp:223
#define SRID_NORTH_UTM_END
Definition: Types.cpp:213
static void init()
Definition: GDAL.cpp:67
#define SRID_NORTH_UTM_START
Definition: Types.cpp:211
std::mutex transformation_map_mutex_
Definition: Types.cpp:115
#define SRID_SOUTH_UTM_START
Definition: Types.cpp:217
#define SRID_SOUTH_UTM_END
Definition: Types.cpp:219
#define SRID_SOUTH_LAMBERT
Definition: Types.cpp:221
#define SRID_WORLD_MERCATOR
Definition: Types.cpp:209
#define SRID_LAEA_END
Definition: Types.cpp:225
#define SRID_NORTH_LAMBERT
Definition: Types.cpp:215
std::map< std::tuple< int32_t, int32_t >, std::shared_ptr< OGRCoordinateTransformation > > transformation_map_
Definition: Types.cpp:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual GeoType Geospatial::GeoBase::getType ( ) const
pure virtual
bool Geospatial::GeoBase::getWkb ( std::vector< uint8_t > &  wkb) const

Definition at line 187 of file Types.cpp.

References geom_.

187  {
188  auto size = geom_->WkbSize();
189  if (size > 0) {
190  wkb.resize(size);
191  geom_->exportToWkb(wkbNDR, wkb.data());
192  return true;
193  }
194  return false;
195 }
OGRGeometry * geom_
Definition: Types.h:102
std::string Geospatial::GeoBase::getWktString ( ) const

Definition at line 165 of file Types.cpp.

References CHECK, and geom_.

Referenced by GeoWktSerializer< kPOINT >::serialize(), GeoWktSerializer< kMULTIPOINT >::serialize(), GeoWktSerializer< kLINESTRING >::serialize(), GeoWktSerializer< kMULTILINESTRING >::serialize(), GeoWktSerializer< kPOLYGON >::serialize(), GeoWktSerializer< kMULTIPOLYGON >::serialize(), ST_AsText__GeoLineString__cpu_(), ST_AsText__GeoMultiLineString__cpu_(), ST_AsText__GeoMultiPoint__cpu_(), ST_AsText__GeoMultiPolygon__cpu_(), ST_AsText__GeoPoint__cpu_(), and ST_AsText__GeoPolygon__cpu_().

165  {
166  char* wkt = nullptr;
167  geom_->exportToWkt(&wkt);
168  CHECK(wkt);
169  std::string wkt_str(wkt);
170  CPLFree(wkt);
171  return wkt_str;
172 }
OGRGeometry * geom_
Definition: Types.h:102
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

bool Geospatial::GeoBase::isEmpty ( ) const

Definition at line 197 of file Types.cpp.

References geom_.

Referenced by Geospatial::GeoGeometry::GeoGeometry(), Geospatial::GeoGeometryCollection::GeoGeometryCollection(), and run().

197  {
198  return geom_ && geom_->IsEmpty();
199 }
OGRGeometry * geom_
Definition: Types.h:102

+ Here is the caller graph for this function:

bool Geospatial::GeoBase::operator== ( const GeoBase other) const
virtual

Definition at line 201 of file Types.cpp.

References geom_.

201  {
202  if (!this->geom_ || !other.geom_) {
203  return false;
204  }
205  return this->geom_->Equals(other.geom_);
206 }
OGRGeometry * geom_
Definition: Types.h:102
std::unique_ptr< GeoBase > Geospatial::GeoBase::optimized_run ( GeoBase::GeoOp  op,
const GeoBase other 
) const

Definition at line 440 of file Types.cpp.

References Geospatial::GeoTypesFactory::createGeoType(), geom_, and run_benchmark_import::result.

441  {
442  OGRGeometry* result = nullptr;
443  // Loop through polys combinations, check validity, do intersections
444  // where needed, return a union of all intersections
445  auto gc1 = geom_->toGeometryCollection();
446  auto gc2 = other.geom_->toGeometryCollection();
447  if (!gc1 || !gc2 || gc1->IsEmpty() || gc2->IsEmpty()) {
448  return nullptr;
449  }
450  for (int i1 = 0; i1 < gc1->getNumGeometries(); i1++) {
451  auto g1 = gc1->getGeometryRef(i1);
452  // Validity check is very slow
453  if (!g1 || g1->IsEmpty() /*|| !g1->IsValid()*/) {
454  continue;
455  }
456  OGREnvelope ge1;
457  g1->getEnvelope(&ge1);
458  for (int i2 = 0; i2 < gc2->getNumGeometries(); i2++) {
459  auto g2 = gc2->getGeometryRef(i2);
460  // Validity check is very slow
461  if (!g2 || g2->IsEmpty() /*|| !g2->IsValid()*/) {
462  continue;
463  }
464  // Check for bounding box overlap
465  OGREnvelope ge2;
466  g2->getEnvelope(&ge2);
467  if (!ge1.Intersects(ge2)) {
468  continue;
469  }
470  // Do intersection
471  auto intermediate_result = g1->Intersection(g2);
472  if (!intermediate_result || intermediate_result->IsEmpty()) {
473  continue;
474  }
475  if (!result) {
476  result = intermediate_result;
477  } else {
478  result = result->Union(intermediate_result);
479  }
480  }
481  }
482 
483  // TODO: Need to handle empty/non-POLYGON result
484  if (!result || result->IsEmpty() ||
485  !(result->getGeometryType() == wkbPolygon ||
486  result->getGeometryType() == wkbMultiPolygon)) {
487  // throw GeoTypesError(std::string(OGRGeometryTypeToName(geom_->getGeometryType())),
488  // "Currenly don't support invalid or empty result");
489  // return GeoTypesFactory::createGeoType("POLYGON EMPTY");
490  // Not supporting EMPTY polygons, return a dot polygon
491  return GeoTypesFactory::createGeoType("MULTIPOLYGON(((0 0,0.0000001 0,0 0.0000001)))",
492  false);
493  }
494  return GeoTypesFactory::createGeoType(result, false);
495 }
OGRGeometry * geom_
Definition: Types.h:102
static std::unique_ptr< GeoBase > createGeoType(const std::string &wkt_or_wkb_hex, const bool validate_with_geos_if_available)
Definition: Types.cpp:1085

+ Here is the call graph for this function:

std::unique_ptr< GeoBase > Geospatial::GeoBase::run ( GeoBase::GeoOp  op,
const GeoBase other 
) const

Definition at line 407 of file Types.cpp.

References Geospatial::GeoTypesFactory::createGeoType(), geom_, kDIFFERENCE, kINTERSECTION, kUNION, and run_benchmark_import::result.

407  {
408  OGRGeometry* result = nullptr;
409  // Invalid geometries are derailing geo op performance,
410  // Checking validity before running an operation doesn't have lesser penalty.
411  // DOES NOT HELP: if (geom_->IsValid() && other.geom_->IsValid()) {
412  switch (op) {
414  result = geom_->Intersection(other.geom_);
415  break;
417  result = geom_->Difference(other.geom_);
418  break;
420  result = geom_->Union(other.geom_);
421  break;
422  default:
423  break;
424  }
425  // TODO: Need to handle empty/non-POLYGON result
426  if (!result || result->IsEmpty() ||
427  !(result->getGeometryType() == wkbPolygon ||
428  result->getGeometryType() == wkbMultiPolygon)) {
429  // throw GeoTypesError(std::string(OGRGeometryTypeToName(geom_->getGeometryType())),
430  // "Currenly don't support invalid or empty result");
431  // return GeoTypesFactory::createGeoType("POLYGON EMPTY");
432  // Not supporting EMPTY polygons, return a dot polygon
433  return GeoTypesFactory::createGeoType("MULTIPOLYGON(((0 0,0.0000001 0,0 0.0000001)))",
434  false);
435  }
436  return GeoTypesFactory::createGeoType(result, false);
437 }
OGRGeometry * geom_
Definition: Types.h:102
static std::unique_ptr< GeoBase > createGeoType(const std::string &wkt_or_wkb_hex, const bool validate_with_geos_if_available)
Definition: Types.cpp:1085

+ Here is the call graph for this function:

std::unique_ptr< GeoBase > Geospatial::GeoBase::run ( GeoBase::GeoOp  op,
double  param 
) const

Definition at line 498 of file Types.cpp.

References Geospatial::GeoTypesFactory::createGeoType(), geom_, kBUFFER, and run_benchmark_import::result.

498  {
499  OGRGeometry* result = nullptr;
500  switch (op) {
502  result = geom_->Buffer(param);
503  break;
504  default:
505  break;
506  }
507  // TODO: Need to handle empty/non-POLYGON result
508  if (!result || result->IsEmpty() ||
509  !(result->getGeometryType() == wkbPolygon ||
510  result->getGeometryType() == wkbMultiPolygon)) {
511  // throw GeoTypesError(std::string(OGRGeometryTypeToName(geom_->getGeometryType())),
512  // "Currenly don't support invalid or empty result");
513  // return GeoTypesFactory::createGeoType("POLYGON EMPTY");
514  // Not supporting EMPTY polygons, return a dot polygon
515  return GeoTypesFactory::createGeoType("MULTIPOLYGON(((0 0,0.0000001 0,0 0.0000001)))",
516  false);
517  }
518  return GeoTypesFactory::createGeoType(result, false);
519 }
OGRGeometry * geom_
Definition: Types.h:102
static std::unique_ptr< GeoBase > createGeoType(const std::string &wkt_or_wkb_hex, const bool validate_with_geos_if_available)
Definition: Types.cpp:1085

+ Here is the call graph for this function:

bool Geospatial::GeoBase::run ( GeoBase::GeoOp  op) const

Definition at line 522 of file Types.cpp.

References geom_, isEmpty(), kISEMPTY, kISVALID, and run_benchmark_import::result.

522  {
523  auto result = false;
524  switch (op) {
526  result = geom_->IsValid();
527  break;
529  result = isEmpty();
530  break;
531  default:
532  break;
533  }
534  return result;
535 }
OGRGeometry * geom_
Definition: Types.h:102
bool isEmpty() const
Definition: Types.cpp:197

+ Here is the call graph for this function:

bool Geospatial::GeoBase::transform ( int32_t  srid0,
int32_t  srid1 
)

Definition at line 384 of file Types.cpp.

References geom_, and getTransformation().

Referenced by transform().

384  {
385  auto coordinate_transformation = getTransformation(srid0, srid1);
386  if (!coordinate_transformation) {
387  return false;
388  }
389  auto ogr_status = geom_->transform(coordinate_transformation.get());
390  return (ogr_status == OGRERR_NONE);
391 }
OGRGeometry * geom_
Definition: Types.h:102
static std::shared_ptr< OGRCoordinateTransformation > getTransformation(int32_t srid0, int32_t srid1)
Definition: Types.cpp:308

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Geospatial::GeoBase::transform ( SQLTypeInfo ti)

Definition at line 393 of file Types.cpp.

References SQLTypeInfo::get_input_srid(), SQLTypeInfo::get_output_srid(), and transform().

393  {
394  auto srid1 = ti.get_output_srid();
395  if (srid1 == 4326) {
396  auto srid0 = ti.get_input_srid();
397  if (srid0 > 0 && srid0 != 4326) {
398  if (!transform(srid0, srid1)) {
399  return false;
400  }
401  }
402  }
403  return true;
404 }
HOST DEVICE int get_input_srid() const
Definition: sqltypes.h:395
bool transform(int32_t srid0, int32_t srid1)
Definition: Types.cpp:384
HOST DEVICE int get_output_srid() const
Definition: sqltypes.h:397

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 108 of file Types.h.

Member Data Documentation

bool Geospatial::GeoBase::owns_geom_obj_
protected

Definition at line 103 of file Types.h.

Referenced by ~GeoBase().


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