OmniSciDB  a5dc49c757
 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 47 of file RasterImporter.cpp.

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

Definition at line 67 of file RasterImporter.cpp.

References kPolynomial, kThinPlateSpline, mode_, and transform_arg_.

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

Member Function Documentation

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

Definition at line 78 of file RasterImporter.cpp.

References kPolynomial, kThinPlateSpline, mode_, and transform_arg_.

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

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: