#include <stdio.h>

#include "utils/palloc.h"

#include "math.h"

typedef struct point {
  double x, y;
} point;

char *index();


struct point *stopoint(s)

char *s;
{
  int lat= atoi(s);
  int lng;
  char *p;
  struct point	*pnt= (struct point*) palloc(sizeof(struct point));
  int north;
  int east;

  if ((p= index(s, 'n')) == 0) {
    p= index(s, 's');
    north= -1;
  } else
    north= 1;

  if (index(s, 'w'))
    east= -1;
  else
    east= 1;

  lng= atoi(p+1);

  pnt->x= east * ((lng/100) + ((lng % 100) / 60.0));
  pnt->y= north * ((lat/100) + ((lat % 100) / 60.0));

  return pnt;
}
