45 static struct vector D_to_A_conv;
46 static struct vector A_to_U_conv;
47 static struct vector U_to_D_conv;
50 static int is_lat_lon;
52 static void calc_size(
struct rect *rect)
54 rect->size.x = rect->east - rect->west;
55 rect->size.y = rect->south - rect->north;
58 static void calc_conv(
struct vector *conv,
const struct vector *
src,
59 const struct vector *
dst)
65 static void fit_aspect(
struct rect *rect,
const struct rect *ref)
68 double scale, size, delta;
70 calc_conv(&conv, &rect->size, &ref->size);
72 if (fabs(conv.y) > fabs(conv.x)) {
73 scale = fabs(conv.y) / fabs(conv.x);
74 size = rect->size.x / scale;
75 delta = rect->size.x - size;
76 rect->west += delta / 2;
77 rect->east -= delta / 2;
81 scale = fabs(conv.x) / fabs(conv.y);
82 size = rect->size.y / scale;
83 delta = rect->size.y - size;
84 rect->north += delta / 2;
85 rect->south -= delta / 2;
92 calc_conv(&D_to_A_conv, &
D.size, &A.size);
93 calc_conv(&A_to_U_conv, &A.size, &U.size);
94 calc_conv(&U_to_D_conv, &U.size, &
D.size);
109 fprintf(stderr,
" D_w %10.1f D_e %10.1f D_s %10.1f D_n %10.1f\n",
D.west,
110 D.east,
D.south,
D.north);
111 fprintf(stderr,
" A_w %10.1f A_e %10.1f A_s %10.1f A_n %10.1f\n", A.west,
112 A.east, A.south, A.north);
113 fprintf(stderr,
" U_w %10.1f U_e %10.1f U_s %10.1f U_n %10.1f\n\n",
114 U.west, U.east, U.south, U.north);
116 fprintf(stderr,
" D_x %10.1f D_y %10.1f\n",
D.size.x,
D.size.y);
117 fprintf(stderr,
" A_x %10.1f A_y %10.1f\n", A.size.x, A.size.y);
118 fprintf(stderr,
" U_x %10.1f U_y %10.1f\n\n", U.size.x, U.size.y);
120 fprintf(stderr,
" D_to_A_conv.x %10.1f D_to_A_conv.y %10.1f\n",
121 D_to_A_conv.x, D_to_A_conv.y);
122 fprintf(stderr,
" A_to_U_conv.x %10.1f A_to_U_conv.y %10.1f\n",
123 A_to_U_conv.x, A_to_U_conv.y);
124 fprintf(stderr,
" U_to_D_conv.x %10.1g U_to_D_conv.y %10.1g\n",
125 U_to_D_conv.x, U_to_D_conv.y);
162 return (D_to_A_conv.x);
166 return (D_to_A_conv.y);
170 return (1 / U_to_D_conv.x);
174 return (1 / U_to_D_conv.y);
178 return (A_to_U_conv.x);
182 return (A_to_U_conv.y);
186 return (1 / D_to_A_conv.x);
190 return (1 / D_to_A_conv.y);
194 return (U_to_D_conv.x);
198 return (U_to_D_conv.y);
202 return (1 / A_to_U_conv.x);
206 return (1 / A_to_U_conv.y);
363 x[0][0] = (int)A.west;
364 x[0][1] = (
int)A.east;
365 x[1][0] = (int)A.north;
366 x[1][1] = (
int)A.south;
389 return A.north + (D_row -
D.north) * D_to_A_conv.y;
404 return A.west + (D_col -
D.west) * D_to_A_conv.x;
419 return U.north + (D_row -
D.north) / U_to_D_conv.y;
434 return U.west + (D_col -
D.west) / U_to_D_conv.x;
449 return U.north + (A_row - A.north) * A_to_U_conv.y;
465 return U.west + (A_col - A.west) * A_to_U_conv.x;
480 return D.north + (A_row - A.north) / D_to_A_conv.y;
496 return D.west + (A_col - A.west) / D_to_A_conv.x;
511 return D.north + (U_row - U.north) * U_to_D_conv.y;
526 return D.west + (U_col - U.west) * U_to_D_conv.x;
541 return A.north + (U_row - U.north) / A_to_U_conv.y;
556 return A.west + (U_col - U.west) / A_to_U_conv.x;
void D_get_src(double *t, double *b, double *l, double *r)
returns frame bounds in source coordinate system
double D_get_a_south(void)
double D_get_d_to_u_yconv(void)
double D_get_d_to_a_xconv(void)
double D_get_a_north(void)
double D_get_u_to_d_yconv(void)
double D_u_to_a_col(double U_col)
earth to array (east
void D_get_grid(int *t, int *b, int *l, int *r)
double D_d_to_a_col(double D_col)
screen to array (x)
double D_a_to_d_col(double A_col)
array to screen (column)
double D_d_to_u_col(double D_col)
screen to earth (x)
double D_u_to_a_row(double U_row)
earth to array (north)
double D_get_u_south(void)
double D_get_d_south(void)
double D_a_to_u_col(double A_col)
array to earth (column)
double D_get_u_to_a_yconv(void)
double D_get_ns_resolution(void)
void D_set_dst(double t, double b, double l, double r)
double D_get_a_west(void)
void D_set_grid(int t, int b, int l, int r)
double D_get_d_west(void)
double D_get_a_to_d_xconv(void)
double D_u_to_d_col(double U_col)
earth to screen (east)
double D_a_to_d_row(double A_row)
array to screen (row)
double D_get_ew_resolution(void)
void D_get_u(double x[2][2])
void D_show_conversions(void)
double D_get_d_north(void)
double D_get_u_east(void)
void D_get_dst(double *t, double *b, double *l, double *r)
returns frame bounds in destination coordinate system
void D_set_src(double t, double b, double l, double r)
void D_update_conversions(void)
double D_get_a_east(void)
double D_get_a_to_u_yconv(void)
double D_get_u_to_a_xconv(void)
double D_d_to_a_row(double D_row)
screen to array (y)
double D_get_u_north(void)
double D_get_u_to_d_xconv(void)
void D_get_d(double x[2][2])
void D_do_conversions(const struct Cell_head *window, double t, double b, double l, double r)
initialize conversions
double D_get_d_east(void)
double D_get_a_to_u_xconv(void)
double D_get_a_to_d_yconv(void)
void D_get_a(int x[2][2])
void D_set_region(const struct Cell_head *window)
double D_a_to_u_row(double A_row)
array to earth (row)
double D_get_u_west(void)
double D_u_to_d_row(double U_row)
earth to screen (north)
double D_get_d_to_a_yconv(void)
double D_d_to_u_row(double D_row)
screen to earth (y)
double D_get_d_to_u_xconv(void)
#define PROJECTION_LL
Projection code - Latitude-Longitude.
2D/3D raster map header (used also for region)
double north
Extent coordinates (north)
double east
Extent coordinates (east)
int rows
Number of rows for 2D data.
int cols
Number of columns for 2D data.
double south
Extent coordinates (south)
double west
Extent coordinates (west)