GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
gp2.c File Reference

OGSF library - loading and manipulating point sets (higher level functions) More...

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/ogsf.h>
#include <grass/glocale.h>
#include "gsget.h"
Include dependency graph for gp2.c:

Go to the source code of this file.

Functions

int GP_site_exists (int id)
 Check if point set exists. More...
 
int GP_new_site (void)
 Create new point set. More...
 
int GP_num_sites (void)
 Get number of loaded point sets. More...
 
int * GP_get_site_list (int *numsites)
 Get list of point sets. More...
 
int GP_delete_site (int id)
 Delete registrated point set. More...
 
int GP_load_site (int id, const char *filename)
 Load point set from file. More...
 
int GP_get_sitename (int id, char **filename)
 Get point set filename. More...
 
int GP_get_style (int id, int *color, int *width, float *size, int *symbol)
 Get point set style. More...
 
int GP_set_style (int id, int color, int width, float size, int symbol)
 Set point style. More...
 
int GP_set_style_thematic (int id, int layer, const char *color, const char *width, const char *size, const char *symbol, struct Colors *color_rules)
 Set point set style for thematic mapping. More...
 
int GP_unset_style_thematic (int id)
 Make style for thematic mapping inactive. More...
 
int GP_set_zmode (int id, int use_z)
 Set z mode for point set. More...
 
int GP_get_zmode (int id, int *use_z)
 Get z-mode. More...
 
void GP_set_trans (int id, float xtrans, float ytrans, float ztrans)
 Set transformation params. More...
 
void GP_get_trans (int id, float *xtrans, float *ytrans, float *ztrans)
 Get transformation params. More...
 
int GP_select_surf (int hp, int hs)
 Select surface for given point set. More...
 
int GP_unselect_surf (int hp, int hs)
 Unselect surface. More...
 
int GP_surf_is_selected (int hp, int hs)
 Check if surface is selected. More...
 
void GP_draw_site (int id)
 Draw point set. More...
 
void GP_alldraw_site (void)
 Draw all available point sets. More...
 
int GP_Set_ClientData (int id, void *clientd)
 Set client data. More...
 
void * GP_Get_ClientData (int id)
 Get client data. More...
 
int GP_str_to_marker (const char *str)
 Determine point marker symbol for string. More...
 

Detailed Description

OGSF library - loading and manipulating point sets (higher level functions)

(C) 1999-2008, 2011 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
Bill Brown USACERL (January 1994)
Updated by Martin landa <landa.martin gmail.com> (doxygenized in May 2008, thematic mapping in June 2011)

Definition in file gp2.c.

Function Documentation

◆ GP_alldraw_site()

void GP_alldraw_site ( void  )

Draw all available point sets.

Definition at line 607 of file gp2.c.

◆ GP_delete_site()

int GP_delete_site ( int  id)

Delete registrated point set.

Parameters
idpoint set id
Returns
1 on success
-1 on error (point sets not available)

Definition at line 131 of file gp2.c.

References G_debug(), gp_delete_site(), and GP_site_exists().

◆ GP_draw_site()

void GP_draw_site ( int  id)

Draw point set.

Parameters
idpoint set id

Definition at line 573 of file gp2.c.

References g_site::drape_surf_id, G_debug(), gp_get_site(), gpd_2dsite(), gpd_3dsite(), GS_get_region(), gs_get_surf(), g_site::has_z, g_site::n_surfs, and g_site::use_z.

Referenced by Nviz_draw_all_site().

◆ GP_Get_ClientData()

void* GP_Get_ClientData ( int  id)

Get client data.

Parameters
idpoint set id
Returns
pointer to client data
NULL on error

Definition at line 649 of file gp2.c.

References g_site::clientdata, gp_get_site(), and NULL.

◆ GP_get_site_list()

int* GP_get_site_list ( int *  numsites)

Get list of point sets.

Must freed when no longer needed!

Parameters
numsitesnumber of point sets
Returns
pointer to list of points sets
NULL on error

Definition at line 101 of file gp2.c.

Referenced by Nviz_draw_all_site().

◆ GP_get_sitename()

int GP_get_sitename ( int  id,
char **  filename 
)

Get point set filename.

Note: char array is allocated by G_store()

Parameters
idpoint set id
[out]filenamepoint set filename
Returns
-1 on error (point set not found)
1 on success

Definition at line 208 of file gp2.c.

◆ GP_get_style()

int GP_get_style ( int  id,
int *  color,
int *  width,
float *  size,
int *  symbol 
)

Get point set style.

Parameters
idpoint set id
Returns
1 on success
-1 on error (point set not found)

Definition at line 231 of file gp2.c.

◆ GP_get_trans()

void GP_get_trans ( int  id,
float *  xtrans,
float *  ytrans,
float *  ztrans 
)

Get transformation params.

Parameters
idpoint set id
[out]xtrans,ytrans,ztransx/y/z values

Definition at line 453 of file gp2.c.

References G_debug(), gp_get_site(), g_site::x_trans, g_site::y_trans, and g_site::z_trans.

◆ GP_get_zmode()

int GP_get_zmode ( int  id,
int *  use_z 
)

Get z-mode.

Todo:
Who's using this?
Parameters
idpoint set id
[out]use_znon-zero code to use z
Returns
-1 on error (invalid point set id)
1 on success

Definition at line 410 of file gp2.c.

References G_debug(), gp_get_site(), NULL, and g_site::use_z.

◆ GP_load_site()

int GP_load_site ( int  id,
const char *  filename 
)

Load point set from file.

Check to see if handle already loaded, if so - free before loading new for now, always load to memory.

Todo:
load file handle & ready for reading instead of using memory
Parameters
idpoint set id
filenamepoint set filename
Returns
-1 on error
1 on success

Definition at line 172 of file gp2.c.

◆ GP_new_site()

int GP_new_site ( void  )

Create new point set.

Returns
point set id
-1 on error (number of point sets exceeded)

Definition at line 63 of file gp2.c.

◆ GP_num_sites()

int GP_num_sites ( void  )

Get number of loaded point sets.

Returns
number of point sets

Definition at line 86 of file gp2.c.

References gp_num_sites().

◆ GP_select_surf()

int GP_select_surf ( int  hp,
int  hs 
)

Select surface for given point set.

Parameters
hppoint set id
hssurface id
Returns
1 surface selected
-1 on error

Definition at line 480 of file gp2.c.

References g_site::drape_surf_id, G_debug(), gp_get_site(), GP_surf_is_selected(), GS_surf_exists(), and g_site::n_surfs.

◆ GP_Set_ClientData()

int GP_Set_ClientData ( int  id,
void *  clientd 
)

Set client data.

Parameters
idpoint set id
clientdclient data
Returns
1 on success
-1 on error (invalid point set id)

Definition at line 627 of file gp2.c.

References g_site::clientdata, and gp_get_site().

◆ GP_set_style()

int GP_set_style ( int  id,
int  color,
int  width,
float  size,
int  symbol 
)

Set point style.

Supported icon symbols (markers):

  • ST_X
  • ST_BOX
  • ST_SPHERE
  • ST_CUBE
  • ST_DIAMOND
  • ST_DEC_TREE
  • ST_CON_TREE
  • ST_ASTER
  • ST_GYRO
  • ST_HISTOGRAM
Parameters
idpoint set id
coloricon color
widthicon line width
sizeicon size
symbolicon symbol
Returns
1 on success
-1 on error (point set not found)

Definition at line 273 of file gp2.c.

◆ GP_set_style_thematic()

int GP_set_style_thematic ( int  id,
int  layer,
const char *  color,
const char *  width,
const char *  size,
const char *  symbol,
struct Colors color_rules 
)

Set point set style for thematic mapping.

Updates also style for each geopoint.

Parameters
idpoint set id
layerlayer number for thematic mapping (-1 for undefined)
coloricon color column name
widthicon line width column name
sizeicon size column name
symbolicon symbol column name
colorspointer to Colors structure or NULL
Returns
1 on success
-1 on error (point set not found)

Definition at line 308 of file gp2.c.

◆ GP_set_trans()

void GP_set_trans ( int  id,
float  xtrans,
float  ytrans,
float  ztrans 
)

Set transformation params.

Parameters
idpoint set id
xtrans,ytrans,ztransx/y/z values

Definition at line 430 of file gp2.c.

References G_debug(), gp_get_site(), g_site::x_trans, g_site::y_trans, and g_site::z_trans.

◆ GP_set_zmode()

int GP_set_zmode ( int  id,
int  use_z 
)

Set z mode for point set.

Parameters
idpoint set id
use_zTRUE to use z-coordinaces when vector map is 3D
Returns
1 on success
0 vector map is not 3D
-1 on error (invalid point set id)

Definition at line 376 of file gp2.c.

References G_debug(), gp_get_site(), g_site::has_z, NULL, and g_site::use_z.

◆ GP_site_exists()

int GP_site_exists ( int  id)

Check if point set exists.

Parameters
idpoint set id
Returns
1 found
0 not found

Definition at line 36 of file gp2.c.

References G_debug(), gp_get_site(), and NULL.

Referenced by GP_delete_site().

◆ GP_str_to_marker()

int GP_str_to_marker ( const char *  str)

Determine point marker symbol for string.

Supported markers:

  • ST_X
  • ST_BOX
  • ST_SPHERE
  • ST_CUBE
  • ST_DIAMOND
  • ST_DEC_TREE
  • ST_CON_TREE
  • ST_ASTER
  • ST_GYRO
  • ST_HISTOGRAM
Parameters
strstring buffer
Returns
marker code (default: ST_SPHERE)

Definition at line 680 of file gp2.c.

References _, G_warning(), ST_ASTER, ST_BOX, ST_CON_TREE, ST_CUBE, ST_DEC_TREE, ST_DIAMOND, ST_GYRO, ST_HISTOGRAM, ST_SPHERE, and ST_X.

◆ GP_surf_is_selected()

int GP_surf_is_selected ( int  hp,
int  hs 
)

Check if surface is selected.

Parameters
hppoint set id
hssurface id
Returns
1 selected
0 not selected

Definition at line 548 of file gp2.c.

References g_site::drape_surf_id, G_debug(), gp_get_site(), and g_site::n_surfs.

Referenced by GP_select_surf(), and GP_unselect_surf().

◆ GP_unselect_surf()

int GP_unselect_surf ( int  hp,
int  hs 
)

Unselect surface.

Parameters
hppoint set id
hssurface id
Returns
1 surface unselected
-1 on error

Definition at line 510 of file gp2.c.

References g_site::drape_surf_id, G_debug(), gp_get_site(), GP_surf_is_selected(), and g_site::n_surfs.

◆ GP_unset_style_thematic()

int GP_unset_style_thematic ( int  id)

Make style for thematic mapping inactive.

Parameters
idpoint set id
Returns
1 on success
-1 on error (point set not found)

Definition at line 348 of file gp2.c.

References g_vect_style_thematic::active, G_debug(), gp_get_site(), NULL, and g_site::tstyle.