21 #include <sys/types.h>
28 #include "local_proto.h"
35 #if !defined HAVE_OGR || !defined HAVE_POSTGRES
38 G_fatal_error(
_(
"Requested format is not compiled in this version"));
62 static void unlink_file(
struct Map_info *,
const char *);
78 "Vect_close(): name = %s, mapset = %s, format = %d, level = %d, "
86 putenv(
"GRASS_VECTOR_EXTERNAL_IMMEDIATE=1");
88 G_warning(
_(
"Unable to create vector map <%s>"),
113 putenv(
"GRASS_VECTOR_EXTERNAL_IMMEDIATE=");
122 if (getenv(
"GRASS_VECTOR_PGFILE"))
123 def_file = getenv(
"GRASS_VECTOR_PGFILE");
138 G_warning(
_(
"Unable to open %s file"), def_file);
202 G_debug(1,
"spatial index file closed");
208 G_debug(1,
"free topology, spatial index, and category index");
212 G_debug(1,
"close history file");
218 if (create_link && ((*Close_array[Map->
format][1])(Map)) != 0) {
249 G_warning(
_(
"Invalid request for writing frmt file - map format is %d"),
263 fprintf(fd,
"format: postgis\n");
268 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
274 fprintf(fd,
"format: ogr\n");
320 void unlink_file(
struct Map_info *Map,
const char *
name)
326 if (access(
path, F_OK) == 0) {
FILE * G_fopen_old(const char *, const char *, const char *)
Open a database file for reading.
void G_zero(void *, int)
Zero out a buffer, buf, of length i.
void G_free(void *)
Free allocated memory.
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)
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
const char * G_find_key_value(const char *, const struct Key_Value *)
Find given key (case sensitive)
void void G_verbose_message(const char *,...) __attribute__((format(printf
const char * G_mapset(void)
Get current mapset name.
struct Key_Value * G_fread_key_value(FILE *)
Read key/values pairs from file.
int int G_strcasecmp(const char *, const char *)
String compare ignoring case (upper or lower)
int G_debug(int, const char *,...) __attribute__((format(printf
char * G_store(const char *)
Copy string to allocated memory.
FILE * G_fopen_new(const char *, const char *)
Open a new database file.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_cidx_save(struct Map_info *)
Save category index to binary file (cidx)
int Vect_coor_info(struct Map_info *, struct Coor_info *)
Update Coor_info structure.
int Vect_open_new(struct Map_info *, const char *, int)
Create new vector map for reading/writing.
int Vect_map_del_dblink(struct Map_info *, int)
Delete db connection from Map_info structure.
const char * Vect_get_full_name(struct Map_info *)
Get fully qualified name of vector map.
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 V2_close_pg(struct Map_info *)
int V1_close_nat(struct Map_info *)
Close vector map.
int Vect_save_topo(struct Map_info *)
Save topology file for vector map.
int Vect_save_sidx(struct Map_info *)
Save spatial index file for vector map.
int Vect_copy_head_data(struct Map_info *, struct Map_info *)
Copy header data from one to another map.
int Vect_hist_copy(struct Map_info *, struct Map_info *)
Copy history from one map to another.
void Vect_copy_map_dblinks(struct Map_info *, struct Map_info *, int)
Copy DB links from input vector map to output vector map.
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.
int V1_close_pg(struct Map_info *)
const char * Vect_get_name(struct Map_info *)
Get name of vector map.
int V2_close_ogr(struct Map_info *)
Close vector map on topological level (write out fidx file)
int Vect_is_3d(struct Map_info *)
Check if vector map is 3D.
#define VECT_CLOSED_CODE
Vector map close code.
#define GV_FRMT_ELEMENT
Format description, data location (OGR)
#define GV_FORMAT_POSTGIS
PostGIS format.
#define GV_DIRECTORY
Name of vector directory.
#define GV_SIDX_ELEMENT
Native format, spatial index.
#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_CIDX_ELEMENT
Native format, category index.
#define GV_TOPO_ELEMENT
Native format, topology file.
#define GV_FORMAT_OGR
OGR format.
void dig_free_plus(struct Plus_head *)
Free Plus structure.
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
off_t size
Total size (in bytes)
long mtime
Time of last modification.
char * mapset
Mapset name.
int temporary
Temporary map flag.
int support_updated
Support files were updated.
char * gisdbase
GISDBASE path.
char * name
Map name (for 4.0)
FILE * hist_fp
History file.
char * location
Location name.
int head_only
Open only header.
int format
Map format (native, ogr, postgis)
struct Format_info fInfo
Format info for non-native formats.
struct Plus_head plus
Plus info (topology, version, ...)
struct gvfile spidx_fp
Spatial index file pointer.
int Spidx_built
Spatial index built?
off_t coor_size
Size of coor file.
int Spidx_new
Build new spatial index.
int release_support
Release memory occupied by support structures (topo, spatial, category)
long coor_mtime
Time of last coor modification.
int built
Highest level of topology currently available.
FILE * file
File descriptor.
int Vect_close(struct Map_info *Map)
Close vector map.
void Vect__free_offset(struct Format_info_offset *offset)
int Vect_save_frmt(struct Map_info *Map)
Save format definition file for vector map.
void Vect__free_cache(struct Format_info_cache *cache)
char * Vect__get_element_path(char *file_path, struct Map_info *Map, const char *element)
Get map element full path (internal use only)