aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSungTaek Hong <sth253.hong@samsung.com>2016-03-22 15:58:18 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-22 15:58:24 -0700
commit635b02a440bc0d95d4eb043e1ee4dd55181ce93b (patch)
treed0b9d004edbcda3bd52e18d3f562832a9f000501
parenttheme: fix non-fixed parts. (diff)
downloadelementary-635b02a440bc0d95d4eb043e1ee4dd55181ce93b.tar.gz
map: separate name, route source logic
Summary: - So far, elm_map only provides Open Street Map and lacks ability to expand to other map providers since it's xml parse only fits into that of OSM. - This patch is to make route and name source same to tile source, which supports other map tile providers. Reviewers: woohyun, cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3303 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/elm_map.c31
-rw-r--r--src/lib/elm_widget_map.h6
-rw-r--r--src/modules/test_map/mod.c19
3 files changed, 49 insertions, 7 deletions
diff --git a/src/lib/elm_map.c b/src/lib/elm_map.c
index b4f915245..b64129fda 100644
--- a/src/lib/elm_map.c
+++ b/src/lib/elm_map.c
@@ -274,12 +274,13 @@ static const Source_Tile src_tiles[] =
_scale_cb}
};
+static void _kml_parse(Elm_Map_Route *r);
// FIXME: Fix more open sources
static const Source_Route src_routes[] =
{
- {"Yours", _yours_url_cb} // http://www.yournavigation.org/
- //{"Monav", _monav_url_cb},
- //{"ORS", _ors_url_cb}, // http://www.openrouteservice.org
+ {"Yours", _yours_url_cb, _kml_parse} // http://www.yournavigation.org/
+ //{"Monav", _monav_url_cb, _kml_parse},
+ //{"ORS", _ors_url_cb, _kml_parse)}, // http://www.openrouteservice.org
};
// Scale in meters
@@ -289,10 +290,12 @@ static const double _scale_tb[] =
20000, 10000, 5000, 2000, 1000, 500, 500, 200, 100, 50, 20, 10, 5, 2, 1
};
+static void _name_parse(Elm_Map_Name *n);
+static void _name_list_parse(Elm_Map_Name_List *nl);
// FIXME: Add more open sources
static const Source_Name src_names[] =
{
- {"Nominatim", _nominatim_url_cb}
+ {"Nominatim", _nominatim_url_cb, _name_parse, _name_list_parse}
};
static int id_num = 1;
@@ -3068,7 +3071,7 @@ _route_cb(void *data,
route->job = NULL;
if (status == 200)
{
- _kml_parse(route);
+ sd->src_route->route_parse_cb(route);
INF("Route request success from (%lf, %lf) to (%lf, %lf)",
route->flon, route->flat, route->tlon, route->tlat);
if (route->cb) route->cb(route->data, sd->obj, route);
@@ -3105,7 +3108,7 @@ _name_cb(void *data,
name->job = NULL;
if (status == 200)
{
- _name_parse(name);
+ sd->src_name->name_parse_cb(name);
INF("Name request success address:%s, lon:%lf, lat:%lf",
name->address, name->lon, name->lat);
if (name->cb) name->cb(name->data, sd->obj, name);
@@ -3141,7 +3144,7 @@ _name_list_cb(void *data,
name_list->job = NULL;
if (status == 200)
{
- _name_list_parse(name_list);
+ sd->src_name->name_list_parse_cb(name_list);
INF("Name List request success address");
if (name_list->cb)
name_list->cb(name_list->data, wd->obj,
@@ -3476,6 +3479,8 @@ _source_mod_cb(Eina_Module *m,
Elm_Map_Module_Tile_Geo_to_Coord_Func geo_to_coord;
Elm_Map_Module_Tile_Coord_to_Geo_Func coord_to_geo;
Elm_Map_Module_Route_Url_Func route_url_cb;
+ Elm_Map_Module_Name_Parse_Func name_parse_cb;
+ Elm_Map_Module_Name_List_Parse_Func name_list_parse_cb;
Elm_Map_Module_Name_Url_Func name_url_cb;
EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE);
@@ -3539,6 +3544,9 @@ _source_mod_cb(Eina_Module *m,
s = ELM_NEW(Source_Route);
s->name = name_cb();
s->url_cb = route_url_cb;
+ s->route_parse_cb = eina_module_symbol_get(m, "map_module_route_source_parse");
+ if (!s->route_parse_cb)
+ s->route_parse_cb = _kml_parse;
sd->src_routes = eina_list_append(sd->src_routes, s);
}
@@ -3551,6 +3559,12 @@ _source_mod_cb(Eina_Module *m,
s = ELM_NEW(Source_Name);
s->name = name_cb();
s->url_cb = name_url_cb;
+ s->name_parse_cb = eina_module_symbol_get(m, "map_module_name_source_parse");
+ if (!s->name_parse_cb)
+ s->name_parse_cb = _name_parse;
+ s->name_list_parse_cb = eina_module_symbol_get(m, "map_module_name_list_source_parse");
+ if (!s->name_list_parse_cb)
+ s->name_list_parse_cb = _name_list_parse;
sd->src_names = eina_list_append(sd->src_names, s);
}
return EINA_TRUE;
@@ -3622,6 +3636,7 @@ _source_all_load(Elm_Map_Data *sd)
src_route = ELM_NEW(Source_Route);
src_route->name = eina_stringshare_add(src_routes[idx].name);
src_route->url_cb = src_routes[idx].url_cb;
+ src_route->route_parse_cb = src_routes[idx].route_parse_cb;
sd->src_routes = eina_list_append(sd->src_routes, src_route);
}
// Load from hard coded NAME source
@@ -3630,6 +3645,8 @@ _source_all_load(Elm_Map_Data *sd)
src_name = ELM_NEW(Source_Name);
src_name->name = eina_stringshare_add(src_names[idx].name);
src_name->url_cb = src_names[idx].url_cb;
+ src_name->name_parse_cb = src_names[idx].name_parse_cb;
+ src_name->name_list_parse_cb = src_names[idx].name_list_parse_cb;
sd->src_names = eina_list_append(sd->src_names, src_name);
}
diff --git a/src/lib/elm_widget_map.h b/src/lib/elm_widget_map.h
index 9d0652c4f..b9e96eafe 100644
--- a/src/lib/elm_widget_map.h
+++ b/src/lib/elm_widget_map.h
@@ -58,11 +58,14 @@ typedef char *(*Elm_Map_Module_Route_Url_Func)(const Evas_Object *,
double,
double,
double);
+typedef void (*Elm_Map_Module_Route_Parse_Func)(Elm_Map_Route *);
typedef char *(*Elm_Map_Module_Name_Url_Func)(const Evas_Object *,
int,
const char *,
double,
double);
+typedef void (*Elm_Map_Module_Name_Parse_Func)(Elm_Map_Name *n);
+typedef void (*Elm_Map_Module_Name_List_Parse_Func)(Elm_Map_Name_List *nl);
typedef struct _Source_Tile Source_Tile;
// FIXME: Currently tile size must be 256*256
@@ -83,6 +86,7 @@ struct _Source_Route
{
Eina_Stringshare *name;
Elm_Map_Module_Route_Url_Func url_cb;
+ Elm_Map_Module_Route_Parse_Func route_parse_cb;
};
typedef struct _Source_Name Source_Name;
@@ -90,6 +94,8 @@ struct _Source_Name
{
Eina_Stringshare *name;
Elm_Map_Module_Name_Url_Func url_cb;
+ Elm_Map_Module_Name_Parse_Func name_parse_cb;
+ Elm_Map_Module_Name_List_Parse_Func name_list_parse_cb;
};
typedef struct _Path Path;
diff --git a/src/modules/test_map/mod.c b/src/modules/test_map/mod.c
index 39bc5248b..df300f7ff 100644
--- a/src/modules/test_map/mod.c
+++ b/src/modules/test_map/mod.c
@@ -3,6 +3,7 @@
#endif
#include "Elementary.h"
+#include "elm_widget_map.h"
#include <Eina.h>
EAPI Eina_Stringshare *
@@ -38,6 +39,12 @@ map_module_route_source_get(void)
return NULL;
}
+EAPI void
+map_module_route_source_parse(Elm_Map_Route *r EINA_UNUSED)
+{
+ return;
+}
+
EAPI char *
map_module_route_url_get(Evas_Object *obj EINA_UNUSED, const char *type_name EINA_UNUSED, int method EINA_UNUSED, double flon EINA_UNUSED, double flat EINA_UNUSED, double tlon EINA_UNUSED, double tlat EINA_UNUSED)
{
@@ -50,6 +57,18 @@ map_module_name_url_get(Evas_Object *obj EINA_UNUSED, int method EINA_UNUSED, co
return strdup("");
}
+EAPI void
+map_module_name_source_parse(Elm_Map_Name *n EINA_UNUSED)
+{
+ return;
+}
+
+EAPI void
+map_module_name_list_source_parse(Elm_Map_Name_List *nl EINA_UNUSED)
+{
+ return;
+}
+
EAPI Eina_Bool
map_module_tile_geo_to_coord(const Evas_Object *obj EINA_UNUSED, int zoom EINA_UNUSED, double lon EINA_UNUSED, double lat EINA_UNUSED, int size EINA_UNUSED, int *x EINA_UNUSED, int *y EINA_UNUSED)
{