OmniSciDB  85c2d10cdc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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
}
 
enum  GeoOp {
  GeoOp::kPROJECTION = 0, GeoOp::kINTERSECTION = 1, GeoOp::kDIFFERENCE = 2, GeoOp::kUNION = 3,
  GeoOp::kBUFFER = 4, GeoOp::kISVALID = 5, GeoOp::kISEMPTY = 6
}
 

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
 

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 createFromWkb (const std::vector< uint8_t > &wkb, OGRGeometry **geom)
 

Protected Attributes

OGRGeometry * geom_ = nullptr
 
bool owns_geom_obj_
 

Friends

class GeoTypesFactory
 

Detailed Description

Definition at line 45 of file Types.h.

Member Enumeration Documentation

Enumerator
kPROJECTION 
kINTERSECTION 
kDIFFERENCE 
kUNION 
kBUFFER 
kISVALID 
kISEMPTY 

Definition at line 60 of file Types.h.

60  {
61  kPROJECTION = 0,
62  kINTERSECTION = 1,
63  kDIFFERENCE = 2,
64  kUNION = 3,
65  kBUFFER = 4,
66  kISVALID = 5,
67  kISEMPTY = 6
68  };
Enumerator
kPOINT 
kLINESTRING 
kPOLYGON 
kMULTIPOLYGON 
kGEOMETRY 
kGEOMETRYCOLLECTION 

Definition at line 52 of file Types.h.

52  {
53  kPOINT,
55  kPOLYGON,
57  kGEOMETRY,
58  kGEOMETRYCOLLECTION
59  };

Constructor & Destructor Documentation

Geospatial::GeoBase::GeoBase ( )
inline

Definition at line 47 of file Types.h.

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

Definition at line 145 of file Types.cpp.

References geom_, and owns_geom_obj_.

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

Definition at line 88 of file Types.h.

89  : geom_(geom), owns_geom_obj_(owns_geom_obj) {}
OGRGeometry * geom_
Definition: Types.h:90
bool owns_geom_obj_
Definition: Types.h:91

Member Function Documentation

OGRErr Geospatial::GeoBase::createFromWkb ( const std::vector< uint8_t > &  wkb,
OGRGeometry **  geom 
)
staticprotected

Definition at line 173 of file Types.cpp.

References CHECK.

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

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

+ Here is the caller graph for this function:

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

Definition at line 154 of file Types.cpp.

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

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

+ Here is the caller graph for this function:

int32_t Geospatial::GeoBase::getBestPlanarSRID ( ) const

Definition at line 226 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.

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

Definition at line 70 of file Types.h.

References geom_.

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

70 { return geom_; }
OGRGeometry * geom_
Definition: Types.h:90

+ 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 307 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().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Geospatial::GeoBase::getWkb ( std::vector< uint8_t > &  wkb) const

Definition at line 186 of file Types.cpp.

References geom_.

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

Definition at line 164 of file Types.cpp.

References CHECK, and geom_.

Referenced by GeoWktSerializer< kPOINT >::serialize(), GeoWktSerializer< kLINESTRING >::serialize(), GeoWktSerializer< kPOLYGON >::serialize(), and GeoWktSerializer< kMULTIPOLYGON >::serialize().

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

+ Here is the caller graph for this function:

bool Geospatial::GeoBase::isEmpty ( ) const

Definition at line 196 of file Types.cpp.

References geom_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 200 of file Types.cpp.

References geom_.

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

Definition at line 439 of file Types.cpp.

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

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

+ 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 406 of file Types.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 497 of file Types.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 521 of file Types.cpp.

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

521  {
522  auto result = false;
523  switch (op) {
525  result = geom_->IsValid();
526  break;
528  result = isEmpty();
529  break;
530  default:
531  break;
532  }
533  return result;
534 }
OGRGeometry * geom_
Definition: Types.h:90
bool isEmpty() const
Definition: Types.cpp:196

+ Here is the call graph for this function:

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

Definition at line 383 of file Types.cpp.

References geom_, and getTransformation().

Referenced by transform().

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

+ 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 392 of file Types.cpp.

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

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

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class GeoTypesFactory
friend

Definition at line 96 of file Types.h.

Member Data Documentation

bool Geospatial::GeoBase::owns_geom_obj_
protected

Definition at line 91 of file Types.h.

Referenced by ~GeoBase().


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