init_head.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*!
  2. \file vector/Vlib/init_head.c
  3. \brief Vector library - init header of vector maps
  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. \author Various updates by Martin Landa <landa.martin gmail.com>, 2009
  13. */
  14. #include <grass/config.h>
  15. #include <string.h>
  16. #include <grass/gis.h>
  17. #include <grass/vector.h>
  18. /*!
  19. \brief Initialize Map_info head structure (dig_head)
  20. \param[in,out] Map pointer to Map_info structure
  21. */
  22. void Vect__init_head(struct Map_info *Map)
  23. {
  24. char buf[64];
  25. /* organization */
  26. Map->head.organization = NULL;
  27. Vect_set_organization(Map, "");
  28. /* date */
  29. Map->head.date = NULL;
  30. Vect_set_date(Map, "");
  31. /* user name */
  32. Map->head.your_name = NULL;
  33. sprintf(buf, "%s", G_whoami());
  34. Vect_set_person(Map, buf);
  35. /* map name */
  36. Map->head.map_name = NULL;
  37. Vect_set_map_name(Map, "");
  38. /* source date */
  39. Map->head.source_date = NULL;
  40. sprintf(buf, "%s", G_date());
  41. Vect_set_map_date(Map, buf);
  42. /* comments */
  43. Map->head.line_3 = NULL;
  44. Vect_set_comment(Map, "");
  45. /* scale, threshold */
  46. Vect_set_scale(Map, 1);
  47. Vect_set_thresh(Map, 0.0);
  48. /* proj, zone */
  49. Vect_set_proj(Map, -1);
  50. Vect_set_zone(Map, -1);
  51. /* support variables */
  52. Map->plus.Spidx_built = 0;
  53. Map->plus.release_support = 0;
  54. Map->plus.update_cidx = 0;
  55. }
  56. /*!
  57. \brief Copy header data from one to another map
  58. \param from target vector map
  59. \param[out] to destination vector map
  60. \return 0
  61. */
  62. int Vect_copy_head_data(const struct Map_info *from, struct Map_info *to)
  63. {
  64. Vect_set_organization(to, Vect_get_organization(from));
  65. Vect_set_date(to, Vect_get_date(from));
  66. Vect_set_person(to, Vect_get_person(from));
  67. Vect_set_map_name(to, Vect_get_map_name(from));
  68. Vect_set_map_date(to, Vect_get_map_date(from));
  69. Vect_set_comment(to, Vect_get_comment(from));
  70. Vect_set_scale(to, Vect_get_scale(from));
  71. Vect_set_zone(to, Vect_get_zone(from));
  72. Vect_set_thresh(to, Vect_get_thresh(from));
  73. return 0;
  74. }