init_head.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*!
  2. \file init_head.c
  3. \brief Vector library - init header of vector map
  4. Higher level functions for reading/writing/manipulating vectors.
  5. Initialize Head structure. To make sure that we are not writing out
  6. garbage to a file.
  7. (C) 2001-2009 by the GRASS Development Team
  8. This program is free software under the GNU General Public License
  9. (>=v2). Read the file COPYING that comes with GRASS for details.
  10. \author Original author CERL, probably Dave Gerdes or Mike Higgins.
  11. \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  12. */
  13. #include <string.h>
  14. #include <grass/gis.h>
  15. #include <grass/Vect.h>
  16. /*!
  17. \brief Initialize head structure
  18. \param Map vector map
  19. \return 0
  20. */
  21. int Vect__init_head(struct Map_info *Map)
  22. {
  23. char buf[64];
  24. Map->head.organization = NULL;
  25. Vect_set_organization(Map, "");
  26. Map->head.date = NULL;
  27. Vect_set_date(Map, "");
  28. Map->head.your_name = NULL;
  29. sprintf(buf, "%s", G_whoami());
  30. Vect_set_person(Map, buf);
  31. Map->head.map_name = NULL;
  32. Vect_set_map_name(Map, "");
  33. Map->head.source_date = NULL;
  34. sprintf(buf, "%s", G_date());
  35. Vect_set_map_date(Map, buf);
  36. Map->head.line_3 = NULL;
  37. Vect_set_comment(Map, "");
  38. Vect_set_scale(Map, 1);
  39. Vect_set_zone(Map, 0);
  40. Vect_set_thresh(Map, 0.0);
  41. Map->plus.Spidx_built = 0;
  42. Map->plus.release_support = 0;
  43. Map->plus.update_cidx = 0;
  44. return 0;
  45. }
  46. /*!
  47. \brief Copy header data from one to another map
  48. \param from target vector map
  49. \param[out] to destination vector map
  50. \return 0
  51. */
  52. int Vect_copy_head_data(const struct Map_info *from, struct Map_info *to)
  53. {
  54. Vect_set_organization(to, Vect_get_organization(from));
  55. Vect_set_date(to, Vect_get_date(from));
  56. Vect_set_person(to, Vect_get_person(from));
  57. Vect_set_map_name(to, Vect_get_map_name(from));
  58. Vect_set_map_date(to, Vect_get_map_date(from));
  59. Vect_set_comment(to, Vect_get_comment(from));
  60. Vect_set_scale(to, Vect_get_scale(from));
  61. Vect_set_zone(to, Vect_get_zone(from));
  62. Vect_set_thresh(to, Vect_get_thresh(from));
  63. return 0;
  64. }