GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
vector/Vlib/header.c File Reference

Vector library - header manipulation. More...

#include <stdlib.h>
#include <string.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include "local_proto.h"
Include dependency graph for vector/Vlib/header.c:

Go to the source code of this file.

Functions

int Vect_print_header (struct Map_info *Map)
 Print vector map header to stdout. More...
 
int Vect_read_header (struct Map_info *Map)
 Read vector map header from map head file. More...
 
int Vect_write_header (struct Map_info *Map)
 Write vector map header to map head file. More...
 
int Vect__write_head (struct Map_info *Map)
 Writes head information to text file (GV_HEAD_ELEMENT) More...
 
int Vect__read_head (struct Map_info *Map)
 Reads head information from text file (GV_HEAD_ELEMENT) - for internal use only. More...
 
const char * Vect_get_name (struct Map_info *Map)
 Get name of vector map. More...
 
const char * Vect_get_mapset (struct Map_info *Map)
 Get name of mapset where vector map lives. More...
 
const char * Vect_get_full_name (struct Map_info *Map)
 Get fully qualified name of vector map. More...
 
int Vect_is_3d (struct Map_info *Map)
 Check if vector map is 3D. More...
 
int Vect_set_organization (struct Map_info *Map, const char *str)
 Set organization string in map header. More...
 
const char * Vect_get_organization (struct Map_info *Map)
 Get organization string from map header. More...
 
int Vect_set_date (struct Map_info *Map, const char *str)
 Set date of digitization in map header. More...
 
const char * Vect_get_date (struct Map_info *Map)
 Get date of digitization from map header. More...
 
int Vect_set_person (struct Map_info *Map, const char *str)
 Set name of user who digitized the map in map header. More...
 
const char * Vect_get_person (struct Map_info *Map)
 Get user name string who digitized the map from map header. More...
 
int Vect_set_map_name (struct Map_info *Map, const char *str)
 Set map name in map header. More...
 
const char * Vect_get_map_name (struct Map_info *Map)
 Get map name from map header. More...
 
int Vect_set_map_date (struct Map_info *Map, const char *str)
 Set date when the source map was originally produced in map header. More...
 
const char * Vect_get_map_date (struct Map_info *Map)
 Get date when the source map was originally produced from map header. More...
 
int Vect_set_scale (struct Map_info *Map, int scale)
 Set map scale in map header. More...
 
int Vect_get_scale (struct Map_info *Map)
 Get map scale from map header. More...
 
int Vect_set_comment (struct Map_info *Map, const char *str)
 Set comment or other info string in map header. More...
 
const char * Vect_get_comment (struct Map_info *Map)
 Get comment or other info string from map header. More...
 
int Vect_set_zone (struct Map_info *Map, int zone)
 Set projection zone in map header. More...
 
int Vect_get_zone (struct Map_info *Map UNUSED)
 Get projection zone from map header. More...
 
int Vect_set_proj (struct Map_info *Map, int proj)
 Set projection in map header. More...
 
int Vect_get_proj (struct Map_info *Map)
 Get projection from map header. More...
 
const char * Vect_get_proj_name (struct Map_info *Map)
 Query cartographic projection name of pointer to Map_info structure. More...
 
int Vect_set_thresh (struct Map_info *Map, double thresh)
 Set threshold used for digitization in map header. More...
 
double Vect_get_thresh (struct Map_info *Map)
 Get threshold used for digitization from map header. More...
 

Detailed Description

Vector library - header manipulation.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2010 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL, probably Dave Gerdes or Mike Higgins.
Update to GRASS 5.7 Radim Blazek and David D. Gray.
Update to GRASS 7 (OGR support) by Martin Landa <landa.martin gmail.com>

Definition in file vector/Vlib/header.c.

Function Documentation

◆ Vect__read_head()

int Vect__read_head ( struct Map_info Map)

Reads head information from text file (GV_HEAD_ELEMENT) - for internal use only.

Parameters
Mappointer to Map_info structure
Returns
0 on success
-1 on error

Definition at line 118 of file vector/Vlib/header.c.

References _, G_debug(), G_fopen_old(), G_getl2(), G_warning(), GPATH_MAX, GV_HEAD_ELEMENT, Map_info::mapset, Map_info::name, NULL, Vect__get_path(), Vect__init_head(), Vect_get_full_name(), Vect_set_comment(), Vect_set_date(), Vect_set_map_date(), Vect_set_map_name(), Vect_set_organization(), Vect_set_person(), Vect_set_proj(), Vect_set_scale(), Vect_set_thresh(), and Vect_set_zone().

Referenced by Vect_read_header().

◆ Vect__write_head()

int Vect__write_head ( struct Map_info Map)

◆ Vect_get_comment()

const char* Vect_get_comment ( struct Map_info Map)

Get comment or other info string from map header.

Parameters
Mappointer to Map_info structure
Returns
comment or other info string

Definition at line 453 of file vector/Vlib/header.c.

References dig_head::comment, and Map_info::head.

Referenced by Vect__write_head(), Vect_copy_head_data(), and Vect_write_ascii_head().

◆ Vect_get_date()

const char* Vect_get_date ( struct Map_info Map)

Get date of digitization from map header.

Parameters
Mappointer to Map_info structure
Returns
date of digitization string

Definition at line 314 of file vector/Vlib/header.c.

References dig_head::date, and Map_info::head.

Referenced by Vect__write_head(), Vect_copy_head_data(), and Vect_write_ascii_head().

◆ Vect_get_full_name()

const char* Vect_get_full_name ( struct Map_info Map)

Get fully qualified name of vector map.

  • for GV_FORMAT_NATIVE and GV_FORMAT_OGR returns "map@mapset"
  • for GV_FORMAT_OGR_DIRECT returns "layer@datasourse"

Allocated string should be freed by G_free().

Parameters
Mappointer to Map_info structure
Returns
allocated string "name@mapset"

Definition at line 221 of file vector/Vlib/header.c.

References Format_info_ogr::dsn, Map_info::fInfo, Map_info::format, G_malloc, GV_FORMAT_OGR_DIRECT, Format_info_ogr::layer_name, Map_info::mapset, Map_info::name, and Format_info::ogr.

Referenced by V1_open_old_nat(), V2_open_old_ogr(), V2_open_old_pg(), Vect__read_head(), Vect__write_head(), Vect_build_partial(), Vect_build_sidx_from_topo(), Vect_cidx_open(), Vect_get_finfo_dsn_name(), Vect_get_finfo_layer_name(), Vect_open_fidx(), and Vect_sfa_get_num_features().

◆ Vect_get_map_date()

const char* Vect_get_map_date ( struct Map_info Map)

Get date when the source map was originally produced from map header.

Parameters
Mappointer to Map_info structure
Returns
string containing a date

Definition at line 398 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::source_date.

Referenced by Vect__write_head(), Vect_copy_head_data(), Vect_print_header(), and Vect_write_ascii_head().

◆ Vect_get_map_name()

const char* Vect_get_map_name ( struct Map_info Map)

Get map name from map header.

Parameters
Mappointer to Map_info structure
Returns
string containing map name

Definition at line 370 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::map_name.

Referenced by Vect__write_head(), Vect_copy_head_data(), Vect_print_header(), and Vect_write_ascii_head().

◆ Vect_get_mapset()

const char* Vect_get_mapset ( struct Map_info Map)

Get name of mapset where vector map lives.

Parameters
Mappointer to Map_info structure
Returns
string containing mapset name

Definition at line 204 of file vector/Vlib/header.c.

References Map_info::mapset.

◆ Vect_get_name()

const char* Vect_get_name ( struct Map_info Map)

Get name of vector map.

Parameters
Mappointer to Map_info structure
Returns
string containing name

Definition at line 192 of file vector/Vlib/header.c.

References Map_info::name.

Referenced by Vect_close(), Vect_save_sidx(), and Vect_write_dblinks().

◆ Vect_get_organization()

const char* Vect_get_organization ( struct Map_info Map)

Get organization string from map header.

Parameters
Mappointer to Map_info structure
Returns
string containing organization name

Definition at line 283 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::organization.

Referenced by Vect__write_head(), Vect_copy_head_data(), Vect_print_header(), and Vect_write_ascii_head().

◆ Vect_get_person()

const char* Vect_get_person ( struct Map_info Map)

Get user name string who digitized the map from map header.

Parameters
Mappointer to Map_info structure
Returns
string containing user name

Definition at line 342 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::user_name.

Referenced by Vect__write_head(), Vect_copy_head_data(), and Vect_write_ascii_head().

◆ Vect_get_proj()

int Vect_get_proj ( struct Map_info Map)

Get projection from map header.

Parameters
Mappointer to Map_info structure
Returns
PROJECTION_XY 0 - x,y (Raw imagery),
PROJECTION_UTM 1 - UTM Universal Transverse Mercator,
PROJECTION_LL 3 - Latitude-Longitude

Definition at line 519 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::proj.

Referenced by Vect__write_head(), and Vect_get_proj_name().

◆ Vect_get_proj_name()

const char* Vect_get_proj_name ( struct Map_info Map)

Query cartographic projection name of pointer to Map_info structure.

Returns a pointer to a string which is a printable name for projection code proj (as returned by Vect_get_proj()).

Parameters
Mappointer to Map_info structure
Returns
allocated string containing projection name
NULL if proj is not a valid projection

Definition at line 536 of file vector/Vlib/header.c.

References _, G_database_projection_name(), G_debug(), G_projection_name(), G_store(), name, PROJECTION_LL, PROJECTION_OTHER, PROJECTION_UTM, PROJECTION_XY, strcpy, and Vect_get_proj().

◆ Vect_get_scale()

int Vect_get_scale ( struct Map_info Map)

Get map scale from map header.

Parameters
Mappointer to Map_info structure
Returns
map scale

Definition at line 425 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::orig_scale.

Referenced by Vect__write_head(), Vect_copy_head_data(), Vect_print_header(), and Vect_write_ascii_head().

◆ Vect_get_thresh()

double Vect_get_thresh ( struct Map_info Map)

Get threshold used for digitization from map header.

Parameters
Mappointer to Map_info structure
Returns
threshold used for digitization

Definition at line 585 of file vector/Vlib/header.c.

References dig_head::digit_thresh, and Map_info::head.

Referenced by Vect__write_head(), Vect_copy_head_data(), and Vect_write_ascii_head().

◆ Vect_get_zone()

int Vect_get_zone ( struct Map_info *Map  UNUSED)

Get projection zone from map header.

Parameters
Mappointer to Map_info structure (unused, returns the zone for the active region)
Returns
projection zone

Definition at line 481 of file vector/Vlib/header.c.

References G_zone().

Referenced by Vect__write_head().

◆ Vect_is_3d()

int Vect_is_3d ( struct Map_info Map)

Check if vector map is 3D.

Check vector map header.

Parameters
Mappointer to Map_info structure
Returns
TRUE vector map is 3D
FALSE vector map is not 3D

Definition at line 255 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::with_z.

Referenced by Vect_close(), Vect_get_area_box(), and Vect_get_isle_box().

◆ Vect_print_header()

int Vect_print_header ( struct Map_info Map)

Print vector map header to stdout.

Parameters
Mappointer to Map_info structure
Returns
0 on success

Definition at line 33 of file vector/Vlib/header.c.

References Vect_get_map_date(), Vect_get_map_name(), Vect_get_organization(), and Vect_get_scale().

◆ Vect_read_header()

int Vect_read_header ( struct Map_info Map)

Read vector map header from map head file.

Parameters
Mappointrt to Map_info structure
Returns
0

Definition at line 51 of file vector/Vlib/header.c.

References Vect__read_head().

◆ Vect_set_comment()

int Vect_set_comment ( struct Map_info Map,
const char *  str 
)

Set comment or other info string in map header.

Parameters
Mappointer to Map_info structure
strcomment or other info string
Returns
0

Definition at line 438 of file vector/Vlib/header.c.

References dig_head::comment, G_free(), G_store(), and Map_info::head.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_date()

int Vect_set_date ( struct Map_info Map,
const char *  str 
)

Set date of digitization in map header.

Todo:
This should be coupled to DateTime functions to support time series
Parameters
Mappointer to Map_info structure
strdate given as string
Returns
0

Definition at line 299 of file vector/Vlib/header.c.

References dig_head::date, G_free(), G_store(), and Map_info::head.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_map_date()

int Vect_set_map_date ( struct Map_info Map,
const char *  str 
)

Set date when the source map was originally produced in map header.

Parameters
Mappointer to Map_info structure
strdate given as a string
Returns
0

Definition at line 383 of file vector/Vlib/header.c.

References G_free(), G_store(), Map_info::head, and dig_head::source_date.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_map_name()

int Vect_set_map_name ( struct Map_info Map,
const char *  str 
)

Set map name in map header.

Parameters
Mappointer to Map_info structure
strmap name to be set
Returns
0

Definition at line 355 of file vector/Vlib/header.c.

References G_free(), G_store(), Map_info::head, and dig_head::map_name.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_organization()

int Vect_set_organization ( struct Map_info Map,
const char *  str 
)

Set organization string in map header.

Parameters
Mappointer to Map_info structure
strorganization name
Returns
0

Definition at line 268 of file vector/Vlib/header.c.

References G_free(), G_store(), Map_info::head, and dig_head::organization.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_person()

int Vect_set_person ( struct Map_info Map,
const char *  str 
)

Set name of user who digitized the map in map header.

Parameters
Mappointer to Map_info structure
struser name
Returns
0

Definition at line 327 of file vector/Vlib/header.c.

References G_free(), G_store(), Map_info::head, and dig_head::user_name.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_proj()

int Vect_set_proj ( struct Map_info Map,
int  proj 
)

Set projection in map header.

Supported projections:

  • PROJECTION_XY 0 - x,y (Raw imagery),
  • PROJECTION_UTM 1 - UTM Universal Transverse Mercator,
  • PROJECTION_LL 3 - Latitude-Longitude
Parameters
Mappointer to Map_info structure
projprojection code
Returns
0

Definition at line 503 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::proj.

Referenced by Vect__init_head(), and Vect__read_head().

◆ Vect_set_scale()

int Vect_set_scale ( struct Map_info Map,
int  scale 
)

Set map scale in map header.

Parameters
Mappointer to Map_info structure
scalemap scale
Returns
0

Definition at line 411 of file vector/Vlib/header.c.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_thresh()

int Vect_set_thresh ( struct Map_info Map,
double  thresh 
)

Set threshold used for digitization in map header.

Parameters
Mappointer to Map_info structure
threshthreshold used for digitization
Returns
0

Definition at line 571 of file vector/Vlib/header.c.

References dig_head::digit_thresh, G_debug(), and Map_info::head.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_set_zone()

int Vect_set_zone ( struct Map_info Map,
int  zone 
)

Set projection zone in map header.

Parameters
Mappointer to Map_info structure
zoneprojection zone
Returns
0

Definition at line 466 of file vector/Vlib/header.c.

References Map_info::head, and dig_head::plani_zone.

Referenced by Vect__init_head(), Vect__read_head(), Vect_copy_head_data(), and Vect_read_ascii_head().

◆ Vect_write_header()

int Vect_write_header ( struct Map_info Map)

Write vector map header to map head file.

Parameters
Mappointer to Map_info structure
Returns
0

Definition at line 64 of file vector/Vlib/header.c.

References Vect__write_head().