OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
import_export::GCPTransformer Class Reference

#include <RasterImporter.h>

Public Types

enum  Mode { Mode::kPolynomial, Mode::kThinPlateSpline }
 

Public Member Functions

 GCPTransformer (OGRDataSource *datasource, const Mode mode=Mode::kPolynomial)
 
 GCPTransformer ()=delete
 
 ~GCPTransformer ()
 
void transform (double &x, double &y)
 

Private Attributes

void * transform_arg_
 
Mode mode_
 

Detailed Description

Definition at line 40 of file RasterImporter.h.

Member Enumeration Documentation

Enumerator
kPolynomial 
kThinPlateSpline 

Definition at line 42 of file RasterImporter.h.

42 { kPolynomial, kThinPlateSpline };

Constructor & Destructor Documentation

import_export::GCPTransformer::GCPTransformer ( OGRDataSource *  datasource,
const Mode  mode = Mode::kPolynomial 
)
explicit

Definition at line 46 of file RasterImporter.cpp.

47  : transform_arg_{nullptr}, mode_{mode} {
48  CHECK(datasource);
49  auto const gcp_count = datasource->GetGCPCount();
50  auto const* gcp_list = datasource->GetGCPs();
51  switch (mode_) {
52  case Mode::kPolynomial: {
53  static constexpr int kPolynomialOrder = 2;
55  GDALCreateGCPTransformer(gcp_count, gcp_list, kPolynomialOrder, false);
56  break;
57  }
59  transform_arg_ = GDALCreateTPSTransformer(gcp_count, gcp_list, false);
60  break;
61  }
62  }
64 }
#define CHECK(condition)
Definition: Logger.h:222
import_export::GCPTransformer::GCPTransformer ( )
delete
import_export::GCPTransformer::~GCPTransformer ( )

Definition at line 66 of file RasterImporter.cpp.

References kPolynomial, kThinPlateSpline, mode_, and transform_arg_.

66  {
67  switch (mode_) {
68  case Mode::kPolynomial:
69  GDALDestroyGCPTransformer(transform_arg_);
70  break;
72  GDALDestroyTPSTransformer(transform_arg_);
73  break;
74  }
75 }

Member Function Documentation

void import_export::GCPTransformer::transform ( double &  x,
double &  y 
)

Definition at line 77 of file RasterImporter.cpp.

References kPolynomial, kThinPlateSpline, mode_, and transform_arg_.

77  {
78  int success{0};
79  switch (mode_) {
80  case Mode::kPolynomial:
81  GDALGCPTransform(transform_arg_, false, 1, &x, &y, nullptr, &success);
82  break;
84  GDALTPSTransform(transform_arg_, false, 1, &x, &y, nullptr, &success);
85  break;
86  }
87  if (!success) {
88  throw std::runtime_error("Failed GCP/TPS Transform");
89  }
90 }

Member Data Documentation

Mode import_export::GCPTransformer::mode_
private

Definition at line 52 of file RasterImporter.h.

Referenced by transform(), and ~GCPTransformer().

void* import_export::GCPTransformer::transform_arg_
private

Definition at line 51 of file RasterImporter.h.

Referenced by transform(), and ~GCPTransformer().


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