distance calculations

Darrell McCauley mccauley at ecn.purdue.edu
Sat Jul 31 23:29:49 EDT 1993


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