GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-57a646b4a4
iclass_perimeter.c File Reference

Imagery library - functions for wx.iclass. More...

#include <stdlib.h>
#include <grass/vector.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "iclass_local_proto.h"
Include dependency graph for iclass_perimeter.c:

Go to the source code of this file.

Macros

#define extrema(x, y, z)   (((x < y) && (z < y)) || ((x > y) && (z > y)))
 
#define non_extrema(x, y, z)   (((x < y) && (y < z)) || ((x > y) && (y > z)))
 

Functions

int vector2perimeters (struct Map_info *Map, const char *layer_name, int category, IClass_perimeter_list *perimeters, struct Cell_head *band_region)
 Creates perimeters from vector areas of given category. More...
 
void free_perimeters (IClass_perimeter_list *perimeters)
 Frees all perimeters in list of perimeters. More...
 
int make_perimeter (struct line_pnts *points, IClass_perimeter *perimeter, struct Cell_head *band_region)
 Creates one perimeter from vector area. More...
 
int edge2perimeter (IClass_perimeter *perimeter, int x0, int y0, int x1, int y1)
 Converts edge to cells. More...
 
void perimeter_add_point (IClass_perimeter *perimeter, int x, int y)
 Adds point to perimeter. More...
 
int edge_order (const void *aa, const void *bb)
 Determines points order during sorting. More...
 

Detailed Description

Imagery library - functions for wx.iclass.

Computation based on training areas for supervised classification. Based on i.class module (GRASS 6).

Vector map with training areas is used to determine corresponding cells by computing cells on area perimeter.

Copyright (C) 1999-2007, 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
David Satnik, Central Washington University (original author)
Markus Neteler <neteler itc.it> (i.class module)
Bernhard Reiter <bernhard intevation.de> (i.class module)
Brad Douglas <rez touchofmadness.com>(i.class module)
Glynn Clements <glynn gclements.plus.com> (i.class module)
Hamish Bowman <hamish_b yahoo.com> (i.class module)
Jan-Oliver Wagner <jan intevation.de> (i.class module)
Anna Kratochvilova <kratochanna gmail.com> (rewriting for wx.iclass)
Vaclav Petras <wenzeslaus gmail.com> (rewriting for wx.iclass)

Definition in file iclass_perimeter.c.

Macro Definition Documentation

◆ extrema

#define extrema (   x,
  y,
 
)    (((x < y) && (z < y)) || ((x > y) && (z > y)))

Definition at line 36 of file iclass_perimeter.c.

◆ non_extrema

#define non_extrema (   x,
  y,
 
)    (((x < y) && (y < z)) || ((x > y) && (y > z)))

Definition at line 37 of file iclass_perimeter.c.

Function Documentation

◆ edge2perimeter()

int edge2perimeter ( IClass_perimeter *  perimeter,
int  x0,
int  y0,
int  x1,
int  y1 
)

Converts edge to cells.

It rasterizes edge given by two vertices. Resterized points are added to perimeter.

Parameters
perimeterperimeter
x0,y0first edge point row and cell
x1,y1second edge point row and cell
Returns
1 on success
0 on error

Definition at line 329 of file iclass_perimeter.c.

◆ edge_order()

int edge_order ( const void *  aa,
const void *  bb 
)

Determines points order during sorting.

Parameters
aafirst IClass_point
bbsecond IClass_point

Definition at line 382 of file iclass_perimeter.c.

◆ free_perimeters()

void free_perimeters ( IClass_perimeter_list *  perimeters)

Frees all perimeters in list of perimeters.

It also frees list of perimeters itself.

Parameters
perimeterslist of perimeters

Definition at line 134 of file iclass_perimeter.c.

References G_debug(), and G_free().

Referenced by I_iclass_analysis(), and vector2perimeters().

◆ make_perimeter()

int make_perimeter ( struct line_pnts points,
IClass_perimeter *  perimeter,
struct Cell_head band_region 
)

Creates one perimeter from vector area.

Parameters
pointslist of vertices represting area
[out]perimeterperimeter
band_regionregion which determines perimeter cells
Returns
1 on success
0 on error

Definition at line 156 of file iclass_perimeter.c.

Referenced by vector2perimeters().

◆ perimeter_add_point()

void perimeter_add_point ( IClass_perimeter *  perimeter,
int  x,
int  y 
)

Adds point to perimeter.

perimeter has to have allocated space for points member.

Parameters
perimeterperimeter
x,ypoint row and cell

Definition at line 365 of file iclass_perimeter.c.

References G_debug(), x, and line_pnts::y.

◆ vector2perimeters()

int vector2perimeters ( struct Map_info Map,
const char *  layer_name,
int  category,
IClass_perimeter_list *  perimeters,
struct Cell_head band_region 
)

Creates perimeters from vector areas of given category.

Parameters
Mapvector map
layer_namelayer name (within vector map)
categoryvector category (cat column value)
[out]perimeterslist of perimeters
band_regionregion which determines perimeter cells
Returns
number of areas of given cat
-1 on error

Definition at line 51 of file iclass_perimeter.c.

References _, free_perimeters(), G_calloc, G_debug(), G_warning(), make_perimeter(), Vect_area_alive(), Vect_destroy_line_struct(), Vect_get_area_cat(), Vect_get_area_points(), Vect_get_field_number(), Vect_get_num_areas(), and Vect_new_line_struct().

Referenced by I_iclass_analysis().