summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorJonathan Atton <jonathan.atton@gmail.com>2011-06-25 14:30:10 +0000
committerJonathan Atton <jonathan.atton@gmail.com>2011-06-25 14:30:10 +0000
commit6b88bee7e53ca8e72a27e18e43240378f0b0d932 (patch)
treecf4430ebf86d867d6c03b6bd932b72d3385d64f8 /legacy
parent8cf97b3ef8a345be9bd555f2945c259484237040 (diff)
elm_map: use emap
SVN revision: 60684
Diffstat (limited to 'legacy')
-rw-r--r--legacy/elementary/configure.ac31
-rw-r--r--legacy/elementary/src/bin/test_map.c7
-rw-r--r--legacy/elementary/src/lib/Elementary.h.in12
-rw-r--r--legacy/elementary/src/lib/Makefile.am2
-rw-r--r--legacy/elementary/src/lib/elm_main.c9
-rw-r--r--legacy/elementary/src/lib/elm_map.c164
6 files changed, 86 insertions, 139 deletions
diff --git a/legacy/elementary/configure.ac b/legacy/elementary/configure.ac
index e4e4b0dbdc..39f107872f 100644
--- a/legacy/elementary/configure.ac
+++ b/legacy/elementary/configure.ac
@@ -420,6 +420,36 @@ if test "x$want_elementary_eweather" = "xyes" -a "x$have_elementary_eweather" =
420fi 420fi
421AC_SUBST(ELM_EWEATHER_DEF) 421AC_SUBST(ELM_EWEATHER_DEF)
422 422
423ELM_EMAP_DEF="#undef"
424have_elementary_emap="no"
425want_elementary_emap="auto"
426AC_ARG_ENABLE([emap],
427 [AC_HELP_STRING([--disable-emap], [disable emap support. @<:@default=detect@:>@])],
428 [want_elementary_emap=$enableval], [])
429
430if test "x$want_elementary_emap" != "xno"; then
431 PKG_CHECK_MODULES([ELEMENTARY_EMAP],
432 [
433 emap
434 ],
435 [
436 AC_DEFINE(HAVE_ELEMENTARY_EMAP, 1, [EMap support for Elementary])
437 have_elementary_emap="yes"
438 ELM_EMAP_DEF="#define"
439 requirement_elm="emap ${requirement_elm}"
440 ],
441 [have_elementary_emap="no"]
442 )
443else
444 have_elementary_emap="no"
445fi
446if test "x$want_elementary_emap" = "xyes" -a "x$have_elementary_emap" = "xno"; then
447 AC_MSG_ERROR([Emap support requested, but no emap found by pkg-config.])
448fi
449AC_SUBST(ELM_EMAP_DEF)
450
451
452
423ELM_ETHUMB_DEF="#undef" 453ELM_ETHUMB_DEF="#undef"
424have_elementary_ethumb="no" 454have_elementary_ethumb="no"
425want_elementary_ethumb="auto" 455want_elementary_ethumb="auto"
@@ -559,6 +589,7 @@ echo " Features:"
559echo " EDBus..................: ${have_elementary_edbus}" 589echo " EDBus..................: ${have_elementary_edbus}"
560echo " EFreet.................: ${have_elementary_efreet}" 590echo " EFreet.................: ${have_elementary_efreet}"
561echo " EWeather...............: ${have_elementary_eweather}" 591echo " EWeather...............: ${have_elementary_eweather}"
592echo " EMap...................: ${have_elementary_emap}"
562echo " Ethumb.................: ${have_elementary_ethumb}" 593echo " Ethumb.................: ${have_elementary_ethumb}"
563echo " Quick Launch...........: ${have_fork}" 594echo " Quick Launch...........: ${have_fork}"
564echo " eio....................: ${have_eio}" 595echo " eio....................: ${have_eio}"
diff --git a/legacy/elementary/src/bin/test_map.c b/legacy/elementary/src/bin/test_map.c
index 2cddf060d3..33ba6984b5 100644
--- a/legacy/elementary/src/bin/test_map.c
+++ b/legacy/elementary/src/bin/test_map.c
@@ -59,7 +59,12 @@ my_map_gpx_fileselector_done(void *data, Evas_Object *obj __UNUSED__, void *even
59 if (selected) 59 if (selected)
60 { 60 {
61 printf("Selected file: %s\n", selected); 61 printf("Selected file: %s\n", selected);
62 track = elm_map_track_add(data, selected); 62#ifdef HAVE_ELEMENTARY_EMAP
63 EMap_Route *emap = emap_route_gpx_new(selected);
64 track = elm_map_track_add(data, emap);
65#else
66 printf("libEMap is required !\n");
67#endif
63 } 68 }
64 evas_object_del(fs_win); 69 evas_object_del(fs_win);
65} 70}
diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in
index c734d33e10..cecc357d5d 100644
--- a/legacy/elementary/src/lib/Elementary.h.in
+++ b/legacy/elementary/src/lib/Elementary.h.in
@@ -98,6 +98,10 @@ Pants
98@ELM_ALLOCA_H_DEF@ ELM_ALLOCA_H 98@ELM_ALLOCA_H_DEF@ ELM_ALLOCA_H
99@ELM_LIBINTL_H_DEF@ ELM_LIBINTL_H 99@ELM_LIBINTL_H_DEF@ ELM_LIBINTL_H
100 100
101#ifdef HAVE_CONFIG_H
102# include "elementary_config.h"
103#endif
104
101/* Standard headers for standard system calls etc. */ 105/* Standard headers for standard system calls etc. */
102#include <stdio.h> 106#include <stdio.h>
103#include <stdlib.h> 107#include <stdlib.h>
@@ -164,6 +168,10 @@ Pants
164# include <Ethumb_Client.h> 168# include <Ethumb_Client.h>
165#endif 169#endif
166 170
171#ifdef HAVE_ELEMENTARY_EMAP
172# include <EMap.h>
173#endif
174
167#ifdef EAPI 175#ifdef EAPI
168# undef EAPI 176# undef EAPI
169#endif 177#endif
@@ -4161,7 +4169,9 @@ EAPI Elm_Genlist_Item *elm_genlist_item_sorted_insert(Evas_Object *obj, const El
4161 EAPI void elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy) EINA_ARG_NONNULL(1, 2, 3, 4); 4169 EAPI void elm_map_rotate_get(const Evas_Object *obj, double *degree, Evas_Coord *cx, Evas_Coord *cy) EINA_ARG_NONNULL(1, 2, 3, 4);
4162 EAPI void elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) EINA_ARG_NONNULL(1); 4170 EAPI void elm_map_wheel_disabled_set(Evas_Object *obj, Eina_Bool disabled) EINA_ARG_NONNULL(1);
4163 EAPI Eina_Bool elm_map_wheel_disabled_get(const Evas_Object *obj) EINA_ARG_NONNULL(1); 4171 EAPI Eina_Bool elm_map_wheel_disabled_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
4164 EAPI Elm_Map_Track *elm_map_track_add(Evas_Object *obj, const char *gpx_file) EINA_ARG_NONNULL(1); 4172#ifdef HAVE_ELEMENTARY_EMAP
4173 EAPI Elm_Map_Track *elm_map_track_add(Evas_Object *obj, EMap_Route *emap) EINA_ARG_NONNULL(1);
4174#endif
4165 EAPI void elm_map_track_remove(Elm_Map_Track *track) EINA_ARG_NONNULL(1); 4175 EAPI void elm_map_track_remove(Elm_Map_Track *track) EINA_ARG_NONNULL(1);
4166 EAPI void elm_map_track_color_set(Elm_Map_Track *track, int r, int g , int b, int a) EINA_ARG_NONNULL(1); 4176 EAPI void elm_map_track_color_set(Elm_Map_Track *track, int r, int g , int b, int a) EINA_ARG_NONNULL(1);
4167 EAPI void elm_map_track_color_get(const Elm_Map_Track *track, int *r, int *g , int *b, int *a) EINA_ARG_NONNULL(1); 4177 EAPI void elm_map_track_color_get(const Elm_Map_Track *track, int *r, int *g , int *b, int *a) EINA_ARG_NONNULL(1);
diff --git a/legacy/elementary/src/lib/Makefile.am b/legacy/elementary/src/lib/Makefile.am
index dbfee077de..879373131a 100644
--- a/legacy/elementary/src/lib/Makefile.am
+++ b/legacy/elementary/src/lib/Makefile.am
@@ -21,6 +21,7 @@ AM_CPPFLAGS = \
21@ELEMENTARY_EDBUS_CFLAGS@ \ 21@ELEMENTARY_EDBUS_CFLAGS@ \
22@ELEMENTARY_EFREET_CFLAGS@ \ 22@ELEMENTARY_EFREET_CFLAGS@ \
23@ELEMENTARY_ETHUMB_CFLAGS@ \ 23@ELEMENTARY_ETHUMB_CFLAGS@ \
24@ELEMENTARY_EMAP_CFLAGS@ \
24@EVIL_CFLAGS@ \ 25@EVIL_CFLAGS@ \
25@EFL_PTHREAD_CFLAGS@ 26@EFL_PTHREAD_CFLAGS@
26 27
@@ -130,6 +131,7 @@ libelementary_la_LIBADD = \
130@ELEMENTARY_EDBUS_LIBS@ \ 131@ELEMENTARY_EDBUS_LIBS@ \
131@ELEMENTARY_EFREET_LIBS@ \ 132@ELEMENTARY_EFREET_LIBS@ \
132@ELEMENTARY_ETHUMB_LIBS@ \ 133@ELEMENTARY_ETHUMB_LIBS@ \
134@ELEMENTARY_EMAP_LIBS@ \
133@EVIL_LIBS@ \ 135@EVIL_LIBS@ \
134@EFL_PTHREAD_LIBS@ 136@EFL_PTHREAD_LIBS@
135libelementary_la_LDFLAGS = \ 137libelementary_la_LDFLAGS = \
diff --git a/legacy/elementary/src/lib/elm_main.c b/legacy/elementary/src/lib/elm_main.c
index 0ce5f0ca20..ebdbeb5969 100644
--- a/legacy/elementary/src/lib/elm_main.c
+++ b/legacy/elementary/src/lib/elm_main.c
@@ -608,6 +608,10 @@ elm_quicklaunch_init(int argc,
608 608
609 eet_init(); 609 eet_init();
610 ecore_init(); 610 ecore_init();
611
612#ifdef HAVE_ELEMENTARY_EMAP
613 emap_init();
614#endif
611 ecore_app_args_set(argc, (const char **)argv); 615 ecore_app_args_set(argc, (const char **)argv);
612 616
613 memset(_elm_policies, 0, sizeof(_elm_policies)); 617 memset(_elm_policies, 0, sizeof(_elm_policies));
@@ -745,6 +749,11 @@ elm_quicklaunch_shutdown(void)
745 _elm_unneed_e_dbus(); 749 _elm_unneed_e_dbus();
746 _elm_unneed_ethumb(); 750 _elm_unneed_ethumb();
747 ecore_file_shutdown(); 751 ecore_file_shutdown();
752
753#ifdef HAVE_ELEMENTARY_EMAP
754 emap_shutdown();
755#endif
756
748 ecore_shutdown(); 757 ecore_shutdown();
749 eet_shutdown(); 758 eet_shutdown();
750 759
diff --git a/legacy/elementary/src/lib/elm_map.c b/legacy/elementary/src/lib/elm_map.c
index 69cd7941af..8b50c547ff 100644
--- a/legacy/elementary/src/lib/elm_map.c
+++ b/legacy/elementary/src/lib/elm_map.c
@@ -291,22 +291,13 @@ struct _Elm_Map_Track
291{ 291{
292 Widget_Data *wd; 292 Widget_Data *wd;
293 293
294 Path_Node *n; 294#ifdef HAVE_ELEMENTARY_EMAP
295 Path_Waypoint *w; 295 EMap_Route *emap;
296#endif
296 297
297 int x, y; 298 int x, y;
298 double flon, flat, tlon, tlat;
299 299
300 Eina_List *nodes, *path; 300 Eina_List *nodes, *path;
301 Eina_List *waypoint;
302
303 struct {
304 int node_count;
305 int waypoint_count;
306 const char *nodes;
307 const char *waypoints;
308 double distance; /* unit : km */
309 } info;
310 301
311 struct { 302 struct {
312 int r; 303 int r;
@@ -840,15 +831,15 @@ obj_rotate_zoom(void *data, Evas_Object *obj)
840static void 831static void
841track_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh) 832track_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh)
842{ 833{
834#ifdef HAVE_ELEMENTARY_EMAP
843 ELM_CHECK_WIDTYPE(obj, widtype); 835 ELM_CHECK_WIDTYPE(obj, widtype);
844 Widget_Data *wd = elm_widget_data_get(obj); 836 Widget_Data *wd = elm_widget_data_get(obj);
845 Eina_List *lr, *lp, *ln; 837 Eina_List *lr, *lp, *ln;
846 Path_Node *n; 838 EMap_Route_Node *n;
847 Evas_Object *p; 839 Evas_Object *p;
848 Elm_Map_Track *t; 840 Elm_Map_Track *t;
849 int nodes; 841 int nodes;
850 int x, y, rx, ry; 842 int x, y, rx, ry;
851 double a;
852 843
853 if (!wd) return; 844 if (!wd) return;
854 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize; 845 Evas_Coord size = pow(2.0, wd->zoom)*wd->tsize;
@@ -861,35 +852,29 @@ track_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py,
861 } 852 }
862 853
863 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL); 854 evas_object_geometry_get(wd->rect, &rx, &ry, NULL, NULL);
864 nodes = eina_list_count(t->nodes); 855 nodes = eina_list_count(emap_route_nodes_get(t->emap));
865 856
866 EINA_LIST_FOREACH(t->nodes, ln, n) 857 int i = 0;
858 EINA_LIST_FOREACH(emap_route_nodes_get(t->emap), ln, n)
867 { 859 {
868 if (t->inbound) 860 if (t->inbound)
869 { 861 {
870 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y); 862 elm_map_utils_convert_geo_into_coord(wd->obj, emap_route_node_lon_get(n), emap_route_node_lat_get(n), size, &x, &y);
871 if ((x >= px - ow) && (x <= (px + ow*2)) && 863 if ((x >= px - ow) && (x <= (px + ow*2)) &&
872 (y >= py - oh) && (y <= (py + oh*2))) 864 (y >= py - oh) && (y <= (py + oh*2)))
873 { 865 {
874 x = x - px + rx; 866 x = x - px + rx;
875 y = y - py + ry; 867 y = y - py + ry;
876 868
877 p = eina_list_nth(t->path, n->idx); 869 p = eina_list_nth(t->path, i);
878 a = (double)(y - t->y) / (double)(x - t->x); 870 if(!p)
879 if ((abs(a) >= 1) || (t->x == x)) 871 {
880 { 872 p = evas_object_line_add(evas_object_evas_get(t->wd->obj));
881 evas_object_polygon_point_add(p, t->x - 3, t->y); 873 evas_object_smart_member_add(p, t->wd->pan_smart);
882 evas_object_polygon_point_add(p, t->x + 3, t->y); 874 t->path = eina_list_append(t->path, p);
883 evas_object_polygon_point_add(p, x + 3, y); 875 }
884 evas_object_polygon_point_add(p, x - 3, y); 876
885 } 877 evas_object_line_xy_set(p, t->x, t->y, x, y);
886 else
887 {
888 evas_object_polygon_point_add(p, t->x, t->y - 3);
889 evas_object_polygon_point_add(p, t->x, t->y + 3);
890 evas_object_polygon_point_add(p, x, y + 3);
891 evas_object_polygon_point_add(p, x, y - 3);
892 }
893 878
894 evas_object_color_set(p, t->color.r, t->color.g, t->color.b, t->color.a); 879 evas_object_color_set(p, t->color.r, t->color.g, t->color.b, t->color.a);
895 evas_object_raise(p); 880 evas_object_raise(p);
@@ -902,7 +887,7 @@ track_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py,
902 } 887 }
903 else 888 else
904 { 889 {
905 elm_map_utils_convert_geo_into_coord(wd->obj, n->pos.lon, n->pos.lat, size, &x, &y); 890 elm_map_utils_convert_geo_into_coord(wd->obj, emap_route_node_lon_get(n), emap_route_node_lat_get(n), size, &x, &y);
906 if ((x >= px - ow) && (x <= (px + ow*2)) && 891 if ((x >= px - ow) && (x <= (px + ow*2)) &&
907 (y >= py - oh) && (y <= (py + oh*2))) 892 (y >= py - oh) && (y <= (py + oh*2)))
908 { 893 {
@@ -912,9 +897,11 @@ track_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py,
912 } 897 }
913 else t->inbound = EINA_FALSE; 898 else t->inbound = EINA_FALSE;
914 } 899 }
900 i++;
915 } 901 }
916 t->inbound = EINA_FALSE; 902 t->inbound = EINA_FALSE;
917 } 903 }
904#endif
918} 905}
919static void 906static void
920route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh) 907route_place(Evas_Object *obj, Grid *g __UNUSED__, Evas_Coord px, Evas_Coord py, Evas_Coord ox __UNUSED__, Evas_Coord oy __UNUSED__, Evas_Coord ow, Evas_Coord oh)
@@ -3211,66 +3198,6 @@ _utils_convert_name(const Evas_Object *obj, int method, char *address, double lo
3211 3198
3212} 3199}
3213 3200
3214static Eina_Bool
3215cb_dump_track_attr(void *data, const char *key, const char *value)
3216{
3217 Track_Dump *dump = data;
3218 Evas_Object *path;
3219 double d;
3220
3221 if (!dump) return EINA_FALSE;
3222 if (!strcmp(GPX_LON, key))
3223 {
3224 sscanf(value, "%lf", &d);
3225 dump->lon = d;
3226 }
3227 else if (!strcmp(GPX_LAT, key))
3228 {
3229 sscanf(value, "%lf", &d);
3230 dump->lat = d;
3231 }
3232
3233 if ((dump->lon) && (dump->lat))
3234 {
3235 Path_Node *n = ELM_NEW(Path_Node);
3236 if (n)
3237 {
3238 n->wd = dump->track->wd;
3239 n->pos.lon = dump->lon;
3240 n->pos.lat = dump->lat;
3241 n->idx = dump->idx++;
3242 INF("[%d] %lf:%lf", n->idx, dump->lon, dump->lat);
3243 n->pos.address = NULL;
3244 dump->track->nodes = eina_list_append(dump->track->nodes, n);
3245
3246 path = evas_object_polygon_add(evas_object_evas_get(dump->track->wd->obj));
3247 evas_object_smart_member_add(path, dump->track->wd->pan_smart);
3248 dump->track->path = eina_list_append(dump->track->path, path);
3249 dump->lon = 0.0;
3250 dump->lat = 0.0;
3251 }
3252 }
3253
3254 return EINA_TRUE;
3255}
3256
3257static Eina_Bool
3258cb_track_dump(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset __UNUSED__, unsigned length __UNUSED__)
3259{
3260 Track_Dump *d = data;
3261
3262 if (!d) return EINA_FALSE;
3263 if (type == EINA_SIMPLE_XML_OPEN)
3264 {
3265 if (!strncmp(GPX_COORDINATES, content, strlen(GPX_COORDINATES)))
3266 {
3267 const char *tags = eina_simple_xml_tag_attributes_find(content, length);
3268 eina_simple_xml_attributes_parse(tags, length - (tags - content), cb_dump_track_attr, d);
3269 }
3270 }
3271 return EINA_TRUE;
3272}
3273
3274static int idnum = 1; 3201static int idnum = 1;
3275 3202
3276/** 3203/**
@@ -5042,6 +4969,7 @@ elm_map_route_add(Evas_Object *obj,
5042 return route; 4969 return route;
5043} 4970}
5044 4971
4972
5045/** 4973/**
5046 * Remove a route from the map 4974 * Remove a route from the map
5047 * 4975 *
@@ -5329,18 +5257,19 @@ elm_map_wheel_disabled_get(const Evas_Object *obj)
5329 return wd->wheel_disabled; 5257 return wd->wheel_disabled;
5330} 5258}
5331 5259
5260#ifdef HAVE_ELEMENTARY_EMAP
5332/** 5261/**
5333 * Add a track on the map 5262 * Add a track on the map
5334 * 5263 *
5335 * @param obj The map object 5264 * @param obj The map object
5336 * @param gpx_file the name of the gpx file 5265 * @param emap the emap object
5337 * 5266 *
5338 * @return The Track object 5267 * @return The Track object
5339 * 5268 *
5340 * @ingroup Map 5269 * @ingroup Map
5341 */ 5270 */
5342EAPI Elm_Map_Track * 5271EAPI Elm_Map_Track *
5343elm_map_track_add(Evas_Object *obj, const char *gpx_file) 5272elm_map_track_add(Evas_Object *obj, EMap_Route *emap)
5344{ 5273{
5345 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 5274 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5346 Widget_Data *wd = elm_widget_data_get(obj); 5275 Widget_Data *wd = elm_widget_data_get(obj);
@@ -5356,52 +5285,13 @@ elm_map_track_add(Evas_Object *obj, const char *gpx_file)
5356 track->color.g = 0; 5285 track->color.g = 0;
5357 track->color.b = 255; 5286 track->color.b = 255;
5358 track->color.a = 255; 5287 track->color.a = 255;
5359 5288 track->emap = emap;
5360 Track_Dump dump = {track, 0, 0.0, 0.0};
5361 if (!wd->gpx_file) wd->gpx_file = eina_stringshare_add(gpx_file);
5362 else eina_stringshare_replace(&wd->gpx_file, gpx_file);
5363
5364 f = fopen(gpx_file, "rb");
5365 if (f)
5366 {
5367 long sz;
5368
5369 fseek(f, 0, SEEK_END);
5370 sz = ftell(f);
5371 if (sz > 0)
5372 {
5373 char *buf;
5374
5375 fseek(f, 0, SEEK_SET);
5376 buf = malloc(sz);
5377 if (buf)
5378 {
5379 if (fread(buf, 1, sz, f))
5380 {
5381 eina_simple_xml_parse(buf, sz, EINA_TRUE, cb_track_dump, &dump);
5382 free(buf);
5383 }
5384 }
5385 }
5386 fclose(f);
5387 }
5388 else
5389 {
5390 ERR("can't open the file %s", gpx_file);
5391 return NULL;
5392 }
5393 DBG("[Done] Load GPX file %s", gpx_file);
5394 5289
5395 wd->track = eina_list_append(wd->track, track); 5290 wd->track = eina_list_append(wd->track, track);
5396 if (wd->grids)
5397 {
5398 Evas_Coord ox, oy, ow, oh;
5399 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
5400 track_place(wd->obj, eina_list_data_get(wd->grids), wd->pan_x, wd->pan_y, ox, oy, ow, oh);
5401 }
5402 5291
5403 return track; 5292 return track;
5404} 5293}
5294#endif
5405 5295
5406/** 5296/**
5407 * Remove a track from the map 5297 * Remove a track from the map