From 65c1bdd44d46606a19ff884f8599817b0d6cd3d2 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Tue, 7 Aug 2007 11:27:52 +0300 Subject: [PATCH] Use double when deadling with lat/lon --- src/latlon.c | 4 ++-- src/mapper-types.h | 4 ++-- src/poi.h | 8 ++++---- src/utils.c | 14 +++++++------- src/utils.h | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/latlon.c b/src/latlon.c index 01f46d4..5b14311 100644 --- a/src/latlon.c +++ b/src/latlon.c @@ -39,8 +39,8 @@ return lrint(sqrt((double)((lat1-lat2)*(lat1-lat2)+(lon1-lon2)*(lon1-lon2)))); * Calculate the distance between two lat/lon pairs. The distance is returned * in kilometer. */ -gfloat -calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2) +gdouble +calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2) { gdouble dlat, dlon, slat, slon, a; diff --git a/src/mapper-types.h b/src/mapper-types.h index 8aa9edc..434aacc 100644 --- a/src/mapper-types.h +++ b/src/mapper-types.h @@ -182,8 +182,8 @@ gchar *SPEED_LOCATION_TEXT[SPEED_LOCATION_ENUM_COUNT]; /** A lat/lon/alt position */ typedef struct _Position Position; struct _Position { - gfloat lat; - gfloat lon; + gdouble lat; + gdouble lon; gfloat altitude; }; diff --git a/src/poi.h b/src/poi.h index 485cfc5..b58dea1 100644 --- a/src/poi.h +++ b/src/poi.h @@ -23,8 +23,8 @@ struct _PoiDb { typedef struct _PoiData PoiData; struct _PoiData { - gfloat lat; - gfloat lon; + gdouble lat; + gdouble lon; gchar *name; gchar *desc; }; @@ -34,8 +34,8 @@ typedef struct _PoiInfo PoiInfo; struct _PoiInfo { guint poi_id; guint cat_id; - gfloat lat; - gfloat lon; + gdouble lat; + gdouble lon; gchar *label; gchar *desc; gchar *cat_label; diff --git a/src/utils.c b/src/utils.c index 229e19b..3f3ee3e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -53,9 +53,9 @@ if (!fork()) { } #if 0 -void latlon2unit(gfloat lat, gfloat lon, gint *unitx_, gint *unity_) +void latlon2unit(gdouble lat, gdouble lon, gint *unitx_, gint *unity_) { - gfloat tmp; + gdouble tmp; gint unitx = &unitx_; gint unity = &unity_; @@ -66,7 +66,7 @@ void latlon2unit(gfloat lat, gfloat lon, gint *unitx_, gint *unity_) * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP); } -void unit2latlon(gint unitx, gint unity, gfloat *lat, gfloat *lon) +void unit2latlon(gint unitx, gint unity, gdouble *lat, gdouble *lon) { (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f; (lat) = (360.f * (atanf(expf(((unity) @@ -76,11 +76,11 @@ void unit2latlon(gint unitx, gint unity, gfloat *lat, gfloat *lon) #endif void -deg_format(DegFormat degformat, gfloat coor, gchar * scoor, gchar neg_char, +deg_format(DegFormat degformat, gdouble coor, gchar * scoor, gchar neg_char, gchar pos_char) { - gfloat min; - gfloat acoor = fabs(coor); + gdouble min; + gdouble acoor = fabs(coor); printf("%s()\n", __PRETTY_FUNCTION__); switch (degformat) { @@ -123,7 +123,7 @@ deg_format(DegFormat degformat, gfloat coor, gchar * scoor, gchar neg_char, */ void integerize_data() { - gfloat tmp; + gdouble tmp; printf("%s()\n", __PRETTY_FUNCTION__); latlon2unit(_gps.lat, _gps.lon, _pos.unitx, _pos.unity); diff --git a/src/utils.h b/src/utils.h index 0e6d5ca..efd0b58 100644 --- a/src/utils.h +++ b/src/utils.h @@ -175,7 +175,7 @@ }; #define latlon2unit(lat, lon, unitx, unity) { \ - gfloat tmp; \ + 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) \ @@ -339,8 +339,8 @@ if (_http_proxy_host) { \ gint download_comparefunc(const ProgressUpdateInfo * a, const ProgressUpdateInfo * b, gpointer user_data); -gfloat calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2); -void deg_format(DegFormat degformat, gfloat coor, gchar *scoor, gchar neg_char, gchar pos_char); +gdouble calculate_distance(gdouble lat1, gdouble lon1, gdouble lat2, gdouble lon2); +void deg_format(DegFormat degformat, gdouble coor, gchar *scoor, gchar neg_char, gchar pos_char); void integerize_data(); #endif -- 2.39.5