46 TYPE_AFFINE_SLANTX = 3,
47 TYPE_AFFINE_INTERPX = 4,
52 transform_type_t d_type = TYPE_INVALID;
62 std::vector<std::pair<double, double>> interpx_points;
63 std::vector<std::pair<std::pair<double, double>, std::pair<double, double>>> interp_xy_points;
64 std::shared_ptr<projection::VizGeorefSpline2D> interp_fwd_interpolator;
65 std::shared_ptr<projection::VizGeorefSpline2D> interp_rev_interpolator;
105 ChannelTransform &init_interp_xy(std::vector<std::pair<std::pair<double, double>, std::pair<double, double>>> interp_xy_points);
110 j[
"type"] = (int)v.d_type;
112 if (v.d_type == TYPE_AFFINE || v.d_type == TYPE_AFFINE_SLANTX || v.d_type == TYPE_AFFINE_INTERPX)
114 j[
"ax"] = v.affine_a_x;
115 j[
"ay"] = v.affine_a_y;
116 j[
"bx"] = v.affine_b_x;
117 j[
"by"] = v.affine_b_y;
120 if (v.d_type == TYPE_AFFINE_SLANTX)
122 j[
"slantx_center"] = v.slantx_center;
123 j[
"slantx_ampli"] = v.slantx_ampli;
126 if (v.d_type == TYPE_AFFINE_INTERPX)
128 j[
"interpx_points"] = v.interpx_points;
131 if (v.d_type == TYPE_INTERP_XY)
133 j[
"interp_xy_points"] = v.interp_xy_points;
139 v.d_type = (transform_type_t)j[
"type"].get<int>();
141 if (v.d_type == TYPE_AFFINE || v.d_type == TYPE_AFFINE_SLANTX || v.d_type == TYPE_AFFINE_INTERPX)
143 v.affine_a_x = j[
"ax"];
144 v.affine_a_y = j[
"ay"];
145 v.affine_b_x = j[
"bx"];
146 v.affine_b_y = j[
"by"];
149 if (v.d_type == TYPE_AFFINE_SLANTX)
151 v.slantx_center = j[
"slantx_center"];
152 v.slantx_ampli = j[
"slantx_ampli"];
155 if (v.d_type == TYPE_AFFINE_INTERPX)
157 v.interpx_points = j[
"interpx_points"].get<std::vector<std::pair<double, double>>>();
159 v.interp_fwd_interpolator = std::make_shared<projection::VizGeorefSpline2D>(1);
160 v.interp_rev_interpolator = std::make_shared<projection::VizGeorefSpline2D>(1);
162 for (
auto &p : v.interpx_points)
164 v.interp_fwd_interpolator->add_point(p.first, p.first, &p.second);
165 v.interp_rev_interpolator->add_point(p.second, p.second, &p.first);
168 v.interp_fwd_interpolator->solve();
169 v.interp_rev_interpolator->solve();
172 if (v.d_type == TYPE_INTERP_XY)
174 v.interp_xy_points = j[
"interp_xy_points"].get<std::vector<std::pair<std::pair<double, double>, std::pair<double, double>>>>();
176 v.interp_fwd_interpolator = std::make_shared<projection::VizGeorefSpline2D>(2);
177 v.interp_rev_interpolator = std::make_shared<projection::VizGeorefSpline2D>(2);
179 for (
auto &p : v.interp_xy_points)
181 printf(
"Point %f %f => %f %f\n", p.first.first, p.first.second, p.second.first, p.second.second);
182 double p1[2] = {p.second.first, p.second.second};
183 v.interp_fwd_interpolator->add_point(p.first.first, p.first.second, p1);
184 double p2[2] = {p.first.first, p.first.second};
185 v.interp_rev_interpolator->add_point(p.second.first, p.second.second, p2);
188 printf(
"%d %d\n", v.interp_fwd_interpolator->solve(), v.interp_rev_interpolator->solve());
210 inline void forward(
double *x,
double *y)
const
212 if (d_type == TYPE_NONE)
214 else if (d_type == TYPE_AFFINE)
216 *x = *x * affine_a_x + affine_b_x;
217 *y = *y * affine_a_y + affine_b_y;
219 else if (d_type == TYPE_AFFINE_SLANTX)
221 *y -= (*x - slantx_center) * slantx_ampli;
222 *x = *x * affine_a_x + affine_b_x;
223 *y = *y * affine_a_y + affine_b_y;
225 else if (d_type == TYPE_AFFINE_INTERPX)
227 *x = *x * affine_a_x + affine_b_x;
228 *y = *y * affine_a_y + affine_b_y;
229 interp_fwd_interpolator->get_point(*x, *x, x);
231 else if (d_type == TYPE_INTERP_XY)
235 interp_fwd_interpolator->get_point(*x, *y, out);
240 else if (d_type == TYPE_INVALID)
241 throw satdump_exception(
"Invalid Channel Transform!\n");
249 inline void reverse(
double *x,
double *y)
const
251 if (d_type == TYPE_NONE)
253 else if (d_type == TYPE_AFFINE)
255 *x = (*x - affine_b_x) / affine_a_x;
256 *y = (*y - affine_b_y) / affine_a_y;
258 else if (d_type == TYPE_AFFINE_SLANTX)
260 *x = (*x - affine_b_x) / affine_a_x;
261 *y = (*y - affine_b_y) / affine_a_y;
262 *y += (*x - slantx_center) * slantx_ampli;
264 else if (d_type == TYPE_AFFINE_INTERPX)
266 interp_rev_interpolator->get_point(*x, *x, x);
267 *x = (*x - affine_b_x) / affine_a_x;
268 *y = (*y - affine_b_y) / affine_a_y;
270 else if (d_type == TYPE_INTERP_XY)
273 printf(
"%f %f REV => ", *x, *y);
274 interp_rev_interpolator->get_point(*x, *y, out);
277 printf(
"%f %f\n ", *x, *y);
279 else if (d_type == TYPE_INVALID)
280 throw satdump_exception(
"Invalid Channel Transform!\n");