#include "math.h" #include "Evas.h" #include "Elementary.h" #include "receiver.h" #include "gui.h" #include "util/projection.h" #include "map/smart_map_priv.h" int _h= 600; int _w = 450; int _distance = 250; int active_map = 0; double own_lat, own_lon; Evas_Object *win, *map; void init_draw_user(Evas_Object *_win, Evas_Object *_map) { win = _win; map = _map; } void enable_map_bubbles() { active_map = 1; } void disable_map_bubbles() { active_map = 0; } void set_dist(int distance) { _distance = distance; } void draw_user(struct position *pos) { int *e = NULL, *n = NULL, *own_e = NULL, *own_n = NULL; double old_lat, old_lon, sender_lat, sender_lon; sender_lat = atof(pos->lat); sender_lon = atof(pos->lon); if (active_map == 1 && test_distance(sender_lat, sender_lon, e, n, own_lat, own_lon, own_e, own_n) == 1) { e_smart_map_overlay_set_bubble(map, "routing", pos->nick, pos->nick, sender_lat, sender_lon, 0xffffffff); } } int test_distance(double lat, double lon, int e, int n, double own_lat, double own_lon, int own_e, int own_n) { project_latlon(lat, lon, &e, &n, PROJECTION_UTM); project_latlon(own_lat, own_lon, &own_e, &own_n, PROJECTION_UTM); if (e != NULL && n !=NULL && own_n != NULL && own_e != NULL) { double x = sqrt(((e - own_e)*(e - own_e) + (n - own_n)*(n - own_n))); printf("x: %f distance: %i \n", x, _distance); if (x <= _distance) { return 1; } else return 0; } } void get_own_position(double lat, double lon) { own_lat = lat; own_lon = lon; }