[geocode-glib] lib: Export function to create query
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] lib: Export function to create query
- Date: Sun, 25 Nov 2012 02:00:41 +0000 (UTC)
commit 36c5da513bff1fd1901659af75dff571189aa100
Author: Bastien Nocera <hadess hadess net>
Date: Sat Nov 24 23:25:37 2012 +0100
lib: Export function to create query
The GeoPlanet API used by the forward geocoding is too
imprecise when we expect to use a single result. So we
export some more function to allow using the Place Finder
API (that the reverse geocoding usually uses).
geocode-glib/geocode-glib-private.h | 2 ++
geocode-glib/geocode-reverse.c | 15 ++++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/geocode-glib/geocode-glib-private.h b/geocode-glib/geocode-glib-private.h
index b1cc57e..586e62b 100644
--- a/geocode-glib/geocode-glib-private.h
+++ b/geocode-glib/geocode-glib-private.h
@@ -38,6 +38,8 @@ GHashTable *_geocode_parse_resolve_json (const char *contents,
GError **error);
GList *_geocode_parse_search_json (const char *contents,
GError **error);
+GFile *_get_resolve_query_for_params (GHashTable *orig_ht,
+ gboolean reverse);
char *_geocode_glib_cache_path_for_query (GFile *query);
gboolean _geocode_glib_cache_save (GFile *query,
diff --git a/geocode-glib/geocode-reverse.c b/geocode-glib/geocode-reverse.c
index 257166b..0eb082a 100644
--- a/geocode-glib/geocode-reverse.c
+++ b/geocode-glib/geocode-reverse.c
@@ -443,20 +443,21 @@ dup_ht (GHashTable *ht)
return ret;
}
-static GFile *
-get_resolve_query_for_params (GeocodeReverse *object,
- GError **error)
+GFile *
+_get_resolve_query_for_params (GHashTable *orig_ht,
+ gboolean reverse)
{
GFile *ret;
GHashTable *ht;
char *locale;
char *params, *uri;
- ht = dup_ht (object->priv->ht);
+ ht = dup_ht (orig_ht);
g_hash_table_insert (ht, "appid", YAHOO_APPID);
g_hash_table_insert (ht, "flags", "QJT");
- g_hash_table_insert (ht, "gflags", "R");
+ if (reverse)
+ g_hash_table_insert (ht, "gflags", "R");
locale = NULL;
if (g_hash_table_lookup (ht, "locale") == NULL) {
@@ -510,7 +511,7 @@ geocode_reverse_resolve_async (GeocodeReverse *object,
user_data,
geocode_reverse_resolve_async);
- query = get_resolve_query_for_params (object, &error);
+ query = _get_resolve_query_for_params (object->priv->ht, TRUE);
if (query == NULL) {
g_simple_async_result_take_error (simple, error);
g_simple_async_result_complete_in_idle (simple);
@@ -599,7 +600,7 @@ geocode_reverse_resolve (GeocodeReverse *object,
g_return_val_if_fail (GEOCODE_IS_REVERSE (object), NULL);
- query = get_resolve_query_for_params (object, error);
+ query = _get_resolve_query_for_params (object->priv->ht, TRUE);
if (query == NULL)
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]