[GRASS-SVN] r48760 - in grass-addons/raster/r.pi: . r.pi.corearea
r.pi.corrwin r.pi.corrwindow r.pi.csr.mw r.pi.energy
r.pi.energy.iter r.pi.enn r.pi.enn.iter r.pi.export r.pi.fnn
r.pi.graph r.pi.graph.dec r.pi.graph.iter r.pi.graph.red
r.pi.grow r.pi.import r.pi.index r.pi.library r.pi.lm
r.pi.neigh r.pi.nlm r.pi.nlm.circ r.pi.nlm.stats r.pi.odc
r.pi.prob.mw r.pi.prox r.pi.rectangle r.pi.searchtime
r.pi.searchtime.iter r.pi.searchtime.mw
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Oct 12 09:20:01 EDT 2011
Author: mmetz
Date: 2011-10-12 06:20:01 -0700 (Wed, 12 Oct 2011)
New Revision: 48760
Added:
grass-addons/raster/r.pi/r.pi.library/helpers.c
grass-addons/raster/r.pi/r.pi.library/r_pi.h
Removed:
grass-addons/raster/r.pi/r.pi.corearea/helpers.c
grass-addons/raster/r.pi/r.pi.corearea/prop_method.c
grass-addons/raster/r.pi/r.pi.csr.mw/helpers.c
grass-addons/raster/r.pi/r.pi.energy.iter/helpers.c
grass-addons/raster/r.pi/r.pi.export/helpers.c
grass-addons/raster/r.pi/r.pi.import/helpers.c
grass-addons/raster/r.pi/r.pi.library/local_proto.h
grass-addons/raster/r.pi/r.pi.nlm.stats/helpers.c
grass-addons/raster/r.pi/r.pi.nlm/helpers.c
grass-addons/raster/r.pi/r.pi.odc/helpers.c
Modified:
grass-addons/raster/r.pi/Makefile
grass-addons/raster/r.pi/r.pi.corearea/Makefile
grass-addons/raster/r.pi/r.pi.corearea/func.c
grass-addons/raster/r.pi/r.pi.corearea/local_proto.h
grass-addons/raster/r.pi/r.pi.corearea/main.c
grass-addons/raster/r.pi/r.pi.corrwin/Makefile
grass-addons/raster/r.pi/r.pi.corrwindow/Makefile
grass-addons/raster/r.pi/r.pi.csr.mw/Makefile
grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h
grass-addons/raster/r.pi/r.pi.energy.iter/Makefile
grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h
grass-addons/raster/r.pi/r.pi.energy/Makefile
grass-addons/raster/r.pi/r.pi.energy/local_proto.h
grass-addons/raster/r.pi/r.pi.enn.iter/Makefile
grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h
grass-addons/raster/r.pi/r.pi.enn/Makefile
grass-addons/raster/r.pi/r.pi.enn/local_proto.h
grass-addons/raster/r.pi/r.pi.export/Makefile
grass-addons/raster/r.pi/r.pi.export/local_proto.h
grass-addons/raster/r.pi/r.pi.fnn/Makefile
grass-addons/raster/r.pi/r.pi.fnn/local_proto.h
grass-addons/raster/r.pi/r.pi.graph.dec/Makefile
grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h
grass-addons/raster/r.pi/r.pi.graph.iter/Makefile
grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h
grass-addons/raster/r.pi/r.pi.graph.red/Makefile
grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h
grass-addons/raster/r.pi/r.pi.graph/Makefile
grass-addons/raster/r.pi/r.pi.graph/local_proto.h
grass-addons/raster/r.pi/r.pi.grow/Makefile
grass-addons/raster/r.pi/r.pi.grow/local_proto.h
grass-addons/raster/r.pi/r.pi.import/Makefile
grass-addons/raster/r.pi/r.pi.import/local_proto.h
grass-addons/raster/r.pi/r.pi.index/Makefile
grass-addons/raster/r.pi/r.pi.index/local_proto.h
grass-addons/raster/r.pi/r.pi.library/Makefile
grass-addons/raster/r.pi/r.pi.library/draw.c
grass-addons/raster/r.pi/r.pi.library/stat_method.c
grass-addons/raster/r.pi/r.pi.lm/Makefile
grass-addons/raster/r.pi/r.pi.lm/local_proto.h
grass-addons/raster/r.pi/r.pi.neigh/Makefile
grass-addons/raster/r.pi/r.pi.neigh/local_proto.h
grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile
grass-addons/raster/r.pi/r.pi.nlm.circ/local_proto.h
grass-addons/raster/r.pi/r.pi.nlm.stats/Makefile
grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h
grass-addons/raster/r.pi/r.pi.nlm/Makefile
grass-addons/raster/r.pi/r.pi.nlm/local_proto.h
grass-addons/raster/r.pi/r.pi.odc/Makefile
grass-addons/raster/r.pi/r.pi.odc/local_proto.h
grass-addons/raster/r.pi/r.pi.prob.mw/Makefile
grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h
grass-addons/raster/r.pi/r.pi.prox/Makefile
grass-addons/raster/r.pi/r.pi.prox/local_proto.h
grass-addons/raster/r.pi/r.pi.rectangle/Makefile
grass-addons/raster/r.pi/r.pi.rectangle/local_proto.h
grass-addons/raster/r.pi/r.pi.searchtime.iter/Makefile
grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h
grass-addons/raster/r.pi/r.pi.searchtime.mw/Makefile
grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h
grass-addons/raster/r.pi/r.pi.searchtime/Makefile
grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h
Log:
first of many many steps in code clean up
Modified: grass-addons/raster/r.pi/Makefile
===================================================================
--- grass-addons/raster/r.pi/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ..
+MODULE_TOPDIR = ../..
PGM = r.pi
Modified: grass-addons/raster/r.pi/r.pi.corearea/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corearea/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.corearea
Modified: grass-addons/raster/r.pi/r.pi.corearea/func.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/func.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corearea/func.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -5,7 +5,7 @@
int out_fd;
DCELL *result;
- result = G_allocate_c_raster_buf();
+ result = (DCELL *) G_allocate_c_raster_buf();
/* write output */
/* open the new cellfile */
Deleted: grass-addons/raster/r.pi/r.pi.corearea/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corearea/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,93 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case TYPE_NOTHING:
- fprintf(stderr, "*");
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_d_buffer(DCELL * buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_array(DCELL * buffer, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%0.2f ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_fragments()
-{
- int f;
- Coords *p;
-
- for (f = 0; f < fragcount; f++) {
- fprintf(stderr, "frag%d: ", f);
- for (p = fragments[f]; p < fragments[f + 1]; p++) {
- fprintf(stderr, "(%d,%d), n=%d ", p->x, p->y, p->neighbors);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.corearea/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corearea/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -15,19 +16,10 @@
#define GLOBAL extern
#endif
-#define TYPE_NOTHING 0
-#define MAX_DOUBLE 1000000.0
-
typedef struct
{
int x, y;
- int neighbors;
-} Coords;
-
-typedef struct
-{
- int x, y;
} Position;
typedef struct
@@ -54,10 +46,6 @@
f_statmethod stat, double dist_weight);
void propagate(int neighbor_count, f_propmethod prop_method);
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-
/* prop_method.c */
DCELL linear(DCELL value, DCELL propcost);
DCELL exponential(DCELL value, DCELL propcost);
Modified: grass-addons/raster/r.pi/r.pi.corearea/main.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/main.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corearea/main.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -148,7 +148,7 @@
parm.stats->key = "stats";
parm.stats->type = TYPE_STRING;
parm.stats->required = YES;
- str = parm.stats->options = G_malloc(1024);
+ str = G_malloc(1024);
for (n = 0; statmethods[n].name; n++) {
if (n)
strcat(str, ",");
@@ -156,6 +156,7 @@
*str = 0;
strcat(str, statmethods[n].name);
}
+ parm.stats->options = str;
parm.stats->description =
_("Statistical method to perform on the values");
@@ -163,7 +164,7 @@
parm.propmethod->key = "propmethod";
parm.propmethod->type = TYPE_STRING;
parm.propmethod->required = YES;
- str = parm.propmethod->options = G_malloc(1024);
+ str = G_malloc(1024);
for (n = 0; propmethods[n].name; n++) {
if (n)
strcat(str, ",");
@@ -171,6 +172,7 @@
*str = 0;
strcat(str, propmethods[n].name);
}
+ parm.propmethod->options = str;
parm.propmethod->description = _("Propagation method");
parm.dist_weight = G_define_option();
Deleted: grass-addons/raster/r.pi/r.pi.corearea/prop_method.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.corearea/prop_method.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corearea/prop_method.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,17 +0,0 @@
-#include "local_proto.h"
-
-DCELL linear(DCELL value, DCELL propcost)
-{
- value -= propcost;
- return value >= 0.0 ? value : 0.0;
-}
-
-DCELL exponential(DCELL value, DCELL propcost)
-{
- if (propcost == 0.0) {
- return MAX_DOUBLE;
- }
- else {
- return value / propcost;
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.corrwin/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwin/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corrwin/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.corrwin
Modified: grass-addons/raster/r.pi/r.pi.corrwindow/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.corrwindow/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.corrwindow/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.corrwindow
Modified: grass-addons/raster/r.pi/r.pi.csr.mw/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.csr.mw/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.csr.mw/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.csr.mw
Deleted: grass-addons/raster/r.pi/r.pi.csr.mw/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.csr.mw/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.csr.mw/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,93 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case TYPE_NOTHING:
- fprintf(stderr, "*");
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_d_buffer(DCELL * buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_array(DCELL * buffer, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%0.2f ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_fragments()
-{
- int f;
- Coords *p;
-
- for (f = 0; f < fragcount; f++) {
- fprintf(stderr, "frag%d: ", f);
- for (p = fragments[f]; p < fragments[f + 1]; p++) {
- fprintf(stderr, "(%d,%d), n=%d ", p->x, p->y, p->neighbors);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.csr.mw/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef DCELL(*f_statmethod) (DCELL *, int);
Modified: grass-addons/raster/r.pi/r.pi.energy/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.energy/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.energy
Modified: grass-addons/raster/r.pi/r.pi.energy/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.energy/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.energy.iter/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy.iter/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.energy.iter/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.energy.iter
Deleted: grass-addons/raster/r.pi/r.pi.energy.iter/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy.iter/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.energy.iter/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,104 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case TYPE_NOTHING:
- fprintf(stderr, "*");
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_d_buffer(DCELL * buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_double_array(DCELL * buffer, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%0.2f ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_int_array(char *title, int *buffer, int size)
-{
- int i;
-
- fprintf(stderr, "%s: ", title);
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%d ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_fragments()
-{
- int f;
- Coords *p;
-
- for (f = 0; f < fragcount; f++) {
- fprintf(stderr, "frag%d: ", f);
- for (p = fragments[f]; p < fragments[f + 1]; p++) {
- fprintf(stderr, "(%d,%d), n=%d ", p->x, p->y, p->neighbors);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.energy.iter/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
@@ -54,17 +56,6 @@
typedef DCELL(*f_statmethod) (DCELL *, int);
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_double_array(DCELL * buffer, int size);
-void print_int_array(char *title, int *buffer, int size);
-void print_fragments();
-
/* frag.c */
void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
Modified: grass-addons/raster/r.pi/r.pi.enn/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.enn/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.enn
Modified: grass-addons/raster/r.pi/r.pi.enn/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.enn/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -21,6 +22,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef DCELL(*f_statmethod) (DCELL *, int);
Modified: grass-addons/raster/r.pi/r.pi.enn.iter/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn.iter/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.enn.iter/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.fragment.iter
Modified: grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.enn.iter/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -28,6 +29,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.export/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.export/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.export/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.export
Deleted: grass-addons/raster/r.pi/r.pi.export/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.export/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.export/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,94 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case NOTHING:
- fprintf(stderr, ".");
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_d_buffer(DCELL * buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_array(DCELL * buffer, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%0.2f ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_fragments()
-{
- int f;
- Coords *p;
-
- for (f = 0; f < fragcount; f++) {
- fprintf(stderr, "frag%d: ", f);
- for (p = fragments[f]; p < fragments[f + 1]; p++) {
- fprintf(stderr, "(%d,%d), n=%d, val=%0.2f;", p->x, p->y,
- p->neighbors, p->value);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.export/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.export/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.export/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
Modified: grass-addons/raster/r.pi/r.pi.fnn/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.fnn/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.fnn/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.fnn
Modified: grass-addons/raster/r.pi/r.pi.fnn/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.fnn/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.fnn/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -21,6 +22,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.graph/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.graph
Modified: grass-addons/raster/r.pi/r.pi.graph/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -21,6 +22,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.graph.dec/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.dec/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph.dec/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.graph.dec
Modified: grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph.dec/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -22,6 +23,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.graph.iter/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.iter/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph.iter/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.graph.iter
Modified: grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph.iter/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -21,6 +22,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.graph.red/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.red/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph.red/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.graph.red
Modified: grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.graph.red/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -8,6 +8,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -21,6 +22,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.grow/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.grow/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.grow/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.grow
Modified: grass-addons/raster/r.pi/r.pi.grow/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.grow/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.grow/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
Modified: grass-addons/raster/r.pi/r.pi.import/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.import/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.import/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.import
Deleted: grass-addons/raster/r.pi/r.pi.import/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.import/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.import/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,93 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case NOTHING:
- fprintf(stderr, ".");
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_d_buffer(DCELL * buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_array(DCELL * buffer, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%0.2f ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_fragments()
-{
- int f;
- Coords *p;
-
- for (f = 0; f < fragcount; f++) {
- fprintf(stderr, "frag%d: ", f);
- for (p = fragments[f]; p < fragments[f + 1]; p++) {
- fprintf(stderr, "(%d,%d), n=%d ", p->x, p->y, p->neighbors);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.import/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.import/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.import/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -14,6 +14,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -32,6 +33,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef DCELL(*f_statmethod) (DCELL *, int);
Modified: grass-addons/raster/r.pi/r.pi.index/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.index/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.index/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.index
Modified: grass-addons/raster/r.pi/r.pi.index/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.index/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.index/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -13,6 +13,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
extern void writeFrag(int row, int col, int nbr_cnt);
Modified: grass-addons/raster/r.pi/r.pi.library/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.library/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -4,7 +4,7 @@
LIB_NAME = grass_rpi.$(GRASS_VERSION_NUMBER)
-LIB_OBJS =
+LIB_OBJS := $(subst .c,.o,$(wildcard *.c))
DEPENDENCIES = $(GISDEP)
Modified: grass-addons/raster/r.pi/r.pi.library/draw.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/draw.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.library/draw.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-#include "local_proto.h"
+#include "r_pi.h"
inline void swap(int *a, int *b)
{
Copied: grass-addons/raster/r.pi/r.pi.library/helpers.c (from rev 48754, grass-addons/raster/r.pi/r.pi.corearea/helpers.c)
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/helpers.c (rev 0)
+++ grass-addons/raster/r.pi/r.pi.library/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -0,0 +1,93 @@
+#include "r_pi.h"
+
+int Round(double d)
+{
+ return d < 0 ? d - 0.5 : d + 0.5;
+}
+
+int Random(int max)
+{
+ return max <=
+ RAND_MAX ? rand() % max :
+ floor((((double) RAND_MAX + 1) / ((double) rand())) * max);
+}
+
+double Randomf()
+{
+ return ((double)rand()) / ((double)RAND_MAX);
+}
+
+void print_buffer(int *buffer, int sx, int sy)
+{
+ int x, y;
+
+ fprintf(stderr, "buffer:\n");
+ for (y = 0; y < sy; y++) {
+ for (x = 0; x < sx; x++) {
+ switch (buffer[x + y * sx]) {
+ case TYPE_NOTHING:
+ fprintf(stderr, "*");
+ break;
+ default:
+ if (buffer[x + y * sx] < 0) {
+ fprintf(stderr, "%d", buffer[x + y * sx]);
+ }
+ else {
+ fprintf(stderr, "%d", buffer[x + y * sx]);
+ }
+ break;
+ }
+ }
+ fprintf(stderr, "\n");
+ }
+}
+
+void print_d_buffer(DCELL * buffer, int sx, int sy)
+{
+ int x, y;
+
+ fprintf(stderr, "buffer:\n");
+ for (y = 0; y < sy; y++) {
+ for (x = 0; x < sx; x++) {
+ fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
+ }
+ fprintf(stderr, "\n");
+ }
+}
+
+void print_array(DCELL * buffer, int size)
+{
+ int i;
+
+ for (i = 0; i < size; i++) {
+ fprintf(stderr, "%0.2f ", buffer[i]);
+ }
+ fprintf(stderr, "\n");
+}
+
+void print_fragments(Coords** fragments, int fragcount)
+{
+ int f;
+ Coords *p;
+
+ for (f = 0; f < fragcount; f++) {
+ fprintf(stderr, "frag%d: ", f);
+ for (p = fragments[f]; p < fragments[f + 1]; p++) {
+ fprintf(stderr, "(%d,%d), n=%d, val=%0.2f;", p->x, p->y, p->neighbors, p->value);
+ }
+ fprintf(stderr, "\n");
+ }
+}
+
+void print_map(double *map, int size)
+{
+ int x, y;
+
+ fprintf(stderr, "map:\n");
+ for (y = 0; y < size; y++) {
+ for (x = 0; x < size; x++) {
+ fprintf(stderr, "%0.0f ", map[x + y * size]);
+ }
+ fprintf(stderr, "\n");
+ }
+}
Deleted: grass-addons/raster/r.pi/r.pi.library/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.library/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,49 +0,0 @@
-#ifndef LOCAL_PROTO_H
-#define LOCAL_PROTO_H
-
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <math.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include <grass/stats.h>
-
-#ifdef MAIN
-#define GLOBAL
-#else
-#define GLOBAL extern
-#endif
-
-#define TYPE_NOTHING -1
-
-typedef struct
-{
- int x, y;
- int neighbors;
-} Coords;
-
-/* draw.c */
-void draw_line(int *map, int val, int x1, int y1, int x2, int y2, int sx,
- int sy, int width);
-
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_array(DCELL * buffer, int size);
-void print_fragments();
-
-/* stat_method.c */
-DCELL average(DCELL * vals, int count);
-DCELL variance(DCELL * vals, int count);
-DCELL std_deviat(DCELL * vals, int count);
-DCELL median(DCELL * vals, int count);
-DCELL min(DCELL * vals, int count);
-DCELL max(DCELL * vals, int count);
-
-#endif /* LOCAL_PROTO_H */
-
Copied: grass-addons/raster/r.pi/r.pi.library/r_pi.h (from rev 48754, grass-addons/raster/r.pi/r.pi.library/local_proto.h)
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/r_pi.h (rev 0)
+++ grass-addons/raster/r.pi/r.pi.library/r_pi.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -0,0 +1,50 @@
+#ifndef R_PI_H
+#define R_PI_H
+
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <math.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include <grass/stats.h>
+
+#define TYPE_NOTHING -1
+
+#define MAX_DOUBLE 1000000.0
+
+typedef struct
+{
+ int x, y;
+ int neighbors;
+ double value;
+} Coords;
+
+
+/* draw.c */
+void draw_line(int *map, int val, int x1, int y1, int x2, int y2, int sx,
+ int sy, int width);
+
+/* helpers.c */
+int Round(double d);
+int Random(int max);
+double Randomf();
+void print_buffer(int *buffer, int sx, int sy);
+void print_d_buffer(DCELL * buffer, int sx, int sy);
+void print_map(double *map, int size);
+void print_array(DCELL * buffer, int size);
+void print_int_array(char *title, int *buffer, int size);
+void print_fragments(Coords **, int);
+
+/* stat_method.c */
+DCELL average(DCELL * vals, int count);
+DCELL variance(DCELL * vals, int count);
+DCELL std_deviat(DCELL * vals, int count);
+DCELL median(DCELL * vals, int count);
+DCELL min(DCELL * vals, int count);
+DCELL max(DCELL * vals, int count);
+DCELL linear(DCELL value, DCELL propcost);
+DCELL exponential(DCELL value, DCELL propcost);
+
+#endif /* LOCAL_PROTO_H */
+
Modified: grass-addons/raster/r.pi/r.pi.library/stat_method.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.library/stat_method.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.library/stat_method.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-#include "local_proto.h"
+#include "r_pi.h"
DCELL average(DCELL * vals, int count)
{
@@ -113,3 +113,19 @@
return res;
}
+
+DCELL linear(DCELL value, DCELL propcost)
+{
+ value -= propcost;
+ return value >= 0.0 ? value : 0.0;
+}
+
+DCELL exponential(DCELL value, DCELL propcost)
+{
+ if (propcost == 0.0) {
+ return MAX_DOUBLE;
+ }
+ else {
+ return value / propcost;
+ }
+}
Modified: grass-addons/raster/r.pi/r.pi.lm/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.lm/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.lm/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.lm
Modified: grass-addons/raster/r.pi/r.pi.lm/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.lm/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.lm/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -7,6 +7,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#include <math.h>
#define MAX_DOUBLE 1000000.0
Modified: grass-addons/raster/r.pi/r.pi.neigh/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.neigh/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.neigh/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.neigh
Modified: grass-addons/raster/r.pi/r.pi.neigh/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.neigh/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.neigh/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -5,6 +5,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -18,6 +19,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef DCELL(*f_func) (DCELL * values, int count);
Modified: grass-addons/raster/r.pi/r.pi.nlm/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.nlm
Deleted: grass-addons/raster/r.pi/r.pi.nlm/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,59 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case TYPE_NOTHING:
- fprintf(stderr, " * ", TYPE_NOTHING);
- break;
- case TYPE_NOGO:
- fprintf(stderr, " X ", TYPE_NOGO);
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d ", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, " %d ", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.nlm/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -7,6 +7,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#include <math.h>
#include <time.h>
Modified: grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm.circ/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.nlm.circ
Modified: grass-addons/raster/r.pi/r.pi.nlm.circ/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.circ/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm.circ/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -7,6 +7,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#include <math.h>
#include <time.h>
Modified: grass-addons/raster/r.pi/r.pi.nlm.stats/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.nlm.stats
Deleted: grass-addons/raster/r.pi/r.pi.nlm.stats/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,59 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case TYPE_NOTHING:
- fprintf(stderr, " * ", TYPE_NOTHING);
- break;
- case TYPE_NOGO:
- fprintf(stderr, " X ", TYPE_NOGO);
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d ", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, " %d ", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.nlm.stats/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -28,6 +29,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.odc/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.odc/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.odc/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.odc
Deleted: grass-addons/raster/r.pi/r.pi.odc/helpers.c
===================================================================
--- grass-addons/raster/r.pi/r.pi.odc/helpers.c 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.odc/helpers.c 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,96 +0,0 @@
-#include "local_proto.h"
-
-int Round(double d)
-{
- return d < 0 ? d - 0.5 : d + 0.5;
-}
-
-int Random(int max)
-{
- return max <=
- RAND_MAX ? rand() % max : floor((double)rand() /
- (double)(RAND_MAX + 1) * max);
-}
-
-double Randomf()
-{
- return ((double)rand()) / ((double)RAND_MAX);
-}
-
-void print_buffer(int *buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- switch (buffer[x + y * sx]) {
- case NOTHING:
- fprintf(stderr, ".");
- break;
- case NOGO:
- fprintf(stderr, "X");
- break;
- default:
- if (buffer[x + y * sx] < 0) {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- else {
- fprintf(stderr, "%d", buffer[x + y * sx]);
- }
- break;
- }
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_d_buffer(DCELL * buffer, int sx, int sy)
-{
- int x, y;
-
- fprintf(stderr, "buffer:\n");
- for (y = 0; y < sy; y++) {
- for (x = 0; x < sx; x++) {
- fprintf(stderr, "%0.2f ", buffer[y * sx + x]);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_array(DCELL * buffer, int size)
-{
- int i;
-
- for (i = 0; i < size; i++) {
- fprintf(stderr, "%0.2f ", buffer[i]);
- }
- fprintf(stderr, "\n");
-}
-
-void print_fragments()
-{
- int f;
- Coords *p;
-
- for (f = 0; f < fragcount; f++) {
- fprintf(stderr, "frag%d: ", f);
- for (p = fragments[f]; p < fragments[f + 1]; p++) {
- fprintf(stderr, "(%d,%d), n=%d ", p->x, p->y, p->neighbors);
- }
- fprintf(stderr, "\n");
- }
-}
-
-void print_map(double *map, int size)
-{
- int x, y;
-
- fprintf(stderr, "map:\n");
- for (y = 0; y < size; y++) {
- for (x = 0; x < size; x++) {
- fprintf(stderr, "%0.0f ", map[x + y * size]);
- }
- fprintf(stderr, "\n");
- }
-}
Modified: grass-addons/raster/r.pi/r.pi.odc/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.odc/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.odc/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -28,6 +29,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.prob.mw/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.prob.mw/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.prob.mw/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.prob.mw
Modified: grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.prob.mw/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef DCELL(*f_statmethod) (DCELL *, int);
Modified: grass-addons/raster/r.pi/r.pi.prox/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.prox/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.prox/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.prox
Modified: grass-addons/raster/r.pi/r.pi.prox/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.prox/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.prox/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -10,6 +10,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
/* frag.c */
Modified: grass-addons/raster/r.pi/r.pi.rectangle/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.rectangle/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.rectangle/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.rectangle
Modified: grass-addons/raster/r.pi/r.pi.rectangle/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.rectangle/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.rectangle/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -7,6 +7,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#include <math.h>
#include <time.h>
Modified: grass-addons/raster/r.pi/r.pi.searchtime/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.searchtime/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.searchtime
Modified: grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.searchtime/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.searchtime.iter/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.iter/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.searchtime.iter/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.searchtime.iter
Modified: grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.searchtime.iter/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
Modified: grass-addons/raster/r.pi/r.pi.searchtime.mw/Makefile
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.mw/Makefile 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.searchtime.mw/Makefile 2011-10-12 13:20:01 UTC (rev 48760)
@@ -1,4 +1,4 @@
-MODULE_TOPDIR = ../..
+MODULE_TOPDIR = ../../..
PGM = r.pi.searchtime.mw
Modified: grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h
===================================================================
--- grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h 2011-10-12 12:06:22 UTC (rev 48759)
+++ grass-addons/raster/r.pi/r.pi.searchtime.mw/local_proto.h 2011-10-12 13:20:01 UTC (rev 48760)
@@ -9,6 +9,7 @@
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/stats.h>
+#include "../r.pi.library/r_pi.h"
#ifdef MAIN
#define GLOBAL
@@ -27,6 +28,7 @@
{
int x, y;
int neighbors;
+ double value;
} Coords;
typedef struct
@@ -51,16 +53,6 @@
typedef DCELL(*f_statmethod) (DCELL *, int);
-/* helpers.c */
-int Round(double d);
-int Random(int max);
-double Randomf();
-void print_buffer(int *buffer, int sx, int sy);
-void print_d_buffer(DCELL * buffer, int sx, int sy);
-void print_map(double *map, int size);
-void print_array(DCELL * buffer, int size);
-void print_fragments();
-
/* frag.c */
void writeFragments(int *flagbuf, int nrows, int ncols, int nbr_cnt);
More information about the grass-commit
mailing list