Skip to content

Commit

Permalink
apply .clang-format (#2712)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Dec 22, 2022
1 parent e0fe056 commit b5a70ba
Show file tree
Hide file tree
Showing 709 changed files with 31,497 additions and 34,039 deletions.
4 changes: 1 addition & 3 deletions raster/r.basins.fill/local_proto.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.basins.fill
Expand All @@ -14,13 +13,12 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#ifndef __LOCAL_PROTO_H__
#define __LOCAL_PROTO_H__

/* read_map.c */
CELL *read_map(const char *, int, int, int);


#endif /* __LOCAL_PROTO_H__ */
13 changes: 6 additions & 7 deletions raster/r.basins.fill/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.basins.fill
Expand All @@ -14,7 +13,7 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

/*====================================================================*/
/* program to propagate the link label into the hillslope areas; */
Expand All @@ -34,7 +33,6 @@

#define NOMASK 1


int main(int argc, char *argv[])
{
int partfd;
Expand All @@ -58,8 +56,7 @@ int main(int argc, char *argv[])

drain_opt = G_define_standard_option(G_OPT_R_INPUT);
drain_opt->key = "cnetwork";
drain_opt->description =
_("Name of input coded stream network raster map");
drain_opt->description = _("Name of input coded stream network raster map");

ridge_opt = G_define_standard_option(G_OPT_R_INPUT);
ridge_opt->key = "tnetwork";
Expand All @@ -81,7 +78,8 @@ int main(int argc, char *argv[])

drain_name = drain_opt->answer;

/* this isn't a nice thing to do. Rast_align_window() should be used first */
/* this isn't a nice thing to do. Rast_align_window() should be used first
*/
Rast_get_cellhd(drain_name, "", &window);
Rast_set_window(&window);

Expand All @@ -97,7 +95,8 @@ int main(int argc, char *argv[])

partfd = Rast_open_c_new(part_name);

/* run through file and set streams to zero at locations where ridges exist */
/* run through file and set streams to zero at locations where ridges exist
*/
for (row = 0; row < nrows; row++) {
for (col = 0; col < ncols; col++)
if (ridge[row * ncols + col] != 0)
Expand Down
8 changes: 3 additions & 5 deletions raster/r.basins.fill/read_map.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.basins.fill
Expand All @@ -14,14 +13,13 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
#include "local_proto.h"


CELL *read_map(const char *name, int nomask, int nrows, int ncols)
{
int fd;
Expand All @@ -30,7 +28,7 @@ CELL *read_map(const char *name, int nomask, int nrows, int ncols)
void (*get_row)(int, CELL *, int);

/* allocate entire map */
map = (CELL *) G_malloc(nrows * ncols * sizeof(CELL));
map = (CELL *)G_malloc(nrows * ncols * sizeof(CELL));

/* open the map */
fd = Rast_open_old(name, "");
Expand All @@ -45,7 +43,7 @@ CELL *read_map(const char *name, int nomask, int nrows, int ncols)

for (row = 0; row < nrows; row++) {
G_percent(row, nrows, 10);
(*get_row) (fd, map + row * ncols, row);
(*get_row)(fd, map + row * ncols, row);
}
G_percent(nrows, nrows, 10);

Expand Down
14 changes: 6 additions & 8 deletions raster/r.buffer/distance.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.buffer
Expand All @@ -17,15 +16,14 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#ifndef __DISTANCE_H__
#define __DISTANCE_H__

#include <grass/gis.h>

struct Distance
{
struct Distance {
int ncols;
int prev_ncols;
double dist;
Expand All @@ -50,11 +48,11 @@ extern double meters_to_grid;
extern double ns_to_ew_squared;
extern int count_rows_with_data;

#define MAPINDEX(r,c) ((size_t)(r) * window.cols + (c))
#define ZONE_INCR 2
#define MAPINDEX(r, c) ((size_t)(r)*window.cols + (c))
#define ZONE_INCR 2

#define FEET_TO_METERS 0.3048
#define MILES_TO_METERS 1609.344
#define FEET_TO_METERS 0.3048
#define MILES_TO_METERS 1609.344
#define NAUT_MILES_TO_METERS 1852.0
#define KILOMETERS_TO_METERS 1000.0

Expand Down
2 changes: 0 additions & 2 deletions raster/r.buffer/execute.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.buffer
Expand All @@ -23,7 +22,6 @@
#include "local_proto.h"
#include <grass/glocale.h>


int execute_distance(void)
{
int row, col, nrows;
Expand Down
28 changes: 12 additions & 16 deletions raster/r.buffer/find_dist.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.buffer
Expand All @@ -17,31 +16,29 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#include <grass/gis.h>
#include "distance.h"
#include "local_proto.h"

static int cur_row;


int begin_distance(int row)
{
cur_row = row;

if (window.proj == PROJECTION_LL)
G_set_geodesic_distance_lat1(window.north -
(row + .5) * window.ns_res);
G_set_geodesic_distance_lat1(window.north - (row + .5) * window.ns_res);

return 0;
}

/* Determine number of columns for each distance zone
* (-1 means doesn't occur)
* Returns: first zone to occur (-1 if none)
* Note: modifies distances structure (global)
*/
/* Determine number of columns for each distance zone
* (-1 means doesn't occur)
* Returns: first zone to occur (-1 if none)
* Note: modifies distances structure (global)
*/

int find_distances(int row)
{
Expand All @@ -51,8 +48,7 @@ int find_distances(int row)
double ns_dist;

if (window.proj == PROJECTION_LL)
G_set_geodesic_distance_lat2(window.north -
(row + .5) * window.ns_res);
G_set_geodesic_distance_lat2(window.north - (row + .5) * window.ns_res);

/* if at same row, distance is constant across each cell */

Expand All @@ -64,11 +60,11 @@ int find_distances(int row)
distances[i].ncols = find_ll_distance_ncols(i);
}
}
else { /* note - see parse_dist.c for more info */
else { /* note - see parse_dist.c for more info */

for (i = 0; i < ndist; i++)
distances[i].ncols = distances[i].prev_ncols
= (int)distances[i].dist;
distances[i].ncols = distances[i].prev_ncols =
(int)distances[i].dist;
}
}
else {
Expand Down Expand Up @@ -123,7 +119,7 @@ int find_ll_distance_ncols(int i)
lon = window.ew_res * col;

d = G_geodesic_distance_lon_to_lon(0.0, lon);
if (d > dist) { /*backup */
if (d > dist) { /*backup */
while (d > dist) {
if (--col < 0)
break;
Expand Down
3 changes: 1 addition & 2 deletions raster/r.buffer/init.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.buffer
Expand All @@ -17,7 +16,7 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#include "distance.h"
#include <grass/gis.h>
Expand Down
3 changes: 1 addition & 2 deletions raster/r.buffer/local_proto.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.buffer
Expand All @@ -17,7 +16,7 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#ifndef __LOCAL_PROTO_H__
#define __LOCAL_PROTO_H__
Expand Down
50 changes: 23 additions & 27 deletions raster/r.buffer/main.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@

/***************************************************************************
*
* MODULE: r.buffer
*
* AUTHOR(S): Michael Shapiro, US Army Construction Engineering Research Laboratory
* James Westervelt, US Army CERL
*
* PURPOSE: This program creates distance zones from non-zero
* cells in a grid layer. Distances are specified in
* meters (on the command-line). Window does not have to
* have square cells. Works both for planimetric (UTM,
* State Plane) and lat-long.
*
* COPYRIGHT: (c) 2006 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.
*
**************************************************************************/
*
* MODULE: r.buffer
*
* AUTHOR(S): Michael Shapiro, US Army Construction Engineering Research
* Laboratory James Westervelt, US Army CERL
*
* PURPOSE: This program creates distance zones from non-zero
* cells in a grid layer. Distances are specified in
* meters (on the command-line). Window does not have to
* have square cells. Works both for planimetric (UTM,
* State Plane) and lat-long.
*
* COPYRIGHT: (c) 2006 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.
*
**************************************************************************/

#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -90,8 +89,7 @@ int main(int argc, char *argv[])

flag2 = G_define_flag();
flag2->key = 'z';
flag2->description =
_("Ignore zero (0) data cells instead of NULL cells");
flag2->description = _("Ignore zero (0) data cells instead of NULL cells");

if (G_parser(argc, argv))
exit(EXIT_FAILURE);
Expand All @@ -104,7 +102,7 @@ int main(int argc, char *argv[])
zone_list = opt3->answers;
units = opt4->answer;

ZEROFLAG = 0; /* default: use NULL for non-data cells */
ZEROFLAG = 0; /* default: use NULL for non-data cells */
ZEROFLAG = (flag2->answer);

mapset = G_find_raster2(input, "");
Expand All @@ -130,7 +128,6 @@ int main(int argc, char *argv[])
if (!(count = parse_distances(zone_list, to_meters)))
G_fatal_error(_("Parse distances error"));


/* need to keep track of distance zones - in memory.
* process MAX_DIST at a time
*
Expand Down Expand Up @@ -164,12 +161,11 @@ int main(int argc, char *argv[])
/* write map history (meta data) */
Rast_short_history(output, "raster", &hist);
Rast_set_history(&hist, HIST_DATSRC_1, input);
Rast_append_format_history(&hist, "Buffer distance%s:",
ndist > 1 ? "s" : "");
Rast_append_format_history(&hist,
"Buffer distance%s:", ndist > 1 ? "s" : "");
Rast_append_format_history(&hist, " %s %s", opt3->answer, units);
Rast_command_history(&hist);
Rast_write_history(output, &hist);


exit(EXIT_SUCCESS);
}
11 changes: 5 additions & 6 deletions raster/r.buffer/parse_dist.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/****************************************************************************
*
* MODULE: r.buffer
Expand All @@ -17,7 +16,7 @@
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
****************************************************************************/
****************************************************************************/

#include <stdlib.h>
#include "distance.h"
Expand All @@ -26,15 +25,15 @@
static int cmp(const void *, const void *);
static int scan_dist(char *, double *);


int parse_distances(char **zone_list, double to_meters)
{
double dist;
double ew2 = 0.0;
int i;
int count;

for (count = 0; zone_list[count]; count++) ;
for (count = 0; zone_list[count]; count++)
;
if (count <= 0)
return 0;

Expand All @@ -51,8 +50,8 @@ int parse_distances(char **zone_list, double to_meters)

for (i = 0; i < count; i++) {
if (!scan_dist(zone_list[i], &dist)) {
G_warning(_("%s: %s - illegal distance specification"),
pgm_name, zone_list[i]);
G_warning(_("%s: %s - illegal distance specification"), pgm_name,
zone_list[i]);
return 0;
}
else {
Expand Down

0 comments on commit b5a70ba

Please sign in to comment.