21 #include <sys/types.h> 25 #include <grass/vector.h> 26 #include <grass/glocale.h> 28 #include "local_proto.h" 30 static int clo_dummy()
35 #if !defined HAVE_OGR || !defined HAVE_POSTGRES 38 G_fatal_error(
_(
"Requested format is not compiled in this version"));
43 static int (*Close_array[][2]) () = {
50 clo_dummy, V1_close_ogr}
66 static void unlink_file(
const struct Map_info *,
const char *);
81 G_debug(1,
"Vect_close(): name = %s, mapset = %s, format = %d, level = %d, is_tmp = %d",
89 putenv(
"GRASS_VECTOR_EXTERNAL_IMMEDIATE=1");
91 G_warning(
_(
"Unable to create vector map <%s>"),
115 putenv(
"GRASS_VECTOR_EXTERNAL_IMMEDIATE=");
125 if (
getenv(
"GRASS_VECTOR_PGFILE"))
126 def_file =
getenv(
"GRASS_VECTOR_PGFILE");
141 G_warning(
_(
"Unable to open %s file"), def_file);
209 G_debug(1,
"spatial index file closed");
215 G_debug(1,
"free topology, spatial index, and category index");
219 G_debug(1,
"close history file");
225 if (create_link && ((*Close_array[Map->
format][1]) (Map)) != 0) {
257 G_warning(
_(
"Invalid request for writing frmt file - map format is %d"), Map->
format);
270 fprintf(fd,
"format: postgis\n");
275 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
280 fprintf(fd,
"format: ogr\n");
324 void unlink_file(
const struct Map_info *Map,
const char *
name)
330 if (access(path, F_OK) == 0) {
331 G_debug(2,
"\t%s: unlink", path);
int Vect_save_frmt(struct Map_info *Map)
Save format definition file for vector map.
int V1_close_ogr(struct Map_info *Map)
Close vector map (OGR dsn & layer) on level 1.
int Spidx_new
Build new spatial index.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
char * name
Map name (for 4.0)
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
off_t coor_size
Size of coor file.
void G_free(void *buf)
Free allocated memory.
int built
Highest level of topology currently available.
char * Vect__get_element_path(char *file_path, const struct Map_info *Map, const char *element)
Get map element full path (internal use only)
#define GV_DIRECTORY
Name of vector directory.
#define GV_FRMT_ELEMENT
Format description, data location (OGR)
off_t size
Total size (in bytes)
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
struct Key_Value * G_fread_key_value(FILE *fd)
Read key/values pairs from file.
int release_support
Release memory occupied by support structures (topo, spatial, category)
void Vect__free_cache(struct Format_info_cache *cache)
int Vect_close(struct Map_info *Map)
Close vector map.
#define GV_FORMAT_OGR
OGR format.
char * location
Location name.
char * G_store(const char *s)
Copy string to allocated memory.
#define GV_TOPO_ELEMENT
Native format, topology file.
void Vect_destroy_line_struct(struct line_pnts *p)
Frees all memory associated with a line_pnts structure, including the structure itself.
struct Format_info fInfo
Format info for non-native formats.
int Vect_save_topo(struct Map_info *Map)
Save topology file for vector map.
long mtime
Time of last modification.
int V1_close_nat(struct Map_info *Map)
Close vector map.
int Vect_copy_map_lines_field(struct Map_info *In, int field, struct Map_info *Out)
Copy all alive vector features from given layer from input vector map to output vector map...
void dig_free_plus(struct Plus_head *)
Free Plus structure.
int Spidx_built
Spatial index built?
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
#define VECT_CLOSED_CODE
Vector map close code.
int V1_close_pg(struct Map_info *Map)
Close vector map (PostGIS layer) on level 1.
struct gvfile spidx_fp
Spatial index file pointer.
void Vect__free_offset(struct Format_info_offset *offset)
#define GV_CIDX_ELEMENT
Native format, category index.
int Vect_save_sidx(struct Map_info *Map)
Save spatial index file for vector map.
int Vect_build(struct Map_info *Map)
Build topology for vector map.
int G_debug(int level, const char *msg,...)
Print debugging message.
int Vect_coor_info(const struct Map_info *Map, struct Coor_info *Info)
Update Coor_info structure.
struct Plus_head plus
Plus info (topology, version, ...)
int V2_close_ogr(struct Map_info *Map)
Close vector map on topological level (write out fidx file)
int Vect_hist_copy(const struct Map_info *In, struct Map_info *Out)
Copy history from one map to another.
char * mapset
Mapset name.
int head_only
Open only header.
int support_updated
Support files were updated.
long coor_mtime
Time of last coor modification.
#define GV_FORMAT_POSTGIS
PostGIS format.
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
FILE * file
File descriptor.
void Vect_copy_map_dblinks(const struct Map_info *In, struct Map_info *Out, int first_only)
Copy DB links from input vector map to output vector map.
int Vect_copy_head_data(const struct Map_info *from, struct Map_info *to)
Copy header data from one to another map.
int temporary
Temporary map flag.
int Vect_cidx_save(struct Map_info *Map)
Save category index to binary file (cidx)
int format
Map format (native, ogr, postgis)
#define GV_BUILD_ALL
Topology levels - build everything (currently same as GV_BUILD_CENTROIDS)
const char * G_mapset(void)
Get current mapset name.
int Vect_map_del_dblink(struct Map_info *Map, int field)
Delete db connection from Map_info structure.
#define GV_FIDX_ELEMENT
External format (OGR), feature index.
int Vect_open_new(struct Map_info *Map, const char *name, int with_z)
Create new vector map for reading/writing.
#define GV_SIDX_ELEMENT
Native format, spatial index.
void G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
int V2_close_pg(struct Map_info *Map)
Close vector map (PostGIS layer) on topological level (write out fidx file)
void G_warning(const char *msg,...)
Print a warning message to stderr.
const 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't touch) ...
char * gisdbase
GISDBASE path.
FILE * hist_fp
History file.