00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <grass/gis.h>
00018 #include <grass/glocale.h>
00019 #include "G.h"
00020
00021 int G_get_set_window (struct Cell_head *window)
00022 {
00023 G__init_window() ;
00024 G_copy((char *) window, (char *) &G__.window, sizeof(*window) ) ;
00025
00026 return 1;
00027 }
00028
00029 int G_set_window (struct Cell_head *window)
00030 {
00031 int i;
00032 int maskfd;
00033 char *err;
00034
00035
00036
00037
00038
00039
00040
00041 if ((err = G_adjust_Cell_head (window, 0,0)))
00042 {
00043 G_warning ("G_set_window(): %s", err);
00044 return -1;
00045 }
00046
00047
00048
00049
00050 maskfd = G__.auto_mask > 0 ? G__.mask_fd : - 1;
00051 for (i = 0; i < G__.fileinfo_count; i++)
00052 {
00053 if (G__.fileinfo[i].open_mode == OPEN_OLD)
00054 {
00055 if (G__.fileinfo[i].cellhd.zone == window->zone &&
00056 G__.fileinfo[i].cellhd.proj == window->proj)
00057 continue;
00058 if (i != maskfd)
00059 {
00060 G_warning (_("G_set_window(): projection/zone differs from that of currently open raster files"));
00061 return -1;
00062 }
00063 }
00064 }
00065
00066
00067 if (G__.auto_mask > 0)
00068 {
00069 G_close_cell (maskfd);
00070
00071 G__.mask_fd = -1;
00072 G__.auto_mask = -1;
00073 }
00074
00075
00076 G_copy ((char *) &G__.window, (char *) window, sizeof (*window));
00077
00078 G__.window_set = 1;
00079
00080
00081
00082
00083
00084
00085 for (i = 0; i < G__.fileinfo_count; i++)
00086 {
00087 if(G__.fileinfo[i].open_mode != OPEN_OLD &&
00088 G__.fileinfo[i].open_mode != OPEN_NEW_UNCOMPRESSED &&
00089 G__.fileinfo[i].open_mode != OPEN_NEW_COMPRESSED &&
00090 G__.fileinfo[i].open_mode != OPEN_NEW_RANDOM)
00091 continue;
00092
00093 if (G__.fileinfo[i].open_mode == OPEN_OLD)
00094 G__create_window_mapping (i);
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 }
00123
00124
00125 G__check_for_auto_masking ();
00126
00127
00128 G__reallocate_null_buf();
00129 G__reallocate_mask_buf();
00130 G__reallocate_temp_buf();
00131 G__reallocate_work_buf(sizeof(DCELL));
00132 G__reallocate_work_buf(XDR_DOUBLE_NBYTES);
00133
00134
00135
00136 return 1;
00137 }