summaryrefslogtreecommitdiffstats
path: root/friendfinder/map/smart_map_priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'friendfinder/map/smart_map_priv.h')
-rw-r--r--friendfinder/map/smart_map_priv.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/friendfinder/map/smart_map_priv.h b/friendfinder/map/smart_map_priv.h
new file mode 100644
index 0000000..d40e847
--- /dev/null
+++ b/friendfinder/map/smart_map_priv.h
@@ -0,0 +1,166 @@
+#ifndef _SMART_MAP_PRIV_H_
+#define _SMART_MAP_PRIV_H_
+
+struct map_level_info
+{
+ int min_x;
+ int max_x;
+ int min_y;
+ int max_y;
+
+ double north, south, west, east;
+ double dx, dy, e0, n0;
+};
+
+struct map_info
+{
+ char *path;
+ struct map_level_info *level;
+ int min_level;
+ int max_level;
+ int tile_size;
+};
+
+#include <Evas.h>
+
+struct smart_map;
+struct controls
+{
+ Evas_Object *bt;
+ Evas_Object *bx;
+ Evas_Object *vkbd;
+ Evas_Object *ctrl;
+};
+
+struct overlay_level_data
+{
+ int ox, oy;
+ int visible:1;
+};
+
+struct overlay_object
+{
+ Evas_Object *obj;
+ int ox;
+ int oy;
+ int sw, sh;
+};
+
+struct overlay_item
+{
+ struct overlay_object *obj;
+ double lat, lon;
+ unsigned int level_mask;
+ struct overlay_level_data level_data;
+};
+
+#define OSM_LEVEL_COUNT 19
+
+#include "e_smart_tile.h"
+struct smart_map
+{
+ Evas_Object *obj;
+ Evas_Object *clip;
+ Evas_Object *theme;
+ Evas_Coord x, y, w, h;
+
+ Evas *evas;
+ Evas_Object *win;
+ struct controls c;
+ Eina_Array *overlays;
+ Eina_Array *paths;
+
+ struct map_info *mi;
+ struct map_level_info *li;
+ int current_level;
+
+ struct tile_array ta;
+ double lat;
+ double lon;
+
+ int moved;
+ int drag;
+};
+
+enum {
+ OVERLAY_HIDDEN,
+ OVERLAY_VISIBLE
+};
+
+struct map_overlay
+{
+ struct smart_map *parent;
+ char *name;
+ Eina_Hash *hash;
+ Eina_Array *pois[OSM_LEVEL_COUNT];
+ int current_level;
+ int state;
+};
+
+enum {
+ POSITION_WORLD,
+ POSITION_PX,
+ NUM_POSITION,
+};
+
+struct map_info *map_info_read(const char *path);
+int map_object_update(struct smart_map *smart);
+int controls_init(struct smart_map *smart);
+
+struct map_overlay *overlay_create(struct smart_map *smart, char *name);
+void overlay_update(struct smart_map *smart, struct osm_data *, int xoff, int yoff);
+void overlay_unload(struct smart_map *smart, struct osm_data *osm);
+void overlay_change_level(struct smart_map *smart, int level);
+void overlay_add(struct smart_map *smart, struct map_overlay *ov, struct overlay_item *poi);
+struct map_overlay *overlay_find_by_name(struct smart_map *smart, char *name);
+void overlay_hide(struct smart_map *smart, char *name);
+void overlay_hide_all(struct smart_map *smart);
+
+static inline struct map_level_info *
+map_info_get_level(struct map_info *map, int* z)
+{
+ if(*z < map->min_level || *z > map->max_level)
+ *z = (map->min_level + map->max_level) / 2 ;
+
+ return &map->level[*z - map->min_level];
+}
+
+#include <limits.h>
+#include "../util/projection.h"
+static inline int
+latlon_to_map(struct map_level_info *level, double lat, double lon, int *x, int *y)
+{
+ if(level == NULL)
+ return -1;
+
+ int e = INT_MAX, n = INT_MAX;
+ double e0 = level->e0;
+ double n0 = level->n0;
+ double dx = level->dx;
+ double dy = level->dy;
+
+ project_latlon(lat, lon, &e, &n, PROJECTION_MERC);
+ *x = (e - e0) / dx;
+ *y = (n0 - n) / dy;
+ return 0;
+}
+
+static inline int
+map_to_latlon(struct map_level_info *level, int x, int y, double *lat, double *lon)
+{
+ int e, n;
+
+ if(level == NULL)
+ return -1;
+
+ double e0 = level->e0;
+ double n0 = level->n0;
+ double dx = level->dx;
+ double dy = level->dy;
+
+ e = e0 + x * dx;
+ n = -(y * dy - n0);
+ project_latlon_inv(e, n, lat, lon, PROJECTION_MERC);
+ return 0;
+}
+#endif