]> err.no Git - mapper/commitdiff
Merge branch 'master' of ssh://git.tal.org/home/git/mapper
authorKaj-Michael Lang <milang@tal.org>
Wed, 14 May 2008 08:44:21 +0000 (11:44 +0300)
committerKaj-Michael Lang <milang@tal.org>
Wed, 14 May 2008 08:44:21 +0000 (11:44 +0300)
src/gtkmap-marshal.list
src/latlon.c
src/latlon.h

index b9b8548b2b310769883caf08aaac64f42fb24079..a73aaeb0b3d22596384b41b4b2723657e6e59f35 100644 (file)
@@ -1 +1,2 @@
 VOID:DOUBLE,DOUBLE
+VOID:UINT,UINT
index 1ce5b6a20b54e22ef784e5cca32871dabb4271af..dceab08620fb891e04f71b8390c440e86507dae3 100644 (file)
 #include "latlon.h"
 #include "osm.h"
 
-/* Int ranges for integerized lat/lon */
-#define LATLON_MAX 2147483646
-#define LATLON_MIN -2147483646
-
-#define EARTH_RADIUS (3440.06479f)
-
 void
 latlon_init(void)
 {
@@ -154,13 +148,13 @@ return lrint(lon/180*LATLON_MAX);
 }
 
 gdouble
-mp_int2lon(gint lon)
+mp_int2lon(gint32 lon)
 {
 return (gdouble)lon/LATLON_MAX*180;
 }
 
 gdouble
-mp_int2lat(gint lat)
+mp_int2lat(gint32 lat)
 {
 return 0;
 }
index 01b722da738f6616991a2e2c342192e203fb6e2c..683daa17c330ee3c4df85290485765a6f3c9e9b0 100644 (file)
@@ -9,22 +9,19 @@
 #define LATLON_MIN -2147483646
 #define EARTH_RADIUS (3440.06479f)
 
-#define PI   (3.14159265358979323846f)
 #define MERCATOR_SPAN (-6.28318377773622f)
 #define MERCATOR_TOP (3.14159188886811f)
 
 #define latlon2unit(lat, lon, unitx, unity) { \
        gdouble tmp; \
-       unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f; \
-       tmp = sinf(lat * (PI / 180.f)); \
-       unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN) \
-               * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); \
+       unitx=lrint((lon + 180.f) * (WORLD_SIZE_UNITS / 360.f)); \
+       tmp=sin(lat * (M_PIl / 180.f)); \
+       unity=lrint((WORLD_SIZE_UNITS / MERCATOR_SPAN) * (log((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP)); \
 }
 
 #define unit2latlon(unitx, unity, lat, lon) { \
-       (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f; \
-       (lat) = (360.f * (atanf(expf(((unity) * (MERCATOR_SPAN / WORLD_SIZE_UNITS)) \
-               + MERCATOR_TOP)))) * (1.f / PI) - 90.f; \
+       (lon)=((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f; \
+       (lat)=(360.f * (atan(exp(((unity) * (MERCATOR_SPAN / WORLD_SIZE_UNITS)) + MERCATOR_TOP)))) * (1.f / M_PIl) - 90.f; \
 }
 
 typedef enum {
@@ -61,6 +58,9 @@ void latlon_init(void);
 gint32 lon2mp_int(gdouble lon);
 gint32 lat2mp_int(gdouble lat);
 
+gdouble mp_int2lon(gint32 lon);
+gdouble mp_int2lat(gint32 lat);
+
 gdouble calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2);
 gdouble calculate_ddistance(gint lat1, gint lon1, gint lat2, gint lon2);
 gulong calculate_idistance(gint lat1, gint lon1, gint lat2, gint lon2);