17#define LL_TOLERANCE 10
21static double llepsilon = 0.01;
22static double fpepsilon = 1.0e-9;
24static int ll_wrap(
struct Cell_head *cellhd);
25static int ll_check_ns(
struct Cell_head *cellhd);
26static int ll_check_ew(
struct Cell_head *cellhd);
59 if (cellhd->
rows <= 0)
61 " (resolution is %g)"),
70 if (cellhd->
cols <= 0)
72 " (resolution is %g)"),
80 " but %g (north) <= %g (south"),
84 " but %g (north) <= %g (south"),
92 " but %g (east) <= %g (west)"),
99 if (cellhd->
rows == 0)
105 if (cellhd->
cols == 0)
109 if (cellhd->
cols < 0) {
110 G_fatal_error(
_(
"Invalid coordinates: negative number of columns"));
112 if (cellhd->
rows < 0) {
175 if (cellhd->
rows <= 0)
177 " (resolution is %g)"),
179 if (cellhd->
rows3 <= 0)
181 " (resolution is %g)"),
193 if (cellhd->
cols <= 0)
195 " (resolution is %g)"),
197 if (cellhd->
cols3 <= 0)
199 " (resolution is %g)"),
216 " but %g (north) <= %g (south"),
220 " but %g (north) <= %g (south"),
228 " but %g (east) <= %g (west)"),
233 " but %g (top) <= %g (bottom)"),
240 if (cellhd->
rows == 0)
246 if (cellhd->
rows3 == 0)
252 if (cellhd->
cols == 0)
257 if (cellhd->
cols3 == 0)
268 if (cellhd->
cols < 0 || cellhd->
cols3 < 0) {
269 G_fatal_error(
_(
"Invalid coordinates: negative number of columns"));
271 if (cellhd->
rows < 0 || cellhd->
rows3 < 0) {
275 G_fatal_error(
_(
"Invalid coordinates: negative number of depths"));
300static int ll_wrap(
struct Cell_head *cellhd)
309 G_warning(
_(
"East (%.15g) is not larger than West (%.15g)"),
312 while (cellhd->
east <= cellhd->
west)
313 cellhd->
east += 360.0;
322 while (cellhd->
west + shift >= 180) {
325 while (cellhd->
east + shift <= -180) {
330 while (cellhd->
east + shift > 360) {
333 while (cellhd->
west + shift <= -360) {
338 cellhd->
west += shift;
339 cellhd->
east += shift;
363static int ll_check_ns(
struct Cell_head *cellhd)
375 G_debug(3,
"ll_check_ns: epsilon: %g", llepsilon);
384 _(
"NS extent does not match NS resolution: %g cells difference"),
392 if (cellhd->
north < 90.0 &&
diff < 1.0) {
396 _(
"Subtle input data rounding error of north boundary (%g)"),
397 cellhd->
north - 90.0);
404 if (cellhd->
north > 90.0) {
405 if (
diff <= 0.5 + llepsilon) {
412 cellhd->
north - 90.0);
413 G_debug(1,
"North of north in seconds: %g",
414 (cellhd->
north - 90.0) * 3600);
428 G_debug(1,
"North of north + 0.5 cells in seconds: %g",
429 (cellhd->
north - 90.0 - cellhd->
ns_res / 2.0) * 3600);
444 if (cellhd->
south > -90.0 &&
diff < 1.0) {
448 _(
"Subtle input data rounding error of south boundary (%g)"),
449 cellhd->
south + 90.0);
456 if (cellhd->
south < -90.0) {
457 if (
diff <= 0.5 + llepsilon) {
465 G_debug(1,
"South of south in seconds: %g",
466 (-cellhd->
south - 90) * 3600);
480 G_debug(1,
"South of south + 0.5 cells in seconds: %g",
481 (-cellhd->
south - 90 - cellhd->
ns_res / 2.0) * 3600);
498static int ll_check_ew(
struct Cell_head *cellhd)
510 G_debug(3,
"ll_check_ew: epsilon: %g", llepsilon);
518 _(
"EW extent does not match EW resolution: %g cells difference"),
521 if (cellhd->
east - cellhd->
west > 360.0) {
523 if (
diff > fpepsilon)
525 " (East: %g, West: %g)"),
528 else if (cellhd->
east - cellhd->
west < 360.0) {
532 _(
"%g cells missing to cover 360 degree EW extent"),
diff);
554 char buf[100],
buf2[100];
598 snprintf(buf,
sizeof(buf),
"%f", old);
603 snprintf(buf,
sizeof(buf),
"%f", old);
608 snprintf(buf,
sizeof(buf),
"%f", old);
613 snprintf(buf,
sizeof(buf),
"%f", old);
618 snprintf(buf,
sizeof(buf),
"%f", old);
623 snprintf(buf,
sizeof(buf),
"%f", old);
void G_adjust_Cell_head3(struct Cell_head *cellhd, int row_flag, int col_flag, int depth_flag)
Adjust cell header for 3D values.
void G_adjust_Cell_head(struct Cell_head *cellhd, int row_flag, int col_flag)
Adjust cell header.
int G_adjust_window_ll(struct Cell_head *cellhd)
Adjust window for lat/lon.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
void G_lat_format(double, char *)
void G_lon_format(double, char *)
int G_lon_scan(const char *, double *)
void void G_verbose_message(const char *,...) __attribute__((format(printf
void G_llres_format(double, char *)
void void void G_important_message(const char *,...) __attribute__((format(printf
int G_lat_scan(const char *, double *)
int G_llres_scan(const char *, double *)
int G_debug(int, const char *,...) __attribute__((format(printf
#define PROJECTION_LL
Projection code - Latitude-Longitude.
2D/3D raster map header (used also for region)
int cols3
Number of columns for 3D data.
double ew_res
Resolution - east to west cell size for 2D data.
double north
Extent coordinates (north)
double bottom
Extent coordinates (bottom) - 3D data.
int depths
number of depths for 3D data
double east
Extent coordinates (east)
double ew_res3
Resolution - east to west cell size for 3D data.
double ns_res
Resolution - north to south cell size for 2D data.
double ns_res3
Resolution - north to south cell size for 3D data.
double top
Extent coordinates (top) - 3D data.
int rows3
Number of rows for 3D data.
int rows
Number of rows for 2D data.
int cols
Number of columns for 2D data.
double south
Extent coordinates (south)
double tb_res
Resolution - top to bottom cell size for 3D data.
double west
Extent coordinates (west)