19#define LL_TOLERANCE 10
23static double llepsilon = 0.01;
24static double fpepsilon = 1.0e-9;
26static int ll_wrap(
struct Cell_head *cellhd);
27static int ll_check_ns(
struct Cell_head *cellhd);
28static int ll_check_ew(
struct Cell_head *cellhd);
61 if (cellhd->
rows <= 0)
63 " (resolution is %g)"),
72 if (cellhd->
cols <= 0)
74 " (resolution is %g)"),
82 " but %g (north) <= %g (south"),
86 " but %g (north) <= %g (south"),
94 " but %g (east) <= %g (west)"),
101 if (cellhd->
rows == 0)
107 if (cellhd->
cols == 0)
111 if (cellhd->
cols < 0) {
112 G_fatal_error(
_(
"Invalid coordinates: negative number of columns"));
114 if (cellhd->
rows < 0) {
177 if (cellhd->
rows <= 0)
179 " (resolution is %g)"),
181 if (cellhd->
rows3 <= 0)
183 " (resolution is %g)"),
195 if (cellhd->
cols <= 0)
197 " (resolution is %g)"),
199 if (cellhd->
cols3 <= 0)
201 " (resolution is %g)"),
218 " but %g (north) <= %g (south"),
222 " but %g (north) <= %g (south"),
230 " but %g (east) <= %g (west)"),
235 " but %g (top) <= %g (bottom)"),
242 if (cellhd->
rows == 0)
248 if (cellhd->
rows3 == 0)
254 if (cellhd->
cols == 0)
259 if (cellhd->
cols3 == 0)
270 if (cellhd->
cols < 0 || cellhd->
cols3 < 0) {
271 G_fatal_error(
_(
"Invalid coordinates: negative number of columns"));
273 if (cellhd->
rows < 0 || cellhd->
rows3 < 0) {
277 G_fatal_error(
_(
"Invalid coordinates: negative number of depths"));
302static int ll_wrap(
struct Cell_head *cellhd)
311 G_warning(
_(
"East (%.15g) is not larger than West (%.15g)"),
314 while (cellhd->
east <= cellhd->
west)
315 cellhd->
east += 360.0;
324 while (cellhd->
west + shift >= 180) {
327 while (cellhd->
east + shift <= -180) {
332 while (cellhd->
east + shift > 360) {
335 while (cellhd->
west + shift <= -360) {
340 cellhd->
west += shift;
341 cellhd->
east += shift;
365static int ll_check_ns(
struct Cell_head *cellhd)
377 G_debug(3,
"ll_check_ns: epsilon: %g", llepsilon);
386 _(
"NS extent does not match NS resolution: %g cells difference"),
394 if (cellhd->
north < 90.0 &&
diff < 1.0) {
398 _(
"Subtle input data rounding error of north boundary (%g)"),
399 cellhd->
north - 90.0);
406 if (cellhd->
north > 90.0) {
407 if (
diff <= 0.5 + llepsilon) {
414 cellhd->
north - 90.0);
415 G_debug(1,
"North of north in seconds: %g",
416 (cellhd->
north - 90.0) * 3600);
430 G_debug(1,
"North of north + 0.5 cells in seconds: %g",
431 (cellhd->
north - 90.0 - cellhd->
ns_res / 2.0) * 3600);
446 if (cellhd->
south > -90.0 &&
diff < 1.0) {
450 _(
"Subtle input data rounding error of south boundary (%g)"),
451 cellhd->
south + 90.0);
458 if (cellhd->
south < -90.0) {
459 if (
diff <= 0.5 + llepsilon) {
467 G_debug(1,
"South of south in seconds: %g",
468 (-cellhd->
south - 90) * 3600);
482 G_debug(1,
"South of south + 0.5 cells in seconds: %g",
483 (-cellhd->
south - 90 - cellhd->
ns_res / 2.0) * 3600);
500static int ll_check_ew(
struct Cell_head *cellhd)
512 G_debug(3,
"ll_check_ew: epsilon: %g", llepsilon);
520 _(
"EW extent does not match EW resolution: %g cells difference"),
523 if (cellhd->
east - cellhd->
west > 360.0) {
525 if (
diff > fpepsilon)
527 " (East: %g, West: %g)"),
530 else if (cellhd->
east - cellhd->
west < 360.0) {
534 _(
"%g cells missing to cover 360 degree EW extent"),
diff);
556 char buf[100],
buf2[100];
600 snprintf(buf,
sizeof(buf),
"%f", old);
605 snprintf(buf,
sizeof(buf),
"%f", old);
610 snprintf(buf,
sizeof(buf),
"%f", old);
615 snprintf(buf,
sizeof(buf),
"%f", old);
620 snprintf(buf,
sizeof(buf),
"%f", old);
625 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)