23 #define MAX_LENGTH 1000 87 double min_corner_x = 0.0;
88 double min_corner_y = 0.0;
89 double resolution_x = 0.0;
90 double resolution_y = 0.0;
91 int number_pixel_x = 0;
92 int number_pixel_y = 0;
97 char origin_code_string[3] = {0,0,0};
99 char pix_reg_code_string[7] = {0,0,0,0,0,0,0};
101 int min_corner_x_found = 0;
102 int min_corner_y_found = 0;
103 int resolution_x_found = 0;
104 int resolution_y_found = 0;
105 int number_pixel_x_found = 0;
106 int number_pixel_y_found = 0;
107 int origin_code_found = 0;
108 int pix_reg_code_found = 0;
114 if (Filename == NULL) {
122 if (Map_info == NULL) {
130 fp = fopen(Filename,
"r");
140 if (line[0] ==
'#')
continue;
142 if (1 == sscanf(line,
"min_corner_x = %lf",&min_corner_x)) {
143 min_corner_x_found = 1;
144 }
else if (1 == sscanf(line,
"min_corner_y = %lf",&min_corner_y)) {
145 min_corner_y_found = 1;
146 }
else if (1 == sscanf(line,
"resolution_x = %lf",&resolution_x)) {
147 resolution_x_found = 1;
148 }
else if (1 == sscanf(line,
"resolution_y = %lf",&resolution_y)) {
149 resolution_y_found = 1;
150 }
else if (1 == sscanf(line,
"number_pixel_x = %d",&number_pixel_x)) {
151 number_pixel_x_found = 1;
152 }
else if (1 == sscanf(line,
"number_pixel_y = %d",&number_pixel_y)) {
153 number_pixel_y_found = 1;
154 }
else if (1 == sscanf(line,
"origin_code = %2s",origin_code_string)) {
155 origin_code_found = 1;
156 }
else if (1 == sscanf(line,
"pix_reg_code = %6s",pix_reg_code_string)) {
157 pix_reg_code_found = 1;
182 if (!min_corner_x_found) {
185 if (!min_corner_y_found) {
188 if (!resolution_x_found) {
191 if (!resolution_y_found) {
194 if (!number_pixel_x_found) {
197 if (!number_pixel_y_found) {
200 if (!origin_code_found) {
203 if (!pix_reg_code_found) {
213 }
else if (0 ==
strncasecmp(
"UR",origin_code_string,2)) {
215 }
else if (0 ==
strncasecmp(
"LL",origin_code_string,2)) {
217 }
else if (0 ==
strncasecmp(
"LR",origin_code_string,2)) {
220 fprintf(stderr,
"Unrecognized origin_code: %2s\n",origin_code_string);
228 if (0 ==
strncasecmp(
"CENTER",pix_reg_code_string,6)) {
230 }
else if (0 ==
strncasecmp(
"CORNER",pix_reg_code_string,6)) {
233 fprintf(stderr,
"Unrecognized pix_reg_code: %6s\n",pix_reg_code_string);
241 status =
MtkGenericMapInfo(min_corner_x, min_corner_y, resolution_x, resolution_y,
242 number_pixel_x, number_pixel_y, origin_code,
243 pix_reg_code, &map_info_tmp);
250 *Map_info = map_info_tmp;
MTKt_OriginCode
Origin code.
#define MTK_ERR_CODE_JUMP(code)
MTKt_PixRegCode
Pixel registration code.
MTKt_status MtkGenericMapInfoRead(const char *Filename, MTKt_GenericMapInfo *Map_info)
Initialize a MTKt_GenericMapInfo structure using data from an external file.
#define MTK_ERR_CODE_MSG_JUMP(code, msg)
int strncasecmp(const char *s1, const char *s2, size_t n)
#define MTK_ERR_COND_JUMP(code)
#define MTKT_GENERICMAPINFO_INIT
MTKt_status MtkGenericMapInfo(double Min_x, double Min_y, double Resolution_x, double Resolution_y, int Number_pixel_x, int Number_pixel_y, MTKt_OriginCode Origin_code, MTKt_PixRegCode Pix_reg_code, MTKt_GenericMapInfo *Map_info)
Initialize a MTKt_GenericMapInfo structure.