GRASS 8 Programmer's Manual 8.6.0dev(2026)-1d1e47ad9d
Loading...
Searching...
No Matches
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.
 
int Vect_read_header (struct Map_info *Map)
 Read vector map header from map head file.
 
int Vect_write_header (struct Map_info *Map)
 Write vector map header to map head file.
 
int Vect__write_head (struct Map_info *Map)
 Writes head information to text file (GV_HEAD_ELEMENT)
 
int Vect__read_head (struct Map_info *Map)
 Reads head information from text file (GV_HEAD_ELEMENT) - for internal use only.
 
const charVect_get_name (struct Map_info *Map)
 Get name of vector map.
 
const charVect_get_mapset (struct Map_info *Map)
 Get name of mapset where vector map lives.
 
const charVect_get_full_name (struct Map_info *Map)
 Get fully qualified name of vector map.
 
int Vect_is_3d (struct Map_info *Map)
 Check if vector map is 3D.
 
int Vect_set_organization (struct Map_info *Map, const char *str)
 Set organization string in map header.
 
const charVect_get_organization (struct Map_info *Map)
 Get organization string from map header.
 
int Vect_set_date (struct Map_info *Map, const char *str)
 Set date of digitization in map header.
 
const charVect_get_date (struct Map_info *Map)
 Get date of digitization from map header.
 
int Vect_set_person (struct Map_info *Map, const char *str)
 Set name of user who digitized the map in map header.
 
const charVect_get_person (struct Map_info *Map)
 Get user name string who digitized the map from map header.
 
int Vect_set_map_name (struct Map_info *Map, const char *str)
 Set map name in map header.
 
const charVect_get_map_name (struct Map_info *Map)
 Get map name from map header.
 
int Vect_set_map_date (struct Map_info *Map, const char *str)
 Set date when the source map was originally produced in map header.
 
const charVect_get_map_date (struct Map_info *Map)
 Get date when the source map was originally produced from map header.
 
int Vect_set_scale (struct Map_info *Map, int scale)
 Set map scale in map header.
 
int Vect_get_scale (struct Map_info *Map)
 Get map scale from map header.
 
int Vect_set_comment (struct Map_info *Map, const char *str)
 Set comment or other info string in map header.
 
const charVect_get_comment (struct Map_info *Map)
 Get comment or other info string from map header.
 
int Vect_set_zone (struct Map_info *Map, int zone)
 Set projection zone in map header.
 
int Vect_get_zone (struct Map_info *Map)
 Get projection zone from map header.
 
int Vect_set_proj (struct Map_info *Map, int proj)
 Set projection in map header.
 
int Vect_get_proj (struct Map_info *Map)
 Get projection from map header.
 
const charVect_get_proj_name (struct Map_info *Map)
 Query cartographic projection name of pointer to Map_info structure.
 
int Vect_set_thresh (struct Map_info *Map, double thresh)
 Set threshold used for digitization in map header.
 
double Vect_get_thresh (struct Map_info *Map)
 Get threshold used for digitization from map header.
 

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 120 of file vector/Vlib/header.c.

References _, G_debug(), G_fopen_old(), G_free(), G_getl2(), G_warning(), GPATH_MAX, GV_HEAD_ELEMENT, AMI_STREAM< T >::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__open_old(), and 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 460 of file vector/Vlib/header.c.

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 321 of file vector/Vlib/header.c.

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 224 of file vector/Vlib/header.c.

References G_malloc, GV_FORMAT_OGR_DIRECT, and AMI_STREAM< T >::name().

Referenced by IL_vector_input_data_2d(), V1_open_old_nat(), V2_open_old_ogr(), V2_open_old_pg(), Vect__open_old(), Vect__read_head(), Vect__write_head(), Vect_build_partial(), Vect_build_sidx_from_topo(), Vect_cidx_open(), Vect_close(), Vect_copy_map_lines_field(), Vect_copy_tables(), Vect_get_finfo_dsn_name(), Vect_get_finfo_layer_name(), Vect_get_map_box1(), Vect_open_fidx(), Vect_read_line(), Vect_read_line_geos(), Vect_read_next_line(), Vect_sfa_get_num_features(), and Vect_topo_dump().

◆ 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 405 of file vector/Vlib/header.c.

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 377 of file vector/Vlib/header.c.

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 207 of file vector/Vlib/header.c.

◆ 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 195 of file vector/Vlib/header.c.

References AMI_STREAM< T >::name().

Referenced by Vect__open_old(), Vect_cidx_save(), Vect_close(), Vect_copy_tables(), Vect_delete_line(), Vect_read_ascii(), Vect_restore_line(), Vect_rewrite_line(), Vect_save_sidx(), Vect_write_dblinks(), and Vect_write_line().

◆ 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 290 of file vector/Vlib/header.c.

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 349 of file vector/Vlib/header.c.

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 526 of file vector/Vlib/header.c.

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 542 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 432 of file vector/Vlib/header.c.

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 591 of file vector/Vlib/header.c.

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)

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 488 of file vector/Vlib/header.c.

References G_zone().

Referenced by Vect__open_old(), Vect__write_head(), Vect_copy_head_data(), and Vect_write_ascii_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 262 of file vector/Vlib/header.c.

Referenced by Gp_load_sites(), Gv_load_vect(), IL_vector_input_data_2d(), V2__update_area_pg(), Vect_close(), Vect_get_area_box(), Vect_get_isle_box(), Vect_get_line_box(), Vect_read_ascii(), Vect_read_line_to_wkb(), Vect_remove_duplicates(), Vect_write_ascii(), Vedit_move_lines(), and Vedit_move_vertex().

◆ 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 445 of file vector/Vlib/header.c.

References G_free(), and G_store().

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 306 of file vector/Vlib/header.c.

References G_free(), and G_store().

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 390 of file vector/Vlib/header.c.

References G_free(), and G_store().

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 362 of file vector/Vlib/header.c.

References G_free(), and G_store().

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 275 of file vector/Vlib/header.c.

References G_free(), and G_store().

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 334 of file vector/Vlib/header.c.

References G_free(), and G_store().

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 510 of file vector/Vlib/header.c.

Referenced by Vect__init_head(), Vect__open_old(), 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 418 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 577 of file vector/Vlib/header.c.

References G_debug().

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 473 of file vector/Vlib/header.c.

Referenced by Vect__init_head(), Vect__open_old(), 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().