distance calculations

Darrell McCauley mccauley at ecn.purdue.edu
Wed Aug 4 00:19:54 EDT 1993


Does any have any comments on this? I hasten to
report this as a bug (and waste someone's time
at OGI) if I am doing something silly, but
after having a few nights to sleep on it, I
still don't see anything wrong.  --Darrell

I wrote on 31 Jul 93:
>
>I'm trying to do distance calculations. Here's a full sample
>program:
>
>#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
>wrong.
>
>I am linking the math library and $(GISLIB) when compiling.  
>
>G_distance should just return factor*hypot (x1-x2,y1-y2), where
>G_begin_distance_calculations() initializes factor to be 1.0
>(for utm and x-y).
>
>What's going on here? %-|




More information about the grass-dev mailing list