rewind_ogr.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*!
  2. \file lib/vector/Vlib/rewind_ogr.c
  3. \brief Vector library - rewind data (OGR)
  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 Radim Blazek, Piero Cavalieri
  9. */
  10. #include <grass/vector.h>
  11. #include <grass/glocale.h>
  12. #ifdef HAVE_OGR
  13. #include <ogr_api.h>
  14. #endif
  15. /*!
  16. \brief Rewind vector map (OGR layer) to cause reads to start at
  17. beginning (level 1)
  18. \param Map pointer to Map_info structure
  19. \return 0 on success
  20. \return -1 on error
  21. */
  22. int V1_rewind_ogr(struct Map_info *Map)
  23. {
  24. G_debug(2, "V1_rewind_ogr(): name = %s", Map->name);
  25. #ifdef HAVE_OGR
  26. struct Format_info_ogr *ogr_info;
  27. ogr_info = &(Map->fInfo.ogr);
  28. ogr_info->cache.lines_num = 0;
  29. ogr_info->cache.lines_next = 0;
  30. OGR_L_ResetReading(ogr_info->layer);
  31. return 0;
  32. #else
  33. G_fatal_error(_("GRASS is not compiled with OGR support"));
  34. return -1;
  35. #endif
  36. }
  37. /*!
  38. \brief Rewind vector map (OGR layer) to cause reads to start at
  39. beginning on topological level (level 2)
  40. \param Map pointer to Map_info structure
  41. \return 0 on success
  42. \return -1 on error
  43. */
  44. int V2_rewind_ogr(struct Map_info *Map)
  45. {
  46. G_debug(2, "V2_rewind_ogr(): name = %s", Map->name);
  47. #ifdef HAVE_OGR
  48. Map->next_line = 1;
  49. V1_rewind_ogr(Map);
  50. return 0;
  51. #else
  52. G_fatal_error(_("GRASS is not compiled with OGR support"));
  53. return -1;
  54. #endif
  55. }