21 #include <sys/types.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_open_new(struct Map_info *, const char *, int)
Create new vector map for reading/writing.
int Vect_save_frmt(struct Map_info *Map)
Save format definition file for vector map.
int Spidx_new
Build new spatial index.
const char * G_find_file2(const char *, const char *, const char *)
Searches for a file from the mapset search list or in a specified mapset. (look but don't touch) ...
char * name
Map name (for 4.0)
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
off_t coor_size
Size of coor file.
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)
struct Key_Value * G_fread_key_value(FILE *)
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.
int Vect_copy_map_lines_field(struct Map_info *, int, struct Map_info *)
Copy all alive vector features from given layer from input vector map to output vector map...
int Vect_copy_head_data(const struct Map_info *, struct Map_info *)
Copy header data from one to another map.
char * location
Location name.
void G_free(void *)
Free allocated memory.
#define GV_TOPO_ELEMENT
Native format, topology file.
struct Format_info fInfo
Format info for non-native formats.
long mtime
Time of last modification.
int Vect_save_sidx(struct Map_info *)
Save spatial index file for vector map.
void dig_free_plus(struct Plus_head *)
Free Plus structure.
int Spidx_built
Spatial index built?
#define VECT_CLOSED_CODE
Vector map close code.
int Vect_hist_copy(const struct Map_info *, struct Map_info *)
Copy history from one map to another.
int V2_close_ogr(struct Map_info *)
Close vector map on topological level (write out fidx file)
struct gvfile spidx_fp
Spatial index file pointer.
void Vect__free_offset(struct Format_info_offset *offset)
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
FILE * G_fopen_new(const char *, const char *)
Open a new database file.
#define GV_CIDX_ELEMENT
Native format, category index.
int Vect_build(struct Map_info *)
Build topology for vector map.
int V1_close_ogr(struct Map_info *)
Close vector map (OGR dsn & layer) on level 1.
struct Plus_head plus
Plus info (topology, version, ...)
int Vect_map_del_dblink(struct Map_info *, int)
Delete db connection from Map_info structure.
int V1_close_nat(struct Map_info *)
Close vector map.
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
int Vect_cidx_save(struct Map_info *)
Save category index to binary file (cidx)
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 * file
File descriptor.
int Vect_is_3d(const struct Map_info *)
Check if vector map is 3D.
const char * G_mapset(void)
Get current mapset name.
int temporary
Temporary map flag.
const char * Vect_get_full_name(const struct Map_info *)
Get fully qualified name of vector map.
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
int Vect_save_topo(struct Map_info *)
Save topology file for vector map.
void G_warning(const char *,...) __attribute__((format(printf
int format
Map format (native, ogr, postgis)
char * G_store(const char *)
Copy string to allocated memory.
#define GV_BUILD_ALL
Topology levels - build everything (currently same as GV_BUILD_CENTROIDS)
#define GV_FIDX_ELEMENT
External format (OGR), feature index.
#define GV_SIDX_ELEMENT
Native format, spatial index.
int V2_close_pg(struct Map_info *)
Close vector map (PostGIS layer) on topological level (write out fidx file)
void Vect_copy_map_dblinks(const struct Map_info *, struct Map_info *, int)
Copy DB links from input vector map to output vector map.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
void void G_verbose_message(const char *,...) __attribute__((format(printf
int Vect_coor_info(const struct Map_info *, struct Coor_info *)
Update Coor_info structure.
const char * Vect_get_name(const struct Map_info *)
Get name of vector map.
int G_debug(int, const char *,...) __attribute__((format(printf
int V1_close_pg(struct Map_info *)
Close vector map (PostGIS layer) on level 1.
char * gisdbase
GISDBASE path.
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
FILE * hist_fp
History file.