distance calculations

Michael Shapiro shapiro at zorro.cecer.army.mil
Wed Aug 4 21:49:25 EDT 1993

In <9308010329.AA07425 at brier.ecn.purdue.edu> mccauley at ecn.purdue.edu (Darrell McCauley) writes:

>I'm trying to do distance calculations. Here's a full sample

>#include <math.h>
>#include "gis.h"

>int main (argc, argv)
>  char **argv;
>  int argc;
>  double x1=8.0,y1=7.0,x2=6.0,y2=5.0;
>  G_gisinit (argv[0]);
>  printf ("projection: %d\n", G_begin_distance_calculations());
>  printf ("G_distance: %g\n", G_distance (x1,y1,x2,y2));
>  printf ("     hypot: %g\n", hypot (x1-x2,y1-y2));

>Is there any thing wrong with this? I run this simple
>program under (x,y), LL, and utm, I get the same answers:

>    GRASS 4.1 > simple
>    projection: 0
>    G_distance: 8
>         hypot: 2.82843

>(that is, except for the projection). A distance of 8 is clearly

Declare: double G_distance();

I probably forgot to put this declaration into "gis.h"
Michael Shapiro               shapiro at zorro.cecer.army.mil
U.S. Army CERL                (217) 373-7277
P.O. Box 9005 
Champaign, Ill. 61826-9005

More information about the grass-dev mailing list