GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
write_nat.c File Reference

Vector library - write vector feature (native format) More...

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Include dependency graph for write_nat.c:

Go to the source code of this file.

Functions

long V1__rewrite_line_nat (struct Map_info *Map, long offset, int type, struct line_pnts *points, struct line_cats *cats)
 Rewrites feature at the given offset. More...
 
long V1_write_line_nat (struct Map_info *Map, int type, struct line_pnts *points, struct line_cats *cats)
 Writes feature to 'coor' file. More...
 
long V2_write_line_nat (struct Map_info *Map, int type, struct line_pnts *points, struct line_cats *cats)
 Writes feature to 'coor' file (topology level) More...
 
long V1_rewrite_line_nat (struct Map_info *Map, long offset, int type, struct line_pnts *points, struct line_cats *cats)
 Rewrites feature at the given offset. More...
 
int V2_rewrite_line_nat (struct Map_info *Map, int line, int type, struct line_pnts *points, struct line_cats *cats)
 Rewrites feature (topology level) More...
 
int V1_delete_line_nat (struct Map_info *Map, long offset)
 Deletes feature at the given offset. More...
 
int V2_delete_line_nat (struct Map_info *Map, int line)
 Deletes feature (topology level). More...
 
int V1_restore_line_nat (struct Map_info *Map, long offset)
 Restores feature at the given offset. More...
 
int V2_restore_line_nat (struct Map_info *Map, int line, long offset)
 Restores feature (topology level) More...
 

Detailed Description

Vector library - write vector feature (native format)

Higher level functions for reading/writing/manipulating vectors.

Operations:

  • Add feature
  • Rewrite feature
  • Delete feature
  • Restore feature

(C) 2001-2008 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.
V*_restore_line() by Martin Landa <landa.martin gmail.com> (2008)
Date
2001

Definition in file write_nat.c.

Function Documentation

long V1__rewrite_line_nat ( struct Map_info *  Map,
long  offset,
int  type,
struct line_pnts *  points,
struct line_cats *  cats 
)

Rewrites feature at the given offset.

Parameters
Mappointer to vector map
offsetfeature offset
typefeature type
pointsfeature geometry
catsfeature categories
Returns
feature offset
-1 on error

Definition at line 487 of file write_nat.c.

References dig__fwrite_port_C(), dig__fwrite_port_D(), dig__fwrite_port_I(), dig__fwrite_port_S(), dig_fflush(), dig_fseek(), dig_set_cur_port(), dig_type_to_store(), and if().

Referenced by V1_rewrite_line_nat(), and V1_write_line_nat().

int V1_delete_line_nat ( struct Map_info *  Map,
long  offset 
)

Deletes feature at the given offset.

Parameters
Mappointer to vector map
offsetfeature offset
Returns
0 on success
-1 on error

Definition at line 584 of file write_nat.c.

References dig__fread_port_C(), dig__fwrite_port_C(), dig_fflush(), dig_fseek(), dig_set_cur_port(), and G_debug().

Referenced by V1_rewrite_line_nat(), and V2_delete_line_nat().

int V1_restore_line_nat ( struct Map_info *  Map,
long  offset 
)

Restores feature at the given offset.

Parameters
Mappointer to vector map
offsetfeature offset
Returns
0 on success
-1 on error

Definition at line 823 of file write_nat.c.

References dig__fread_port_C(), dig__fwrite_port_C(), dig_fflush(), dig_fseek(), dig_set_cur_port(), and G_debug().

Referenced by V2_restore_line_nat().

long V1_rewrite_line_nat ( struct Map_info *  Map,
long  offset,
int  type,
struct line_pnts *  points,
struct line_cats *  cats 
)

Rewrites feature at the given offset.

If the number of points or cats differs from the original one or the type is changed: GV_POINTS -> GV_LINES or GV_LINES -> GV_POINTS, the old one is deleted and the new is appended to the end of the file.

Old feature is deleted (marked as dead), new feature written.

Parameters
Mappointer to vector map
offsetfeature offset
typefeature type
pointsfeature geometry
catsfeature categories
Returns
feature offset (rewriten feature)
-1 on error

Definition at line 397 of file write_nat.c.

References dig_fseek(), dig_ftell(), main::GV_LINES, NULL, V1__rewrite_line_nat(), V1_delete_line_nat(), V1_read_line_nat(), Vect_new_cats_struct(), and Vect_new_line_struct().

long V1_write_line_nat ( struct Map_info *  Map,
int  type,
struct line_pnts *  points,
struct line_cats *  cats 
)

Writes feature to 'coor' file.

Parameters
Mappointer to vector map
typefeature type
pointsfeature geometry
catsfeature categories
Returns
feature offset into file
-1 on error

Definition at line 314 of file write_nat.c.

References dig_fseek(), dig_ftell(), and V1__rewrite_line_nat().

Referenced by V2_write_line_nat().

int V2_delete_line_nat ( struct Map_info *  Map,
int  line 
)
int V2_restore_line_nat ( struct Map_info *  Map,
int  line,
long  offset 
)

Restores feature (topology level)

Parameters
Mappointer to vector map
linefeature id
offsetfeature offset
Returns
0 on success
-1 on error

Definition at line 866 of file write_nat.c.

References tools::box, dig_cidx_add_cat(), dig_line_box(), dig_line_set_box(), dig_restore_line(), G_debug(), G_fatal_error(), NULL, dialogs::type, V1_read_line_nat(), V1_restore_line_nat(), Vect_box_extend(), Vect_new_cats_struct(), and Vect_new_line_struct().

int V2_rewrite_line_nat ( struct Map_info *  Map,
int  line,
int  type,
struct line_pnts *  points,
struct line_cats *  cats 
)

Rewrites feature (topology level)

Old feature is deleted (marked as dead), new feature written.

Parameters
Mappointer to vector map
linefeature id
typefeature type
pointsfeature geometry
catsfeature category
Returns
new feature id
-1 on error

Definition at line 459 of file write_nat.c.

References V2_delete_line_nat(), and V2_write_line_nat().

long V2_write_line_nat ( struct Map_info *  Map,
int  type,
struct line_pnts *  points,
struct line_cats *  cats 
)

Writes feature to 'coor' file (topology level)

Parameters
Mappointer to vector map
typefeature type
pointsfeature geometry
catsfeature categories
Returns
new feature id
-1 on error

Definition at line 340 of file write_nat.c.

References tools::box, dig_add_line(), dig_line_box(), dig_line_set_box(), G_debug(), V1_write_line_nat(), Vect_box_copy(), and Vect_box_extend().

Referenced by V2_rewrite_line_nat().