From c0c6626c128b5b7a0a40844ffa1ffe47d3a80b47 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Mon, 14 Dec 2009 21:57:42 +0100 Subject: [PATCH] Fix URL formatting issue Previous URL formatting code was locale dependent. On a french locale, this code cannot works as geonames does not understand coordinate values. --- src/geonamessearch.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/geonamessearch.c b/src/geonamessearch.c index 47ea1a8e..c08ff09a 100644 --- a/src/geonamessearch.c +++ b/src/geonamessearch.c @@ -34,7 +34,7 @@ #include "util.h" #include "curl_download.h" -#define GEONAMES_WIKIPEDIA_URL_FMT "http://ws.geonames.org/wikipediaBoundingBoxJSON?formatted=true&north=%f&south=%f&east=%f&west=%f" +#define GEONAMES_WIKIPEDIA_URL_FMT "http://ws.geonames.org/wikipediaBoundingBoxJSON?formatted=true&north=%s&south=%s&east=%s&west=%s" #define GEONAMES_SEARCH_URL_FMT "http://ws.geonames.org/searchJSON?formatted=true&style=medium&maxRows=10&lang=en&q=%s" #define GEONAMES_COUNTRY_PATTERN "\"countryName\": \"" #define GEONAMES_LONGITUDE_PATTERN "\"lng\": " @@ -612,7 +612,16 @@ void a_geonames_wikipedia_box(VikWindow *vw, VikTrwLayer *vtl, VikLayersPanel *v VikWaypoint *wiki_wp; found_geoname *wiki_geoname; - uri = g_strdup_printf(GEONAMES_WIKIPEDIA_URL_FMT, maxmin[0].lat, maxmin[1].lat, maxmin[0].lon, maxmin[1].lon); + /* encode doubles in a C locale */ + gchar *north = a_coords_dtostr(maxmin[0].lat); + gchar *south = a_coords_dtostr(maxmin[1].lat); + gchar *east = a_coords_dtostr(maxmin[0].lon); + gchar *west = a_coords_dtostr(maxmin[1].lon); + uri = g_strdup_printf(GEONAMES_WIKIPEDIA_URL_FMT, north, south, east, west); + g_free(north); north = NULL; + g_free(south); south = NULL; + g_free(east); east = NULL; + g_free(west); west = NULL; tmpname = download_url(uri); if (!tmpname) { none_found(vw); -- 2.39.5