rewind.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*!
  2. \file lib/vector/Vlib/rewind.c
  3. \brief Vector library - rewind data
  4. Higher level functions for reading/writing/manipulating vectors.
  5. (C) 2001-2009, 2011-2012 by the GRASS Development Team
  6. This program is free software under the GNU General Public License
  7. (>=v2). Read the file COPYING that comes with GRASS for details.
  8. \author Original author CERL, probably Dave Gerdes or Mike Higgins.
  9. \author Update to GRASS 5.7 Radim Blazek and David D. Gray.
  10. \author Level 3 by Martin Landa <landa.martin gmail.com>
  11. */
  12. #include <grass/vector.h>
  13. #include <grass/glocale.h>
  14. static int rew_dummy()
  15. {
  16. return -1;
  17. }
  18. #if !defined HAVE_OGR || !defined HAVE_POSTGRES
  19. static int format()
  20. {
  21. G_fatal_error(_("Requested format is not compiled in this version"));
  22. return 0;
  23. }
  24. #endif
  25. static int (*Rewind_array[][4]) () = {
  26. {
  27. rew_dummy, V1_rewind_nat, V2_rewind_nat, rew_dummy}
  28. #ifdef HAVE_OGR
  29. , {
  30. rew_dummy, V1_rewind_ogr, V2_rewind_ogr, rew_dummy}
  31. , {
  32. rew_dummy, V1_rewind_ogr, V2_rewind_ogr, rew_dummy}
  33. #else
  34. , {
  35. rew_dummy, format, format, rew_dummy}
  36. , {
  37. rew_dummy, format, format, rew_dummy}
  38. #endif
  39. #ifdef HAVE_POSTGRES
  40. , {
  41. rew_dummy, V1_rewind_pg, V2_rewind_pg, V2_rewind_pg}
  42. #else
  43. , {
  44. rew_dummy, format, format, rew_dummy}
  45. #endif
  46. };
  47. /*!
  48. \brief Rewind vector map to cause reads to start at beginning
  49. \param Map pointer to Map_info structure
  50. \return 0 on success
  51. \return -1 on error
  52. */
  53. int Vect_rewind(struct Map_info *Map)
  54. {
  55. if (!VECT_OPEN(Map))
  56. return -1;
  57. G_debug(1, "Vect_Rewind(): name = %s level = %d", Map->name, Map->level);
  58. return (*Rewind_array[Map->format][Map->level]) (Map);
  59. }