init_head.c 2.1 KB

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