rewind.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 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. */
  11. #include <grass/vector.h>
  12. #include <grass/glocale.h>
  13. static int rew_dummy()
  14. {
  15. return -1;
  16. }
  17. #if !defined HAVE_OGR || !defined HAVE_POSTGRES
  18. static int format()
  19. {
  20. G_fatal_error(_("Requested format is not compiled in this version"));
  21. return 0;
  22. }
  23. #endif
  24. static int (*Rewind_array[][3]) () = {
  25. {
  26. rew_dummy, V1_rewind_nat, V2_rewind_nat}
  27. #ifdef HAVE_OGR
  28. , {
  29. rew_dummy, V1_rewind_ogr, V2_rewind_ogr}
  30. , {
  31. rew_dummy, V1_rewind_ogr, V2_rewind_ogr}
  32. #else
  33. , {
  34. rew_dummy, format, format}
  35. , {
  36. rew_dummy, format, format}
  37. #endif
  38. #ifdef HAVE_POSTGRES
  39. , {
  40. rew_dummy, V1_rewind_pg, V2_rewind_pg}
  41. #else
  42. , {
  43. rew_dummy, format, format}
  44. #endif
  45. };
  46. /*!
  47. \brief Rewind vector map to cause reads to start at beginning
  48. \param Map pointer to Map_info structure
  49. \return 0 on success
  50. \return -1 on error
  51. */
  52. int Vect_rewind(struct Map_info *Map)
  53. {
  54. if (!VECT_OPEN(Map))
  55. return -1;
  56. G_debug(1, "Vect_Rewind(): name = %s", Map->name);
  57. return (*Rewind_array[Map->format][Map->level]) (Map);
  58. }