23 #include <grass/gis.h>
24 #include <grass/Vect.h>
25 #include <grass/glocale.h>
27 static int lookup(
const char *
file,
const char *key,
char *
value,
size_t len);
39 fprintf(stdout,
"\nSelected information from dig header\n");
91 sprintf(buf,
"%s/%s", GRASS_VECT_DIRECTORY, Map->name);
93 head_fp =
G_fopen_new(buf, GRASS_VECT_HEAD_ELEMENT);
94 if (head_fp ==
NULL) {
95 G_warning(_(
"Unable to open header file of vector <%s>"),
139 G_debug(1,
"Vect__read_head(): vector = %s@%s", Map->name, Map->mapset);
140 sprintf(buff,
"%s/%s", GRASS_VECT_DIRECTORY, Map->name);
141 head_fp =
G_fopen_old(buff, GRASS_VECT_HEAD_ELEMENT, Map->mapset);
142 if (head_fp ==
NULL) {
143 G_warning(_(
"Unable to open header file of vector <%s>"),
148 while (
G_getl2(buff, 2000, head_fp)) {
150 if (!(ptr =
G_index(buff,
':'))) {
151 G_warning(_(
"Corrupted row in head: %s"), buff);
159 if (strncmp(buff,
"ORGANIZATION:",
sizeof(
char) * 12) == 0)
161 else if (strncmp(buff,
"DIGIT DATE:",
sizeof(
char) * 11) == 0)
163 else if (strncmp(buff,
"DIGIT NAME:",
sizeof(
char) * 11) == 0)
165 else if (strncmp(buff,
"MAP NAME:",
sizeof(
char) * 9) == 0)
167 else if (strncmp(buff,
"MAP DATE:",
sizeof(
char) * 9) == 0)
169 else if (strncmp(buff,
"MAP SCALE:",
sizeof(
char) * 10) == 0)
171 else if (strncmp(buff,
"OTHER INFO:",
sizeof(
char) * 11) == 0)
173 else if (strncmp(buff,
"PROJ:",
sizeof(
char) * 5) == 0)
174 G_debug(1,
"Projection code for map is %s", ptr);
175 else if (strncmp(buff,
"ZONE:",
sizeof(
char) * 5) == 0 ||
176 strncmp(buff,
"UTM ZONE:",
sizeof(
char) * 9) == 0)
178 else if (strncmp(buff,
"WEST EDGE:",
sizeof(
char) * 10) == 0) {
180 else if (strncmp(buff,
"EAST EDGE:",
sizeof(
char) * 10) == 0) {
182 else if (strncmp(buff,
"SOUTH EDGE:",
sizeof(
char) * 11) == 0) {
184 else if (strncmp(buff,
"NORTH EDGE:",
sizeof(
char) * 11) == 0) {
186 else if (strncmp(buff,
"MAP THRESH:",
sizeof(
char) * 11) == 0)
189 G_warning(_(
"Unknown keyword %s in vector head"), buff);
217 return (Map->mapset);
231 ptr = (
char *)G_malloc(strlen(Map->name) + strlen(Map->mapset) + 2);
232 sprintf(ptr,
"%s@%s", Map->name, Map->mapset);
246 return (Map->head.with_z);
259 G_free(Map->head.organization);
260 Map->head.organization =
G_store(str);
274 return (Map->head.organization);
307 return (Map->head.date);
320 G_free(Map->head.your_name);
321 Map->head.your_name =
G_store(str);
334 return (Map->head.your_name);
347 G_free(Map->head.map_name);
348 Map->head.map_name =
G_store(str);
361 return (Map->head.map_name);
374 G_free(Map->head.source_date);
375 Map->head.source_date =
G_store(str);
388 return (Map->head.source_date);
401 Map->head.orig_scale = scale;
414 return ((
int)Map->head.orig_scale);
428 Map->head.line_3 =
G_store(str);
441 return (Map->head.line_3);
454 Map->head.plani_zone = zone;
468 return (Map->head.plani_zone);
515 if (!lookup(PROJECTION_FILE,
"name", name,
sizeof(name)))
516 strcpy(name, _(
"Unknown projection"));
531 G_debug(1,
"Vect_set_thresh(): thresh = %f", thresh);
532 Map->head.digit_thresh = thresh;
545 G_debug(1,
"Vect_get_thresh(): thresh = %f", Map->head.digit_thresh);
546 return (Map->head.digit_thresh);
551 static int lookup(
const char *
file,
const char *key,
char *
value,
size_t len)
553 char path[GPATH_MAX];
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void G_free(void *buf)
Free allocated memory.
char * G_store(const char *s)
Copy string to allocated memory.
char * G_index(const char *str, int delim)
delimiter
int G_lookup_key_value_from_file(const char *file, const char *key, char value[], int n)
Look up for key in file.
int G_getl2(char *buf, int n, FILE *fd)
gets a line of text from a file of any pedigree
char * G__file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int G_debug(int level, const char *msg,...)
Print debugging message.
char * G__projection_name(int n)
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.