1 /*! 2 \file lib/vector/Vlib/rewind_ogr.c 3 4 \brief Vector library - rewind data (OGR) 5 6 Higher level functions for reading/writing/manipulating vectors. 7 8 (C) 2001-2009, 2011 by the GRASS Development Team 9 10 This program is free software under the GNU General Public License 11 (>=v2). Read the file COPYING that comes with GRASS for details. 12 13 \author Radim Blazek, Piero Cavalieri 14 */ 15 16 #include <grass/vector.h> 17 #include <grass/glocale.h> 18 19 #ifdef HAVE_OGR 20 #include <ogr_api.h> 21 #endif 22 23 /*! 24 \brief Rewind vector map (OGR layer) to cause reads to start at 25 beginning (level 1) 26 27 \param Map pointer to Map_info structure 28 29 \return 0 on success 30 \return -1 on error 31 */ V1_rewind_ogr(struct Map_info * Map)32int V1_rewind_ogr(struct Map_info *Map) 33 { 34 G_debug(2, "V1_rewind_ogr(): name = %s", Map->name); 35 #ifdef HAVE_OGR 36 struct Format_info_ogr *ogr_info; 37 38 ogr_info = &(Map->fInfo.ogr); 39 40 ogr_info->cache.lines_num = 0; 41 ogr_info->cache.lines_next = 0; 42 43 OGR_L_ResetReading(ogr_info->layer); 44 45 return 0; 46 #else 47 G_fatal_error(_("GRASS is not compiled with OGR support")); 48 return -1; 49 #endif 50 } 51 52 /*! 53 \brief Rewind vector map (OGR layer) to cause reads to start at 54 beginning on topological level (level 2) 55 56 \param Map pointer to Map_info structure 57 58 \return 0 on success 59 \return -1 on error 60 */ V2_rewind_ogr(struct Map_info * Map)61int V2_rewind_ogr(struct Map_info *Map) 62 { 63 G_debug(2, "V2_rewind_ogr(): name = %s", Map->name); 64 #ifdef HAVE_OGR 65 Map->next_line = 1; 66 67 V1_rewind_ogr(Map); 68 69 return 0; 70 #else 71 G_fatal_error(_("GRASS is not compiled with OGR support")); 72 return -1; 73 #endif 74 } 75