/* Copyright 2002 Daniel Egnor.  See LICENSE file.
 *
 * Basic primitives for calculating distances on the Earth's surface.
 * These aren't super sophisticated; they assume a sphere. */
#ifndef GEODESY_H
#define GEODESY_H

/* Returns kilometers >= 0 between two points */
double geo_distance(
        double start_latitude,double start_longitude,
        double end_latitude,double end_longitude);

/* Returns 0 <= degrees < 360 heading from one point to another */
double geo_heading(
        double start_latitude,double start_longitude,
        double end_latitude,double end_longitude);

/* Returns the latitude after moving a certain distance at a certain heading */
double geo_latitude(
        double start_latitude,
        double heading /* degrees */,
        double distance /* kilometers */);

/* Returns the longitude after moving a certain distance at a certain heading;
 * supply the latitude from geo_latitude(). */
double geo_longitude(
        double start_latitude,double start_longitude,
        double end_latitude,
        double heading /* degrees */,
        double distance /* kilometers */);

/* Mercator transform for E/W, forward and inverse.
 * -1 <= easting <= 1 */
double geo_mercator_easting(double longitude);
double geo_mercator_longitude(double easting);

/* Mercator transform for N/S, forward and inverse.
 * -inf < northing < inf -- yes, the Mercator projection is infinite. */
double geo_mercator_northing(double latitude);
double geo_mercator_latitude(double northing);

#endif

