Commit c1042732 authored by Philip Withnall's avatar Philip Withnall Committed by Philip Withnall
Browse files

reverse: Fix type of lat/lon parameters to backend reverse query method

The backend methods are documented as taking parameters which follow the
Telepathy Location mapping
(https://telepathy.freedesktop.org/spec/Connection_Interface_Location.html#Mapping:Location),
or alternatively XEP-0080.

Both of these specify that the ‘lat’ and ‘lon’ parameters are numeric,
not numeric strings. Since the GeocodeBackend interface has not been
released yet, fix the implementation to use a GValue holding a gdouble,
rather than a GValue holding a string representation of a double.

https://bugzilla.gnome.org/show_bug.cgi?id=774631
parent 7ec672c6
......@@ -794,6 +794,8 @@ get_resolve_uri_for_params (GeocodeNominatim *self,
char *params, *uri;
GeocodeNominatimPrivate *priv;
const GValue *lat, *lon;
char lat_str[G_ASCII_DTOSTR_BUF_SIZE];
char lon_str[G_ASCII_DTOSTR_BUF_SIZE];
priv = geocode_nominatim_get_instance_private (self);
......@@ -810,8 +812,13 @@ get_resolve_uri_for_params (GeocodeNominatim *self,
ht = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
g_hash_table_insert (ht, (gpointer) "lat", (gpointer) g_value_get_string (lat));
g_hash_table_insert (ht, (gpointer) "lon", (gpointer) g_value_get_string (lon));
g_ascii_dtostr (lat_str, G_ASCII_DTOSTR_BUF_SIZE,
g_value_get_double (lat));
g_ascii_dtostr (lon_str, G_ASCII_DTOSTR_BUF_SIZE,
g_value_get_double (lon));
g_hash_table_insert (ht, (gpointer) "lat", lat_str);
g_hash_table_insert (ht, (gpointer) "lon", lon_str);
g_hash_table_insert (ht, (gpointer) "format", (gpointer) "json");
g_hash_table_insert (ht, (gpointer) "email",
......
......@@ -110,13 +110,13 @@ ensure_backend (GeocodeReverse *object)
}
static GValue *
str_to_value (const gchar *str)
double_to_value (gdouble val)
{
GValue *value;
value = g_new0 (GValue, 1);
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, str);
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, val);
return value;
}
......@@ -132,21 +132,14 @@ static GHashTable *
_geocode_location_to_params (GeocodeLocation *location)
{
GHashTable *ht;
char lat[G_ASCII_DTOSTR_BUF_SIZE];
char lon[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr (lat,
G_ASCII_DTOSTR_BUF_SIZE,
geocode_location_get_latitude (location));
g_ascii_dtostr (lon,
G_ASCII_DTOSTR_BUF_SIZE,
geocode_location_get_longitude (location));
/* Semantics from http://xmpp.org/extensions/xep-0080.html */
ht = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
(GDestroyNotify) free_value);
g_hash_table_insert (ht, (gpointer) "lat", str_to_value (lat));
g_hash_table_insert (ht, (gpointer) "lon", str_to_value (lon));
g_hash_table_insert (ht, (gpointer) "lat",
double_to_value (geocode_location_get_latitude (location)));
g_hash_table_insert (ht, (gpointer) "lon",
double_to_value (geocode_location_get_longitude (location)));
return ht;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment