GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vector/Vlib/open.c
Go to the documentation of this file.
1 
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <unistd.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <grass/glocale.h>
27 #include <grass/gis.h>
28 #include <grass/Vect.h>
29 
30 #define MAX_OPEN_LEVEL 2
31 
32 static int open_old_dummy()
33 {
34  return 0;
35 }
36 
37 #ifndef HAVE_OGR
38 static int format()
39 {
40  G_fatal_error(_("Requested format is not compiled in this version"));
41  return 0;
42 }
43 #endif
44 
45 static int Open_level = 0;
46 
47 static int (*Open_old_array[][2]) () = {
48  {
49  open_old_dummy, V1_open_old_nat}
50 #ifdef HAVE_OGR
51  , {
52  open_old_dummy, V1_open_old_ogr}
53 #else
54  , {
55  open_old_dummy, format}
56 #endif
57 };
58 
59 static void fatal_error(int ferror, char *errmsg)
60 {
61  switch (ferror) {
62  case GV_FATAL_EXIT:
63  G_fatal_error(errmsg);
64  break;
65  case GV_FATAL_PRINT:
66  G_warning(errmsg);
67  break;
68  case GV_FATAL_RETURN:
69  break;
70  }
71 }
72 
73 
96 int Vect_set_open_level(int level)
97 {
98  Open_level = level;
99  if (Open_level < 1 || Open_level > MAX_OPEN_LEVEL) {
100  G_warning(_("Programmer requested unknown open level %d"),
101  Open_level);
102  Open_level = 0;
103  return 1;
104  }
105 
106  return 0;
107 }
108 
109 
124 int
125 Vect__open_old(struct Map_info *Map, const char *name, const char *mapset,
126  int update, int head_only)
127 {
128  char buf[GNAME_MAX + 10], buf2[GMAPSET_MAX + 10], xname[GNAME_MAX],
129  xmapset[GMAPSET_MAX], errmsg[2000];
130  FILE *fp;
131  int level, level_request, ferror;
132  int format, ret;
133  char *fmapset;
134 
135  G_debug(1, "Vect_open_old(): name = %s mapset= %s update = %d", name,
136  mapset, update);
137 
138  /* TODO: Open header for update ('dbln') */
139 
140  ferror = Vect_get_fatal_error();
141  Vect_set_fatal_error(GV_FATAL_EXIT);
142 
143  level_request = Open_level;
144  Open_level = 0;
145  Vect__init_head(Map);
146  dig_init_plus(&(Map->plus));
147 
148  if (G__name_is_fully_qualified(name, xname, xmapset)) {
149  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, xname);
150  sprintf(buf2, "%s@%s", GRASS_VECT_COOR_ELEMENT, xmapset);
151 
152  Map->name = G_store(xname);
153  Map->mapset = G_store(xmapset);
154  }
155  else {
156  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, name);
157  sprintf(buf2, "%s", GRASS_VECT_COOR_ELEMENT);
158  Map->name = G_store(name);
159 
160  if (mapset)
161  Map->mapset = G_store(mapset);
162  else
163  Map->mapset = G_store("");
164  }
165 
166  fmapset = G_find_vector2(Map->name, Map->mapset);
167  if (fmapset == NULL) {
168  sprintf(errmsg, _("Vector map <%s> not found"),
169  Vect_get_full_name(Map));
170  fatal_error(ferror, errmsg);
171  return -1;
172  }
173  Map->mapset = G_store(fmapset);
174 
175  Map->location = G_store(G_location());
176  Map->gisdbase = G_store(G_gisdbase());
177 
178  if (update && (0 != strcmp(Map->mapset, G_mapset()))) {
179  G_warning(_("Vector map which is not in the current mapset cannot be opened for update"));
180  return -1;
181  }
182 
183  /* Read vector format information */
184  format = 0;
185  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
186  G_debug(1, "open format file: '%s/%s/%s'", Map->mapset, buf,
187  GRASS_VECT_FRMT_ELEMENT);
188  fp = G_fopen_old(buf, GRASS_VECT_FRMT_ELEMENT, Map->mapset);
189  if (fp == NULL) {
190  G_debug(1, "Vector format: %d (native)", format);
191  format = GV_FORMAT_NATIVE;
192  }
193  else {
194  format = dig_read_frmt_ascii(fp, &(Map->fInfo));
195  fclose(fp);
196 
197  G_debug(1, "Vector format: %d (non-native)", format);
198  if (format < 0) {
199  sprintf(errmsg, _("Unable to open vector map <%s>"),
200  Vect_get_full_name(Map));
201  fatal_error(ferror, errmsg);
202  return -1;
203  }
204  }
205 
206  Map->format = format;
207 
208  /* Read vector head */
209  if (Vect__read_head(Map) != GRASS_OK) {
210  sprintf(errmsg,
211  _("Unable to open vector map <%s> on level %d. "
212  "Try to rebuild vector topology by v.build."),
213  Vect_get_full_name(Map), level_request);
214  G_warning(_("Unable to read head file"));
215  }
216 
217  G_debug(1, "Level request = %d", level_request);
218 
219  /* There are only 2 possible open levels, 1 and 2. Try first to open 'support' files
220  * (topo,sidx,cidx), these files are the same for all formats.
221  * If it is not possible and requested level is 2, return error,
222  * otherwise call Open_old_array[format][1], to open remaining files/sources (level 1)
223  */
224 
225  /* Try to open support files if level was not requested or requested level is 2 (format independent) */
226  if (level_request == 0 || level_request == 2) {
227  level = 2; /* We expect success */
228  /* open topo */
229  ret = Vect_open_topo(Map, head_only);
230  if (ret == 1) { /* topo file is not available */
231  G_debug(1, "Topo file for vector '%s' not available.",
232  Vect_get_full_name(Map));
233  level = 1;
234  }
235  else if (ret == -1) {
236  G_fatal_error(_("Unable to open topology file for vector map <%s>"),
237  Vect_get_full_name(Map));
238  }
239  /* open spatial index, not needed for head_only */
240  /* spatial index is not loaded anymore */
241  /*
242  if ( level == 2 && !head_only ) {
243  if ( Vect_open_spatial_index(Map) == -1 ) {
244  G_debug( 1, "Cannot open spatial index file for vector '%s'.", Vect_get_full_name (Map) );
245  dig_free_plus ( &(Map->plus) );
246  level = 1;
247  }
248  }
249  */
250  /* open category index */
251  if (level == 2) {
252  ret = Vect_cidx_open(Map, head_only);
253  if (ret == 1) { /* category index is not available */
254  G_debug(1,
255  "Category index file for vector '%s' not available.",
256  Vect_get_full_name(Map));
257  dig_free_plus(&(Map->plus)); /* free topology */
258  dig_spidx_free(&(Map->plus)); /* free spatial index */
259  level = 1;
260  }
261  else if (ret == -1) { /* file exists, but cannot be opened */
262  G_fatal_error(_("Unable to open category index file for vector map <%s>"),
263  Vect_get_full_name(Map));
264  }
265  }
266 #ifdef HAVE_OGR
267  /* Open OGR specific support files */
268  if (level == 2 && Map->format == GV_FORMAT_OGR) {
269  if (V2_open_old_ogr(Map) < 0) {
270  dig_free_plus(&(Map->plus));
271  dig_spidx_free(&(Map->plus));
272  dig_cidx_free(&(Map->plus));
273  level = 1;
274  }
275  }
276 #endif
277  if (level_request == 2 && level < 2) {
278  sprintf(errmsg,
279  _("Unable to open vector map <%s> on level %d. "
280  "Try to rebuild vector topology by v.build."),
281  Vect_get_full_name(Map), level_request);
282  fatal_error(ferror, errmsg);
283  return -1;
284  }
285  }
286  else {
287  level = 1; /* I.e. requested level is 1 */
288  }
289 
290  /* Open level 1 files / sources (format specific) */
291  if (!head_only) { /* No need to open coordinates */
292  if (0 != (*Open_old_array[format][1]) (Map, update)) { /* Cannot open */
293  if (level == 2) { /* support files opened */
294  dig_free_plus(&(Map->plus));
295  dig_spidx_free(&(Map->plus));
296  dig_cidx_free(&(Map->plus));
297  }
298  sprintf(errmsg,
299  _("Unable to open vector map <%s> on level %d. "
300  "Try to rebuild vector topology by v.build."),
301  Vect_get_full_name(Map), level_request);
302  fatal_error(ferror, errmsg);
303  return -1;
304  }
305  }
306  else {
307  Map->head.with_z = Map->plus.with_z; /* take dimension from topo */
308  }
309 
310  /* Set status */
311  Map->open = VECT_OPEN_CODE;
312  Map->level = level;
313  Map->head_only = head_only;
314  Map->support_updated = 0;
315  if (update) {
316  Map->mode = GV_MODE_RW;
317  Map->plus.mode = GV_MODE_RW;
318  }
319  else {
320  Map->mode = GV_MODE_READ;
321  Map->plus.mode = GV_MODE_READ;
322  }
323  if (head_only) {
324  Map->head_only = 1;
325  }
326  else {
327  Map->head_only = 0;
328  }
329 
330  Map->Constraint_region_flag = 0;
331  Map->Constraint_type_flag = 0;
332  G_debug(1, "Vect_open_old(): vector opened on level %d", level);
333 
334  if (level == 1) { /* without topology */
335  Map->plus.built = GV_BUILD_NONE;
336  }
337  else { /* level 2, with topology */
338  Map->plus.built = GV_BUILD_ALL; /* Highest level of topology for level 2 */
339  }
340 
341  Map->plus.do_uplist = 0;
342 
343  Map->dblnk = Vect_new_dblinks_struct();
344  Vect_read_dblinks(Map);
345 
346  /* Open history file */
347  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
348 
349  if (update) { /* native only */
350  Map->hist_fp = G_fopen_modify(buf, GRASS_VECT_HIST_ELEMENT);
351  if (Map->hist_fp == NULL) {
352  sprintf(errmsg,
353  _("Unable to open history file for vector map <%s>"),
354  Vect_get_full_name(Map));
355  fatal_error(ferror, errmsg);
356  return (-1);
357  }
358  fseek(Map->hist_fp, (long)0, SEEK_END);
359  Vect_hist_write(Map,
360  "---------------------------------------------------------------------------------\n");
361 
362  }
363  else {
364  if (Map->format == GV_FORMAT_NATIVE || Map->format == GV_FORMAT_OGR) {
365  Map->hist_fp =
366  G_fopen_old(buf, GRASS_VECT_HIST_ELEMENT, Map->mapset);
367  /* If NULL (does not exist) then Vect_hist_read() handle that */
368  }
369  else {
370  Map->hist_fp = NULL;
371  }
372  }
373 
374  if (!head_only) { /* Cannot rewind if not fully opened */
375  Vect_rewind(Map);
376  }
377 
378  /* Delete support files if native format was opened for update (not head_only) */
379  if (update && !head_only) {
380  char file_path[2000];
381  struct stat info;
382 
383  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, name);
384 
385  G__file_name(file_path, buf, GV_TOPO_ELEMENT, G_mapset());
386  if (stat(file_path, &info) == 0) /* file exists? */
387  unlink(file_path);
388 
389  G__file_name(file_path, buf, GV_SIDX_ELEMENT, G_mapset());
390  if (stat(file_path, &info) == 0) /* file exists? */
391  unlink(file_path);
392 
393  G__file_name(file_path, buf, GV_CIDX_ELEMENT, G_mapset());
394  if (stat(file_path, &info) == 0) /* file exists? */
395  unlink(file_path);
396  }
397 
398  return (level);
399 }
400 
413 int Vect_open_old(struct Map_info *Map, const char *name, const char *mapset)
414 {
415  return (Vect__open_old(Map, name, mapset, 0, 0));
416 }
417 
430 int
431 Vect_open_update(struct Map_info *Map, const char *name, const char *mapset)
432 {
433  int ret;
434 
435  ret = Vect__open_old(Map, name, mapset, 1, 0);
436 
437  if (ret > 0) {
438  Map->plus.do_uplist = 1;
439 
440  Map->plus.uplines = NULL;
441  Map->plus.n_uplines = 0;
442  Map->plus.alloc_uplines = 0;
443  Map->plus.upnodes = NULL;
444  Map->plus.n_upnodes = 0;
445  Map->plus.alloc_upnodes = 0;
446 
447  /* Build spatial index from topo */
449  }
450 
451  return ret;
452 }
453 
467 int
468 Vect_open_old_head(struct Map_info *Map, const char *name, const char *mapset)
469 {
470  return (Vect__open_old(Map, name, mapset, 0, 1));
471 }
472 
485 int
486 Vect_open_update_head(struct Map_info *Map, const char *name,
487  const char *mapset)
488 {
489  int ret;
490 
491  ret = Vect__open_old(Map, name, mapset, 1, 1);
492 
493  if (ret > 0) { /* Probably not important */
494  Map->plus.do_uplist = 1;
495 
496  Map->plus.uplines = NULL;
497  Map->plus.n_uplines = 0;
498  Map->plus.alloc_uplines = 0;
499  Map->plus.upnodes = NULL;
500  Map->plus.n_upnodes = 0;
501  Map->plus.alloc_upnodes = 0;
502  }
503 
504  return ret;
505 }
506 
517 int Vect_open_new(struct Map_info *Map, const char *name, int with_z)
518 {
519  int ret, ferror;
520  char errmsg[2000], buf[200];
521  char xname[GNAME_MAX], xmapset[GMAPSET_MAX];
522 
523  G_debug(2, "Vect_open_new(): name = %s", name);
524 
525  Vect__init_head(Map);
526  ferror = Vect_get_fatal_error();
527  Vect_set_fatal_error(GV_FATAL_EXIT);
528 
529  if (G__name_is_fully_qualified(name, xname, xmapset)) {
530  if (strcmp(xmapset, G_mapset()) != 0) {
531  sprintf(errmsg, _("%s is not in the current mapset (%s)"), name,
532  G_mapset());
533  fatal_error(ferror, errmsg);
534  }
535  name = xname;
536  }
537 
538  /* check for [A-Za-z][A-Za-z0-9_]* in name */
539  if (Vect_legal_filename(name) < 0) {
540  sprintf(errmsg, _("Vector map name is not SQL compliant"));
541  fatal_error(ferror, errmsg);
542  return (-1);
543  }
544 
545  /* Check if map already exists */
546  if (G_find_file2(GRASS_VECT_DIRECTORY, name, G_mapset()) != NULL) {
547  G_warning(_("Vector map <%s> already exists and will be overwritten"),
548  name);
549 
550  ret = Vect_delete(name);
551  if (ret == -1) {
552  sprintf(errmsg, _("Unable to delete vector map <%s>"), name);
553  fatal_error(ferror, errmsg);
554  return (-1);
555  }
556  }
557 
558  Map->name = G_store(name);
559  Map->mapset = G_store(G_mapset());
560  Map->location = G_store(G_location());
561  Map->gisdbase = G_store(G_gisdbase());
562 
563  Map->format = GV_FORMAT_NATIVE;
564 
565  if (V1_open_new_nat(Map, name, with_z) < 0) {
566  sprintf(errmsg, _("Unable to create vector map <%s>"),
567  Vect_get_full_name(Map));
568  fatal_error(ferror, errmsg);
569  return (-1);
570  }
571 
572  /* Open history file */
573  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
574  Map->hist_fp = G_fopen_new(buf, GRASS_VECT_HIST_ELEMENT);
575  if (Map->hist_fp == NULL) {
576  sprintf(errmsg, _("Unable to open history file for vector map <%s>"),
577  Vect_get_full_name(Map));
578  fatal_error(ferror, errmsg);
579  return (-1);
580  }
581 
582  Open_level = 0;
583 
584  dig_init_plus(&(Map->plus));
585 
586  Map->open = VECT_OPEN_CODE;
587  Map->level = 1;
588  Map->head_only = 0;
589  Map->support_updated = 0;
590  Map->plus.built = GV_BUILD_NONE;
591  Map->mode = GV_MODE_RW;
592  Map->Constraint_region_flag = 0;
593  Map->Constraint_type_flag = 0;
594  Map->head.with_z = with_z;
595  Map->plus.do_uplist = 0;
596 
597  Map->dblnk = Vect_new_dblinks_struct();
598 
599  return 1;
600 }
601 
611 int Vect_coor_info(struct Map_info *Map, struct Coor_info *Info)
612 {
613  char buf[2000], path[2000];
614  struct stat stat_buf;
615 
616  switch (Map->format) {
617  case GV_FORMAT_NATIVE:
618  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
619  G__file_name(path, buf, GRASS_VECT_COOR_ELEMENT, Map->mapset);
620  G_debug(1, "get coor info: %s", path);
621  if (0 != stat(path, &stat_buf)) {
622  G_warning(_("Unable to stat file <%s>"), path);
623  Info->size = -1L;
624  Info->mtime = -1L;
625  }
626  else {
627  Info->size = (long)stat_buf.st_size; /* file size */
628  Info->mtime = (long)stat_buf.st_mtime; /* last modified time */
629  }
630  /* stat does not give correct size on MINGW
631  * if the file is opened */
632 #ifdef __MINGW32__
633  if (Map->open == VECT_OPEN_CODE) {
634  dig_fseek(&(Map->dig_fp), 0L, SEEK_END);
635  G_debug(2, "ftell = %d", dig_ftell(&(Map->dig_fp)));
636  Info->size = dig_ftell(&(Map->dig_fp));
637  }
638 #endif
639  break;
640  case GV_FORMAT_OGR:
641  Info->size = 0L;
642  Info->mtime = 0L;
643  break;
644  }
645  G_debug(1, "Info->size = %ld, Info->mtime = %ld", Info->size,
646  Info->mtime);
647 
648  return 1;
649 }
650 
659 const char *Vect_maptype_info(struct Map_info *Map)
660 {
661  char maptype[1000];
662 
663  switch (Map->format) {
664  case GV_FORMAT_NATIVE:
665  sprintf(maptype, "native");
666  break;
667  case GV_FORMAT_OGR:
668  sprintf(maptype, "ogr");
669  break;
670  default:
671  sprintf(maptype, "unknown %d (update Vect_maptype_info)",
672  Map->format);
673  }
674 
675  return G_store(maptype);
676 }
677 
678 
689 int Vect_open_topo(struct Map_info *Map, int head_only)
690 {
691  int err, ret;
692  char buf[500], file_path[2000];
693  GVFILE fp;
694  struct Coor_info CInfo;
695  struct Plus_head *Plus;
696  struct stat info;
697 
698  G_debug(1, "Vect_open_topo(): name = %s mapset= %s", Map->name,
699  Map->mapset);
700 
701  Plus = &(Map->plus);
702 
703  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
704  G__file_name(file_path, buf, GV_TOPO_ELEMENT, Map->mapset);
705 
706  if (stat(file_path, &info) != 0) /* does not exist */
707  return 1;
708 
709  dig_file_init(&fp);
710  fp.file = G_fopen_old(buf, GV_TOPO_ELEMENT, Map->mapset);
711 
712  if (fp.file == NULL) { /* topo file is not available */
713  G_debug(1, "Cannot open topo file for vector '%s@%s'.",
714  Map->name, Map->mapset);
715  return -1;
716  }
717 
718  /* get coor info */
719  Vect_coor_info(Map, &CInfo);
720 
721  /* load head */
722  if (dig_Rd_Plus_head(&fp, Plus) == -1)
723  return -1;
724 
725  G_debug(1, "Topo head: coor size = %ld, coor mtime = %ld",
726  Plus->coor_size, Plus->coor_mtime);
727 
728  /* do checks */
729  err = 0;
730  if (CInfo.size != Plus->coor_size) {
731  G_warning(_("Size of 'coor' file differs from value saved in topology file"));
732  err = 1;
733  }
734  /* Do not check mtime because mtime is changed by copy */
735  /*
736  if ( CInfo.mtime != Plus->coor_mtime ) {
737  G_warning ( "Time of last modification for 'coor' file differs from value saved in topo file.\n");
738  err = 1;
739  }
740  */
741  if (err) {
742  G_warning(_("Please rebuild topology for vector map <%s@%s>"),
743  Map->name, Map->mapset);
744  return -1;
745  }
746 
747  /* load file to the memory */
748  /* dig_file_load ( &fp); */
749 
750  /* load topo to memory */
751  ret = dig_load_plus(Plus, &fp, head_only);
752 
753  fclose(fp.file);
754  /* dig_file_free ( &fp); */
755 
756  if (ret == 0)
757  return -1;
758 
759  return 0;
760 }
761 
770 int Vect_open_spatial_index(struct Map_info *Map)
771 {
772  char buf[500];
773  GVFILE fp;
774 
775  /* struct Coor_info CInfo; */
776  struct Plus_head *Plus;
777 
778  G_debug(1, "Vect_open_spatial_index(): name = %s mapset= %s", Map->name,
779  Map->mapset);
780 
781  Plus = &(Map->plus);
782 
783  sprintf(buf, "%s/%s", GRASS_VECT_DIRECTORY, Map->name);
784  dig_file_init(&fp);
785  fp.file = G_fopen_old(buf, GV_SIDX_ELEMENT, Map->mapset);
786 
787  if (fp.file == NULL) { /* spatial index file is not available */
788  G_debug(1, "Cannot open spatial index file for vector '%s@%s'.",
789  Map->name, Map->mapset);
790  return -1;
791  }
792 
793  /* TODO: checks */
794  /* load head */
795  /*
796  dig_Rd_spindx_head (fp, Plus);
797  G_debug ( 1, "Spindx head: coor size = %ld, coor mtime = %ld",
798  Plus->coor_size, Plus->coor_mtime);
799 
800  */
801  /* do checks */
802  /*
803  err = 0;
804  if ( CInfo.size != Plus->coor_size ) {
805  G_warning ( "Size of 'coor' file differs from value saved in topo file.\n");
806  err = 1;
807  }
808  */
809  /* Do not check mtime because mtime is changed by copy */
810  /*
811  if ( CInfo.mtime != Plus->coor_mtime ) {
812  G_warning ( "Time of last modification for 'coor' file differs from value saved in topo file.\n");
813  err = 1;
814  }
815  */
816  /*
817  if ( err ) {
818  G_warning ( "Please rebuild topology for vector '%s@%s'\n", Map->name,
819  Map->mapset );
820  return -1;
821  }
822  */
823 
824  /* load file to the memory */
825  /* dig_file_load ( &fp); */
826 
827  /* load topo to memory */
828  dig_spidx_init(Plus);
829  dig_read_spidx(&fp, Plus);
830 
831  fclose(fp.file);
832  /* dig_file_free ( &fp); */
833 
834  return 0;
835 }
char * G_mapset(void)
current mapset name
Definition: mapset.c:31
int dig_init_plus(struct Plus_head *Plus)
Init head structure.
Definition: plus.c:31
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void dig_spidx_free(struct Plus_head *Plus)
Free spatial index (nodes, lines, areas, isles)
Definition: spindex.c:101
int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset, int update, int head_only)
Open old vector for reading.
char * G_store(const char *s)
Copy string to allocated memory.
Definition: store.c:32
char xmapset[512]
Definition: g3dcats.c:89
string maptype
Definition: gcp/manager.py:59
int V1_open_new_nat(struct Map_info *Map, const char *name, int with_z)
Open/Create new vector map.
Definition: open_nat.c:86
int Vect_build_sidx_from_topo(struct Map_info *Map)
Create spatial index from topo if necessary.
Definition: sindex.c:144
string name
Definition: render.py:1314
int dig_spidx_init(struct Plus_head *Plus)
Initit spatial index (nodes, lines, areas, isles)
Definition: spindex.c:31
const char * err
Definition: g3dcolor.c:50
int V1_open_old_ogr(struct Map_info *Map, int update)
Open existing vector map.
Definition: open_ogr.c:45
FILE * G_fopen_modify(const char *element, const char *name)
Open a database file for update (r+ mode)
Definition: gis/open.c:279
char * G_find_vector2(const char *name, const char *mapset)
find a vector map (look but don&#39;t touch)
Definition: find_vect.c:75
const char * Vect_maptype_info(struct Map_info *Map)
Gets maptype (native, shape, postgis)
#define MAX_OPEN_LEVEL
const char * Vect_get_full_name(struct Map_info *Map)
Get full map name.
int Vect__init_head(struct Map_info *Map)
Initialize head structure.
Definition: init_head.c:35
int dig_Rd_Plus_head(GVFILE *fp, struct Plus_head *ptr)
Definition: plus_struct.c:567
int Vect_set_fatal_error(int err)
Set behaviour if fatal error occurs in some functions.
int dig_fseek(GVFILE *file, long offset, int whence)
Set GVFILE position.
Definition: file.c:60
int Vect_get_fatal_error(void)
Get behaviour for fatal error.
int stat
Definition: g3dcolor.c:369
char * G__file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
Definition: file_name.c:33
int Vect_open_topo(struct Map_info *Map, int head_only)
Open topo file.
int Vect_set_open_level(int level)
Predetermine level at which a map will be opened for reading.
int Vect_open_update(struct Map_info *Map, const char *name, const char *mapset)
Open existing vector for reading/writing.
char * G_gisdbase(void)
Get name of top level database directory.
Definition: gisdbase.c:29
int Vect_open_old_head(struct Map_info *Map, const char *name, const char *mapset)
Reads only info about vector from headers of &#39;head&#39;, &#39;dbln&#39;, &#39;topo&#39; and &#39;cidx&#39; file.
int V2_open_old_ogr(struct Map_info *Map)
Open OGR specific level 2 files (feature index)
Definition: open_ogr.c:124
int dig_read_spidx(GVFILE *fp, struct Plus_head *Plus)
Definition: spindex_rw.c:359
int
Definition: g3dcolor.c:48
int Vect_delete(const char *map)
Delete vector map including attribute tables.
Definition: map.c:431
void dig_cidx_free(struct Plus_head *Plus)
Definition: diglib/cindex.c:44
int Vect__read_head(struct Map_info *Map)
Reads head information from text file (GRASS_VECT_HEAD_ELEMENT).
char * G_location(void)
Get current location name.
Definition: location.c:61
int Vect_open_update_head(struct Map_info *Map, const char *name, const char *mapset)
Open old vector head for updating (mostly for database link updates)
int Vect_open_old(struct Map_info *Map, const char *name, const char *mapset)
Open existing vector for reading.
int Vect_coor_info(struct Map_info *Map, struct Coor_info *Info)
Update Coor_info structure.
void dig_free_plus(struct Plus_head *Plus)
Free Plus structure.
Definition: plus.c:241
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
int Vect_open_spatial_index(struct Map_info *Map)
Open spatial index file.
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
Definition: gis/open.c:197
return NULL
Definition: dbfopen.c:1394
char * G_find_file2(const char *element, const char *name, const char *mapset)
searches for a file from the mapset search list or in a specified mapset. (look but don&#39;t touch) retu...
Definition: find_file.c:191
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
tuple Map
Definition: render.py:1310
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
void dig_file_init(GVFILE *file)
Initialize GVFILE.
Definition: file.c:168
fclose(fd)
char buf2[200]
Definition: g3dcats.c:89
int Vect_cidx_open(struct Map_info *Map, int head_only)
Read category index from file if exists.
Definition: Vlib/cindex.c:488
struct dblinks * Vect_new_dblinks_struct(void)
Create and init new dblinks ctructure.
Definition: field.c:45
int Vect_open_new(struct Map_info *Map, const char *name, int with_z)
Open new vector for reading/writing.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
Definition: gis/open.c:226
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int Vect_read_dblinks(struct Map_info *Map)
Read dblinks to existing structure.
Definition: field.c:431
int Vect_hist_write(struct Map_info *Map, const char *str)
Write string to history file.
Definition: hist.c:62
long dig_ftell(GVFILE *file)
Get GVFILE position.
Definition: file.c:36
char xname[512]
Definition: g3dcats.c:89
int V1_open_old_nat(struct Map_info *Map, int update)
Open existing vector map.
Definition: open_nat.c:43
int dig_load_plus(struct Plus_head *Plus, GVFILE *plus, int head_only)
Reads topo file to topo structure.
Definition: plus.c:262
int dig_read_frmt_ascii(FILE *dascii, struct Format_info *finfo)
Definition: frmt.c:27
int Vect_rewind(struct Map_info *Map)
Rewind vector data file to cause reads to start at beginning.
int G__name_is_fully_qualified(const char *fullname, char *name, char *mapset)
Check if map name is fully qualified (map @ mapset)
Definition: nme_in_mps.c:57