typedef struct _ChamplainMarker ChamplainMarker;
typedef struct _ChamplainMarkerClass ChamplainMarkerClass;
-typedef struct _Map Map;
-
#define CHAMPLAIN_PARAM_READABLE \
(G_PARAM_READABLE | \
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB)
#define CHAMPLAIN_MARKER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_MARKER, ChamplainMarkerPrivate))
+typedef struct _Map Map;
+typedef struct _Tile Tile;
+
typedef struct
{
gint x;
g_object_get(G_OBJECT(prev_marker), "latitude", &tmp_y, NULL);
tmp_y = 90 - tmp_y;
- if (prev_marker == marker)
+ if (prev_marker == (ChamplainMarker*) marker)
continue;
if (y < tmp_y && tmp_y < low_y)
ChamplainLayer *
champlain_layer_new ()
{
- ClutterGroup *layer;
+ ClutterActor *layer;
layer = clutter_group_new();
g_signal_connect_after(G_OBJECT(layer), "actor-added", G_CALLBACK(layer_add_cb), NULL);
#include "zoomlevel.h"
#include <clutter/clutter.h>
+#include <clutter-cairo/clutter-cairo.h>
#include <glib.h>
#include <glib-object.h>
#include <cairo.h>
PROP_ANCHOR_Y,
};
-static guint champlain_marker_signals[LAST_SIGNAL] = { 0, };
+//static guint champlain_marker_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (ChamplainMarker, champlain_marker, CLUTTER_TYPE_GROUP);
static void
champlain_marker_finalize (GObject *object)
{
- ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
- ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+ //ChamplainMarker *marker = CHAMPLAIN_MARKER (object);
+ //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
G_OBJECT_CLASS (champlain_marker_parent_class)->finalize (object);
}
ChamplainMarker *marker;
marker = CHAMPLAIN_MARKER (g_object_new (CHAMPLAIN_TYPE_MARKER, NULL));
- ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
+ //ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (marker);
return CLUTTER_ACTOR (marker);
}
ClutterColor *marker_color)
{
ChamplainMarker *champlainMarker = CHAMPLAIN_MARKER(champlain_marker_new ());
- ChamplainMarkerPrivate *priv = CHAMPLAIN_MARKER_GET_PRIVATE (champlainMarker);
ClutterColor default_text_color = { 0x22, 022, 0x22, 0xFF },
default_marker_color = { 0x2A, 0xB1, 0x26, 0xEE },
darker_color;
point = (text_height + 2 * padding) / 4.0;
bg = clutter_cairo_new (text_width, text_height + point);
- cr = clutter_cairo_create (bg);
+ cr = clutter_cairo_create (CLUTTER_CAIRO (bg));
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_move_to (cr, 0, 0);
clutter_actor_set_anchor_point (CLUTTER_ACTOR(champlainMarker), 0, text_height + point);
- return champlainMarker;
+ return CLUTTER_ACTOR (champlainMarker);
}
PROP_DECEL_RATE,
};
-static guint champlain_view_signals[LAST_SIGNAL] = { 0, };
+// static guint champlain_view_signals[LAST_SIGNAL] = { 0, };
#define CHAMPLAIN_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), CHAMPLAIN_TYPE_VIEW, ChamplainViewPrivate))
g_object_notify(G_OBJECT(view), "zoom-level");
}
-
+
+ return success;
}
static void
gdouble lat = viewport_get_current_latitude(priv);
gdouble lon = viewport_get_current_longitude(priv);
if (priv->map) {
- gint currentLevel = priv->map->current_level->level;
+ guint currentLevel = priv->map->current_level->level;
map_free(priv->map);
priv->map = map_new(priv->map_source);
static void
champlain_view_finalize (GObject *object)
{
- ChamplainView *view = CHAMPLAIN_VIEW (object);
- ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
+ //ChamplainView *view = CHAMPLAIN_VIEW (object);
+ //ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
G_OBJECT_CLASS (champlain_view_parent_class)->finalize (object);
}
ClutterActor *
champlain_view_new (ChamplainViewMode mode)
{
- ClutterColor stage_color = { 0x34, 0x39, 0x39, 0xff };
ChamplainView *view;
- ClutterActor *stage;
view = CHAMPLAIN_VIEW (g_object_new (CHAMPLAIN_TYPE_VIEW, NULL));
ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view);
anchor->y = 0;
}
- int i;
+ guint i;
for (i = 0; i < priv->map->current_level->tiles->len; i++)
{
Tile *tile = g_ptr_array_index(priv->map->current_level->tiles, i);
#include "zoomlevel.h"
#include "sources/osm_mapnik.h"
#include "sources/mff_relief.h"
-#include "sources/google_sat.h"
-#include "sources/google_map.h"
-#include "sources/google_terrain.h"
+#include "sources/oam.h"
+#include "sources/debugmap.h"
#include <math.h>
Map*
case CHAMPLAIN_MAP_SOURCE_MAPSFORFREE_RELIEF:
mff_relief_init(map);
break;
+ case CHAMPLAIN_MAP_SOURCE_COUNT:
+ default:
+ g_warning("Unsupported map source");
+ break;
}
map->previous_level = NULL;
//g_print("Tiles: %d, %d to %d, %d\n", x_first, y_first, x_count, y_count);
- int i, j, k;
+ int i, j;
+ guint k;
// Get rid of old tiles first
for (k = 0; k < map->current_level->tiles->len; k++)
gboolean
map_zoom_in (Map *map)
{
- gint new_level = map->current_level->level + 1;
+ guint new_level = map->current_level->level + 1;
if(new_level <= map->zoom_levels)
{
map_load_level(map, new_level);
gboolean
map_zoom_to (Map *map, guint zoomLevel)
{
- if(zoomLevel >= 0 &&
- zoomLevel<= map->zoom_levels)
+ if (zoomLevel<= map->zoom_levels)
{
map_load_level(map, zoomLevel);
return TRUE;
#include "champlain.h"
#include "champlainview.h"
-#include "champlain_defines.h"
+#include "champlain_private.h"
#include "zoomlevel.h"
#include "tile.h"
#include <glib.h>
#include <clutter/clutter.h>
-
struct _Map
{
- int zoom_levels;
+ guint zoom_levels;
const gchar *name;
int tile_size;
void map_free (Map *map);
+gboolean map_zoom_in (Map *map);
+
+gboolean map_zoom_out (Map *map);
+
gboolean map_zoom_to (Map *map, guint zoomLevel);
+void map_load_level(Map *map, gint zoom_level);
+
#endif
gchar *google_map_get_tile_uri(Map *map, Tile *tile)
{
- return g_strdup_printf("http://mt.google.com/mt?n=404&v=w2.99&x=%d&y=%d&zoom=%d", tile->x, tile->y, map->zoom_levels + 1 - tile->level, NULL);
+ return g_strdup_printf("http://mt.google.com/mt?n=404&v=w2.99&x=%d&y=%d&zoom=%d", tile->x, tile->y, map->zoom_levels + 1 - tile->level);
}
gchar *google_sat_get_tile_uri(Map *map, Tile *tile)
{
- return g_strdup_printf("http://mt.google.com/mt?n=404&v=w2.99&x=%d&y=%d&zoom=%d", tile->x, tile->y, map->zoom_levels + 1 - tile->level, NULL);
+ return g_strdup_printf("http://mt.google.com/mt?n=404&v=w2.99&x=%d&y=%d&zoom=%d", tile->x, tile->y, map->zoom_levels + 1 - tile->level);
}
gchar *google_terrain_get_tile_uri(Map *map, Tile *tile)
{
- return g_strdup_printf("http://tile.openstreetmap.org/%d/%d/%d.png", tile->level, tile->x, tile->y, NULL);
+ return g_strdup_printf("http://tile.openstreetmap.org/%d/%d/%d.png", tile->level, tile->x, tile->y);
}
gchar *mff_relief_get_tile_uri(Map *map, Tile *tile)
{
- return g_strdup_printf("http://maps-for-free.com/layer/relief/z%d/row%d/%d_%d-%d.jpg", tile->level, tile->y, tile->level, tile->x, tile->y, NULL);
+ return g_strdup_printf("http://maps-for-free.com/layer/relief/z%d/row%d/%d_%d-%d.jpg", tile->level, tile->y, tile->level, tile->x, tile->y);
}
gchar *oam_get_tile_uri(Map *map, Tile *tile)
{
- return g_strdup_printf("http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.jpg", tile->level, tile->x, tile->y, NULL);
+ return g_strdup_printf("http://tile.openaerialmap.org/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.jpg", tile->level, tile->x, tile->y);
}
gchar *osm_mapnik_get_tile_uri(Map *map, Tile *tile)
{
- return g_strdup_printf("http://tile.openstreetmap.org/%d/%d/%d.png", tile->level, tile->x, tile->y, NULL);
+ return g_strdup_printf("http://tile.openstreetmap.org/%d/%d/%d.png", tile->level, tile->x, tile->y);
}
#include <glib.h>
#include <clutter/clutter.h>
+#include <champlain/champlain_private.h>
-typedef struct
+struct _Tile
{
ClutterActor* actor;
int x;
gboolean loading; // TRUE when a callback exist to load the tile, FALSE otherwise
gboolean to_destroy; // TRUE when a tile struct should be deleted when loading is done, FALSE otherwise
-} Tile;
+};
void tile_free(Tile* tile);
+void tile_set_position(Map* map, Tile* tile);
+
+Tile* tile_load (Map* map, guint zoom_level, guint x, guint y, gboolean offline);
+
#endif
void
zoom_level_free(ZoomLevel *level)
{
- int i;
+ guint i;
for (i = 0; i < level->tiles->len; i++)
{
Tile *tile = g_ptr_array_index(level->tiles, i);