// magdev.c
// (C) 2009 Philip Endecott
// See http://chezphil.org/libmagdev/
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "libmagdev.h"


void usage()
{
  fprintf(stderr,"Compute magnetic deviation (aka declination) using the IGRF model.\n"
                 "usage: magdev <longditude> <latitude>\n"
                 "  E and N are positive, W and S are negative.\n"
                 "  Positive result means magnetic N is E of true N, negative means it is W.\n");
  exit(1);
}


int main(int argc, char* argv[])
{
  if (argc!=3) {
    usage();
  }

  float lng = strtof(argv[1],NULL);
  float lat = strtof(argv[2],NULL);

  float dev = magdev(time(NULL),lng,lat,0);

  printf("%f\n",dev);

  return 0;
}

