From: Kaj-Michael Lang Date: Mon, 16 Jul 2007 11:02:52 +0000 (+0300) Subject: Start to move lat/lon conversion functions/helpers here X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29935bc5ab0a66c55d566eb9262d697079452c51;p=mapper Start to move lat/lon conversion functions/helpers here --- diff --git a/src/latlon.c b/src/latlon.c new file mode 100644 index 0000000..472a983 --- /dev/null +++ b/src/latlon.c @@ -0,0 +1,26 @@ +#define _GNU_SOURCE + +#include +#include + +#include "osm.h" + +/* Int ranges for integerized lat/lon */ +#define LATLON_MAX 2147483646 +#define LATLON_MIN -2147483646 + +/* Convert latitude to integerized+mercator projected value */ +gint32 +lat2mp_int(gdouble lat) +{ +return lat > 85.051128779 ? LATLON_MAX : lat < -85.051128779 ? LATLON_MIN : + lrint(log(tan(M_PI_4l+lat*M_PIl/360))/M_PIl*LATLON_MAX); +} + +/* Convert longitude to integerized+mercator projected value */ +gint32 +lon2mp_int(gdouble lon) +{ +return lrint(lon/180*LATLON_MAX); +} + diff --git a/src/latlon.h b/src/latlon.h new file mode 100644 index 0000000..774756d --- /dev/null +++ b/src/latlon.h @@ -0,0 +1,5 @@ +#include + +gint32 lon2mp_int(gdouble lon); +gint32 lat2mp_int(gdouble lat); +