47 static struct vector D_to_A_conv;
48 static struct vector A_to_U_conv;
49 static struct vector U_to_D_conv;
52 static int is_lat_lon;
55 static void calc_size(
struct rect *rect)
57 rect->size.x = rect->east - rect->west;
58 rect->size.y = rect->south - rect->north;
61 static void calc_conv(
struct vector *conv,
62 const struct vector *src,
const struct vector *
dst)
64 conv->x = dst->x / src->x;
65 conv->y = dst->y / src->y;
68 static void fit_aspect(
struct rect *rect,
const struct rect *ref)
71 double scale, size, delta;
73 calc_conv(&conv, &rect->size, &ref->size);
75 if (fabs(conv.y) > fabs(conv.x)) {
76 scale = fabs(conv.y) / fabs(conv.x);
77 size = rect->size.x / scale;
78 delta = rect->size.x - size;
79 rect->west += delta/2;
80 rect->east -= delta/2;
84 scale = fabs(conv.x) / fabs(conv.y);
85 size = rect->size.y / scale;
86 delta = rect->size.y - size;
87 rect->north += delta/2;
88 rect->south -= delta/2;
95 calc_conv(&D_to_A_conv, &
D.size, &A.size);
96 calc_conv(&A_to_U_conv, &A.size, &U.size);
97 calc_conv(&U_to_D_conv, &U.size, &
D.size);
113 " D_w %10.1f D_e %10.1f D_s %10.1f D_n %10.1f\n",
114 D.west,
D.east,
D.south,
D.north);
116 " A_w %10.1f A_e %10.1f A_s %10.1f A_n %10.1f\n",
117 A.west, A.east, A.south, A.north);
119 " U_w %10.1f U_e %10.1f U_s %10.1f U_n %10.1f\n",
120 U.west, U.east, U.south, U.north);
123 " D_x %10.1f D_y %10.1f\n" "\n",
D.size.x,
D.size.y);
125 " A_x %10.1f A_y %10.1f\n" "\n", A.size.x, A.size.y);
127 " U_x %10.1f U_y %10.1f\n" "\n", U.size.x, U.size.y);
129 fprintf(stderr,
" D_to_A_conv.x %10.1f D_to_A_conv.y %10.1f \n",
130 D_to_A_conv.x, D_to_A_conv.y);
131 fprintf(stderr,
" A_to_U_conv.x %10.1f A_to_U_conv.y %10.1f \n",
132 A_to_U_conv.x, A_to_U_conv.y);
133 fprintf(stderr,
" U_to_D_conv.x %10.1f U_to_D_conv.y %10.1f \n",
134 U_to_D_conv.x, U_to_D_conv.y);
153 double t,
double b,
double l,
double r)
292 x[0][0] = (int)A.west;
293 x[0][1] = (
int)A.east;
294 x[1][0] = (int)A.north;
295 x[1][1] = (
int)A.south;
318 return A.north + (D_row -
D.north) * D_to_A_conv.y;
334 return A.west + (D_col -
D.west) * D_to_A_conv.x;
350 return U.north + (D_row -
D.north) / U_to_D_conv.y;
366 return U.west + (D_col -
D.west) / U_to_D_conv.x;
382 return U.north + (A_row - A.north) * A_to_U_conv.y;
399 return U.west + (A_col - A.west) * A_to_U_conv.x;
415 return D.north + (A_row - A.north) / D_to_A_conv.y;
432 return D.west + (A_col - A.west) / D_to_A_conv.x;
448 return D.north + (U_row - U.north) * U_to_D_conv.y;
464 return D.west + (U_col - U.west) * U_to_D_conv.x;
480 return A.north + (U_row - U.north) / A_to_U_conv.y;
496 return A.west + (U_col - U.west) / A_to_U_conv.x;
double D_d_to_a_col(double D_col)
screen to array (x)
double D_u_to_a_row(double U_row)
earth to array (north)
double D_get_a_east(void)
double D_get_d_to_u_xconv(void)
void D_set_src(double t, double b, double l, double r)
void D_get_dst(double *t, double *b, double *l, double *r)
returns frame bounds in destination coordinate system
double D_get_d_to_a_xconv(void)
2D/3D raster map header (used also for region)
double D_get_u_to_d_yconv(void)
double west
Extent coordinates (west)
double D_a_to_u_row(double A_row)
array to earth (row)
double D_d_to_a_row(double D_row)
screen to array (y)
void D_get_grid(int *t, int *b, int *l, int *r)
double D_d_to_u_col(double D_col)
screen to earth (x)
double D_get_d_west(void)
double D_get_u_north(void)
double D_get_a_to_d_xconv(void)
double D_get_a_south(void)
double D_get_ew_resolution(void)
double D_get_a_west(void)
double D_get_u_east(void)
double north
Extent coordinates (north)
double D_get_d_east(void)
double D_get_d_north(void)
void D_set_grid(int t, int b, int l, int r)
double D_u_to_d_col(double U_col)
earth to screen (east)
void D_get_u(double x[2][2])
double south
Extent coordinates (south)
double D_get_a_north(void)
double D_get_ns_resolution(void)
#define PROJECTION_LL
Projection code - Latitude-Longitude.
void D_do_conversions(const struct Cell_head *window, double t, double b, double l, double r)
initialize conversions
double D_get_d_to_u_yconv(void)
double D_get_a_to_d_yconv(void)
double D_get_u_south(void)
double D_u_to_a_col(double U_col)
earth to array (east
double D_a_to_d_row(double A_row)
array to screen (row)
double D_get_u_to_a_xconv(void)
void D_show_conversions(void)
void D_update_conversions(void)
double D_get_a_to_u_yconv(void)
void D_set_dst(double t, double b, double l, double r)
double D_get_d_south(void)
double D_get_u_to_d_xconv(void)
int cols
Number of columns for 2D data.
double D_a_to_u_col(double A_col)
array to earth (column)
double D_get_d_to_a_yconv(void)
double east
Extent coordinates (east)
double D_get_a_to_u_xconv(void)
double D_d_to_u_row(double D_row)
screen to earth (y)
void D_get_d(double x[2][2])
void D_get_a(int x[2][2])
int rows
Number of rows for 2D data.
double D_u_to_d_row(double U_row)
earth to screen (north)
void D_set_region(const struct Cell_head *window)
double D_get_u_west(void)
double D_a_to_d_col(double A_col)
array to screen (column)
void D_get_src(double *t, double *b, double *l, double *r)
returns frame bounds in source coordinate system
double D_get_u_to_a_yconv(void)