/*! \brief Initialize Map_info head structure (dig_head) \param[in,out] Map pointer to Map_info structure */ void Vect__init_head(struct Map_info *Map) { char buf[64]; /* organization */ Map->head.organization = NULL; Vect_set_organization(Map, ""); /* date */ Map->head.date = NULL; Vect_set_date(Map, ""); /* user name */ Map->head.user_name = NULL; sprintf(buf, "%s", G_whoami()); Vect_set_person(Map, buf); /* map name */ Map->head.map_name = NULL; Vect_set_map_name(Map, ""); /* source date */ Map->head.source_date = NULL; sprintf(buf, "%s", G_date()); Vect_set_map_date(Map, buf); /* comments */ Map->head.comment = NULL; Vect_set_comment(Map, ""); /* scale, threshold */ Vect_set_scale(Map, 1); Vect_set_thresh(Map, 0.0); /* proj, zone */ Vect_set_proj(Map, -1); Vect_set_zone(Map, -1); /* support variables */ Map->plus.Spidx_built = 0; Map->plus.release_support = 0; Map->plus.update_cidx = 0; }
/*! \brief Reads head information from text file (GV_HEAD_ELEMENT) - for internal use only \param Map pointer to Map_info structure \return 0 on success \return -1 on error */ int Vect__read_head(struct Map_info *Map) { FILE *head_fp; char buff[2000]; char *path, *ptr; /* Reset / init */ Vect__init_head(Map); G_debug(1, "Vect__read_head(): vector = %s@%s", Map->name, Map->mapset); path = Vect__get_path(Map); head_fp = G_fopen_old(path, GV_HEAD_ELEMENT, Map->mapset); G_free(path); if (head_fp == NULL) { G_warning(_("Unable to open header file of vector <%s>"), Vect_get_full_name(Map)); return -1; } while (G_getl2(buff, 2000, head_fp)) { if (!(ptr = strchr(buff, ':'))) { G_warning(_("Corrupted row in head: %s"), buff); continue; } ptr++; /* Search for the start of text */ while (*ptr == ' ') ptr++; if (strncmp(buff, "ORGANIZATION:", sizeof(char) * 12) == 0) Vect_set_organization(Map, ptr); else if (strncmp(buff, "DIGIT DATE:", sizeof(char) * 11) == 0) Vect_set_date(Map, ptr); else if (strncmp(buff, "DIGIT NAME:", sizeof(char) * 11) == 0) Vect_set_person(Map, ptr); else if (strncmp(buff, "MAP NAME:", sizeof(char) * 9) == 0) Vect_set_map_name(Map, ptr); else if (strncmp(buff, "MAP DATE:", sizeof(char) * 9) == 0) Vect_set_map_date(Map, ptr); else if (strncmp(buff, "MAP SCALE:", sizeof(char) * 10) == 0) Vect_set_scale(Map, atoi(ptr)); else if (strncmp(buff, "OTHER INFO:", sizeof(char) * 11) == 0) Vect_set_comment(Map, ptr); else if (strncmp(buff, "PROJ:", sizeof(char) * 5) == 0) Vect_set_proj(Map, atoi(ptr)); else if (strncmp(buff, "ZONE:", sizeof(char) * 5) == 0 || strncmp(buff, "UTM ZONE:", sizeof(char) * 9) == 0) Vect_set_zone(Map, atoi(ptr)); else if (strncmp(buff, "WEST EDGE:", sizeof(char) * 10) == 0) { } else if (strncmp(buff, "EAST EDGE:", sizeof(char) * 10) == 0) { } else if (strncmp(buff, "SOUTH EDGE:", sizeof(char) * 11) == 0) { } else if (strncmp(buff, "NORTH EDGE:", sizeof(char) * 11) == 0) { } else if (strncmp(buff, "MAP THRESH:", sizeof(char) * 11) == 0) Vect_set_thresh(Map, atof(ptr)); else G_warning(_("Unknown keyword '%s' in vector head"), buff); } fclose(head_fp); return 0; }