map.c \
zoomlevel.c \
tile.c \
- sources/openstreetmap.c \
- sources/debugmap.c
+ sources/oam.c \
+ sources/osm_mapnik.c \
+ sources/mff_relief.c \
+ sources/google_map.c \
+ sources/google_sat.c \
+ sources/google_terrain.c \
+ sources/debugmap.c
libchamplain_1_0_la_LIBADD = $(DEPS_LIBS) ../tidy/libtidy-1.0.la
{
CHAMPLAIN_MAP_SOURCE_DEBUG,
CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP,
- CHAMPLAIN_MAP_SOURCE_GOOGLE
+ CHAMPLAIN_MAP_SOURCE_OPENARIALMAP,
+ //CHAMPLAIN_MAP_SOURCE_GOOGLE_MAP,
+ //CHAMPLAIN_MAP_SOURCE_GOOGLE_TERRAIN,
+ //CHAMPLAIN_MAP_SOURCE_GOOGLE_SATELITE
+ CHAMPLAIN_MAP_SOURCE_MAPSFORFREE_RELIEF,
+ CHAMPLAIN_MAP_SOURCE_COUNT
} ChamplainMapSource;
#define CHAMPLAIN_TYPE_VIEW (champlain_view_get_type())
#include "map.h"
#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 <math.h>
Map*
debugmap_init(map);
break;
case CHAMPLAIN_MAP_SOURCE_OPENSTREETMAP:
- osm_init(map);
+ osm_mapnik_init(map);
+ break;
+ case CHAMPLAIN_MAP_SOURCE_OPENARIALMAP:
+ oam_init(map);
+ break;
+ case CHAMPLAIN_MAP_SOURCE_MAPSFORFREE_RELIEF:
+ mff_relief_init(map);
break;
}
gboolean
map_zoom_in (Map* map)
{
- if(map->current_level->level + 1 <= map->zoom_levels &&
- map->current_level->level + 1 <= 7) //FIXME Due to a ClutterUnit limitation (the x, y will have to be rethinked)
+ gint new_level = map->current_level->level + 1;
+ if(new_level + 1 <= map->zoom_levels &&
+ new_level + 1 <= 8) //FIXME Due to a ClutterUnit limitation (the x, y will have to be rethinked)
{
- map_load_level(map, map->current_level->level + 1);
+ gboolean exist = FALSE;
+ int i;
+ for (i = 0; i < map->levels->len && !exist; i++)
+ {
+ ZoomLevel* level = g_ptr_array_index(map->levels, i);
+ if (level && level->level == new_level)
+ {
+ exist = TRUE;
+ map->current_level = level;
+ }
+ }
+
+ if(!exist)
+ {
+ map_load_level(map, map->current_level->level + 1);
+ }
return TRUE;
}
return FALSE;
{
gboolean exist = FALSE;
int i;
- for (i = 0; i < map->current_level->tiles->len && !exist; i++)
+ for (i = 0; i < map->levels->len && !exist; i++)
{
ZoomLevel* level = g_ptr_array_index(map->levels, i);
- if ( level->level == new_level)
+ if (level && level->level == new_level)
{
exist = TRUE;
map->current_level = level;
- g_print("Found!");
}
}
gdouble (* x_to_longitude) (Map* map, gint x, guint zoom_level);
gdouble (* y_to_latitude) (Map* map, gint y, guint zoom_level);
- gchar* (* get_tile_filename) (Tile* tile);
- gchar* (* get_tile_uri) (Tile* tile);
+ gchar* (* get_tile_filename) (Map* map, Tile* tile);
+ gchar* (* get_tile_uri) (Map* map, Tile* tile);
};
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * WARNING: Using the Google Map Tiles is in viloation of the Terms of Service.
+ * The current code isn't working because the web server is returning Forbiden error message.
+ */
+
+#include "sources/google_map.h"
+#include "map.h"
+#include <math.h>
+#include <clutter/clutter.h>
+
+guint google_map_row_count(Map* map, guint zoom_level);
+guint google_map_column_count(Map* map, guint zoom_level);
+Tile* google_map_get_tile (Map* map, guint zoom_level, guint x, guint y);
+
+gint google_map_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
+gint google_map_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
+gdouble google_map_x_to_longitude (Map* map, gint x, guint zoom_level);
+gdouble google_map_y_to_latitude (Map* map, gint y, guint zoom_level);
+
+gchar* google_map_get_tile_filename(Map* map, Tile* tile);
+gchar* google_map_get_tile_uri(Map* map, Tile* tile);
+
+void
+google_map_init(Map* map)
+{
+ map->name = "Google Map";
+ map->zoom_levels = 15;
+ map->tile_size = 256;
+
+ map->get_row_count = google_map_row_count;
+ map->get_column_count = google_map_column_count;
+
+ map->longitude_to_x = google_map_longitude_to_x;
+ map->latitude_to_y = google_map_latitude_to_y;
+ map->x_to_longitude = google_map_x_to_longitude;
+ map->y_to_latitude = google_map_y_to_latitude;
+
+ map->get_tile_filename = google_map_get_tile_filename;
+ map->get_tile_uri = google_map_get_tile_uri;
+}
+
+guint google_map_row_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+guint
+google_map_column_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+gint
+google_map_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
+{
+ return ((longitude + 180.0) / 360.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gint
+google_map_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
+{
+ return ((1.0 - log( tan(latitude * M_PI/180.0) + 1.0 / cos(latitude * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gdouble
+google_map_x_to_longitude (Map* map, gint x, guint zoom_level)
+{
+ gdouble dx = (float)x / map->tile_size;
+ return dx / pow(2.0, zoom_level) * 360.0 - 180;
+}
+
+gdouble
+google_map_y_to_latitude (Map* map, gint y, guint zoom_level)
+{
+ gdouble dy = (float)y / map->tile_size;
+ double n = M_PI - 2.0 * M_PI * dy / pow(2.0, zoom_level);
+ return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
+}
+
+gchar* google_map_get_tile_filename(Map* map, Tile* tile)
+{
+ return g_build_filename (g_strdup_printf("%d_%d_%d.png", map->zoom_levels + 1 - tile->level, tile->y, tile->x), NULL);
+}
+
+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);
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GOOGLE_MAP_H
+#define GOOGLE_MAP_H
+
+#include <map.h>
+
+void google_map_init(Map* map);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * WARNING: Using the Google Map Tiles is in viloation of the Terms of Service.
+ * The current code isn't working because the web server is returning Forbiden error message.
+ */
+
+#include "sources/google_sat.h"
+#include "map.h"
+#include <math.h>
+#include <clutter/clutter.h>
+
+guint google_sat_row_count(Map* map, guint zoom_level);
+guint google_sat_column_count(Map* map, guint zoom_level);
+Tile* google_sat_get_tile (Map* map, guint zoom_level, guint x, guint y);
+
+gint google_sat_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
+gint google_sat_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
+gdouble google_sat_x_to_longitude (Map* map, gint x, guint zoom_level);
+gdouble google_sat_y_to_latitude (Map* map, gint y, guint zoom_level);
+
+gchar* google_sat_get_tile_filename(Map* map, Tile* tile);
+gchar* google_sat_get_tile_uri(Map* map, Tile* tile);
+
+void
+google_sat_init(Map* map)
+{
+ map->name = "OpenStreetMap";
+ map->zoom_levels = 17;
+ map->tile_size = 256;
+
+ map->get_row_count = google_sat_row_count;
+ map->get_column_count = google_sat_column_count;
+
+ map->longitude_to_x = google_sat_longitude_to_x;
+ map->latitude_to_y = google_sat_latitude_to_y;
+ map->x_to_longitude = google_sat_x_to_longitude;
+ map->y_to_latitude = google_sat_y_to_latitude;
+
+ map->get_tile_filename = google_sat_get_tile_filename;
+ map->get_tile_uri = google_sat_get_tile_uri;
+}
+
+guint google_sat_row_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+guint
+google_sat_column_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+gint
+google_sat_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
+{
+ return ((longitude + 180.0) / 360.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gint
+google_sat_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
+{
+ return ((1.0 - log( tan(latitude * M_PI/180.0) + 1.0 / cos(latitude * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gdouble
+google_sat_x_to_longitude (Map* map, gint x, guint zoom_level)
+{
+ gdouble dx = (float)x / map->tile_size;
+ return dx / pow(2.0, zoom_level) * 360.0 - 180;
+}
+
+gdouble
+google_sat_y_to_latitude (Map* map, gint y, guint zoom_level)
+{
+ gdouble dy = (float)y / map->tile_size;
+ double n = M_PI - 2.0 * M_PI * dy / pow(2.0, zoom_level);
+ return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
+}
+
+gchar* google_sat_get_tile_filename(Map* map, Tile* tile)
+{
+ return g_build_filename (g_strdup_printf("%d_%d_%d.png", map->zoom_levels + 1 - tile->level, tile->y, tile->x), NULL);
+}
+
+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);
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GOOGLE_SAT_H
+#define GOOGLE_SAT_H
+
+#include <map.h>
+
+void google_sat_init(Map* map);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/*
+ * WARNING: Using the Google Map Tiles is in viloation of the Terms of Service.
+ * The current code isn't working because the web server is returning Forbiden error message.
+ */
+
+#include "sources/google_terrain.h"
+#include "map.h"
+#include <math.h>
+#include <clutter/clutter.h>
+
+guint google_terrain_row_count(Map* map, guint zoom_level);
+guint google_terrain_column_count(Map* map, guint zoom_level);
+Tile* google_terrain_get_tile (Map* map, guint zoom_level, guint x, guint y);
+
+gint google_terrain_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
+gint google_terrain_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
+gdouble google_terrain_x_to_longitude (Map* map, gint x, guint zoom_level);
+gdouble google_terrain_y_to_latitude (Map* map, gint y, guint zoom_level);
+
+gchar* google_terrain_get_tile_filename(Map* map, Tile* tile);
+gchar* google_terrain_get_tile_uri(Map* map, Tile* tile);
+
+void
+google_terrain_init(Map* map)
+{
+ map->name = "OpenStreetMap";
+ map->zoom_levels = 17;
+ map->tile_size = 256;
+
+ map->get_row_count = google_terrain_row_count;
+ map->get_column_count = google_terrain_column_count;
+
+ map->longitude_to_x = google_terrain_longitude_to_x;
+ map->latitude_to_y = google_terrain_latitude_to_y;
+ map->x_to_longitude = google_terrain_x_to_longitude;
+ map->y_to_latitude = google_terrain_y_to_latitude;
+
+ map->get_tile_filename = google_terrain_get_tile_filename;
+ map->get_tile_uri = google_terrain_get_tile_uri;
+}
+
+guint google_terrain_row_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+guint
+google_terrain_column_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+gint
+google_terrain_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
+{
+ return ((longitude + 180.0) / 360.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gint
+google_terrain_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
+{
+ return ((1.0 - log( tan(latitude * M_PI/180.0) + 1.0 / cos(latitude * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gdouble
+google_terrain_x_to_longitude (Map* map, gint x, guint zoom_level)
+{
+ gdouble dx = (float)x / map->tile_size;
+ return dx / pow(2.0, zoom_level) * 360.0 - 180;
+}
+
+gdouble
+google_terrain_y_to_latitude (Map* map, gint y, guint zoom_level)
+{
+ gdouble dy = (float)y / map->tile_size;
+ double n = M_PI - 2.0 * M_PI * dy / pow(2.0, zoom_level);
+ return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
+}
+
+gchar* google_terrain_get_tile_filename(Map* map, Tile* tile)
+{
+ return g_build_filename (g_strdup_printf("%d_%d_%d.png", tile->level, tile->y, tile->x), NULL);
+}
+
+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);
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GOOGLE_TERRAIN_H
+#define GOOGLE_TERRAIN_H
+
+#include <map.h>
+
+void google_terrain_init(Map* map);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "sources/mff_relief.h"
+#include "map.h"
+#include <math.h>
+#include <clutter/clutter.h>
+
+
+//http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames#C.2FC.2B.2B
+
+guint mff_relief_row_count(Map* map, guint zoom_level);
+guint mff_relief_column_count(Map* map, guint zoom_level);
+Tile* mff_relief_get_tile (Map* map, guint zoom_level, guint x, guint y);
+
+gint mff_relief_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
+gint mff_relief_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
+gdouble mff_relief_x_to_longitude (Map* map, gint x, guint zoom_level);
+gdouble mff_relief_y_to_latitude (Map* map, gint y, guint zoom_level);
+
+gchar* mff_relief_get_tile_filename(Map* map, Tile* tile);
+gchar* mff_relief_get_tile_uri(Map* map, Tile* tile);
+
+void
+mff_relief_init(Map* map)
+{
+ map->name = "Maps For Free Relief";
+ map->zoom_levels = 11;
+ map->tile_size = 256;
+
+ map->get_row_count = mff_relief_row_count;
+ map->get_column_count = mff_relief_column_count;
+
+ map->longitude_to_x = mff_relief_longitude_to_x;
+ map->latitude_to_y = mff_relief_latitude_to_y;
+ map->x_to_longitude = mff_relief_x_to_longitude;
+ map->y_to_latitude = mff_relief_y_to_latitude;
+
+ map->get_tile_filename = mff_relief_get_tile_filename;
+ map->get_tile_uri = mff_relief_get_tile_uri;
+}
+
+guint mff_relief_row_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+guint
+mff_relief_column_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+gint
+mff_relief_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
+{
+ return ((longitude + 180.0) / 360.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gint
+mff_relief_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
+{
+ return ((1.0 - log( tan(latitude * M_PI/180.0) + 1.0 / cos(latitude * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gdouble
+mff_relief_x_to_longitude (Map* map, gint x, guint zoom_level)
+{
+ gdouble dx = (float)x / map->tile_size;
+ return dx / pow(2.0, zoom_level) * 360.0 - 180;
+}
+
+gdouble
+mff_relief_y_to_latitude (Map* map, gint y, guint zoom_level)
+{
+ gdouble dy = (float)y / map->tile_size;
+ double n = M_PI - 2.0 * M_PI * dy / pow(2.0, zoom_level);
+ return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
+}
+
+gchar* mff_relief_get_tile_filename(Map* map, Tile* tile)
+{
+ return g_build_filename (g_strdup_printf("%d_%d_%d.png", tile->level, tile->y, tile->x), NULL);
+}
+
+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);
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef MFF_RELIEF_H
+#define MFF_RELIEF_H
+
+#include <map.h>
+
+void mff_relief_init(Map* map);
+
+#endif
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "sources/oam.h"
+#include "map.h"
+#include <math.h>
+#include <clutter/clutter.h>
+
+guint oam_row_count(Map* map, guint zoom_level);
+guint oam_column_count(Map* map, guint zoom_level);
+Tile* oam_get_tile (Map* map, guint zoom_level, guint x, guint y);
+
+gint oam_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
+gint oam_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
+gdouble oam_x_to_longitude (Map* map, gint x, guint zoom_level);
+gdouble oam_y_to_latitude (Map* map, gint y, guint zoom_level);
+
+gchar* oam_get_tile_filename(Map* map, Tile* tile);
+gchar* oam_get_tile_uri(Map* map, Tile* tile);
+
+void
+oam_init(Map* map)
+{
+ map->name = "OpenArialMap";
+ map->zoom_levels = 17;
+ map->tile_size = 256;
+
+ map->get_row_count = oam_row_count;
+ map->get_column_count = oam_column_count;
+
+ map->longitude_to_x = oam_longitude_to_x;
+ map->latitude_to_y = oam_latitude_to_y;
+ map->x_to_longitude = oam_x_to_longitude;
+ map->y_to_latitude = oam_y_to_latitude;
+
+ map->get_tile_filename = oam_get_tile_filename;
+ map->get_tile_uri = oam_get_tile_uri;
+}
+
+guint oam_row_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+guint
+oam_column_count(Map* map, guint zoom_level)
+{
+ return pow (2, zoom_level);
+}
+
+gint
+oam_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
+{
+ return ((longitude + 180.0) / 360.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gint
+oam_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
+{
+ return ((1.0 - log( tan(latitude * M_PI/180.0) + 1.0 / cos(latitude * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, zoom_level)) * map->tile_size;
+}
+
+gdouble
+oam_x_to_longitude (Map* map, gint x, guint zoom_level)
+{
+ gdouble dx = (float)x / map->tile_size;
+ return dx / pow(2.0, zoom_level) * 360.0 - 180;
+}
+
+gdouble
+oam_y_to_latitude (Map* map, gint y, guint zoom_level)
+{
+ gdouble dy = (float)y / map->tile_size;
+ double n = M_PI - 2.0 * M_PI * dy / pow(2.0, zoom_level);
+ return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
+}
+
+gchar* oam_get_tile_filename(Map* map, Tile* tile)
+{
+ return g_build_filename (g_strdup_printf("%d_%d_%d.png", tile->level, tile->y, tile->x), NULL);
+}
+
+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);
+}
* Boston, MA 02110-1301, USA.
*/
-#ifndef OPENSTREETMAP_H
-#define OPENSTREETMAP_H
+#ifndef OAM_H
+#define OAM_H
#include <map.h>
-void osm_init(Map* map);
+void oam_init(Map* map);
#endif
* Boston, MA 02110-1301, USA.
*/
-#include "sources/openstreetmap.h"
+#include "sources/osm_mapnik.h"
#include "map.h"
#include <math.h>
#include <clutter/clutter.h>
//http://wiki.openstreetmap.org/index.php/Slippy_map_tilenames#C.2FC.2B.2B
-guint osm_row_count(Map* map, guint zoom_level);
-guint osm_column_count(Map* map, guint zoom_level);
-Tile* osm_get_tile (Map* map, guint zoom_level, guint x, guint y);
+guint osm_mapnik_row_count(Map* map, guint zoom_level);
+guint osm_mapnik_column_count(Map* map, guint zoom_level);
+Tile* osm_mapnik_get_tile (Map* map, guint zoom_level, guint x, guint y);
-gint osm_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
-gint osm_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
-gdouble osm_x_to_longitude (Map* map, gint x, guint zoom_level);
-gdouble osm_y_to_latitude (Map* map, gint y, guint zoom_level);
+gint osm_mapnik_longitude_to_x (Map* map, gdouble longitude, guint zoom_level);
+gint osm_mapnik_latitude_to_y (Map* map, gdouble latitude, guint zoom_level);
+gdouble osm_mapnik_x_to_longitude (Map* map, gint x, guint zoom_level);
+gdouble osm_mapnik_y_to_latitude (Map* map, gint y, guint zoom_level);
-gchar* osm_get_tile_filename(Tile* tile);
-gchar* osm_get_tile_uri(Tile* tile);
+gchar* osm_mapnik_get_tile_filename(Map* map, Tile* tile);
+gchar* osm_mapnik_get_tile_uri(Map* map, Tile* tile);
void
-osm_init(Map* map)
+osm_mapnik_init(Map* map)
{
map->name = "OpenStreetMap";
map->zoom_levels = 17;
map->tile_size = 256;
- map->get_row_count = osm_row_count;
- map->get_column_count = osm_column_count;
+ map->get_row_count = osm_mapnik_row_count;
+ map->get_column_count = osm_mapnik_column_count;
- map->longitude_to_x = osm_longitude_to_x;
- map->latitude_to_y = osm_latitude_to_y;
- map->x_to_longitude = osm_x_to_longitude;
- map->y_to_latitude = osm_y_to_latitude;
+ map->longitude_to_x = osm_mapnik_longitude_to_x;
+ map->latitude_to_y = osm_mapnik_latitude_to_y;
+ map->x_to_longitude = osm_mapnik_x_to_longitude;
+ map->y_to_latitude = osm_mapnik_y_to_latitude;
- map->get_tile_filename = osm_get_tile_filename;
- map->get_tile_uri = osm_get_tile_uri;
+ map->get_tile_filename = osm_mapnik_get_tile_filename;
+ map->get_tile_uri = osm_mapnik_get_tile_uri;
}
-guint osm_row_count(Map* map, guint zoom_level)
+guint osm_mapnik_row_count(Map* map, guint zoom_level)
{
return pow (2, zoom_level);
}
guint
-osm_column_count(Map* map, guint zoom_level)
+osm_mapnik_column_count(Map* map, guint zoom_level)
{
return pow (2, zoom_level);
}
gint
-osm_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
+osm_mapnik_longitude_to_x (Map* map, gdouble longitude, guint zoom_level)
{
return ((longitude + 180.0) / 360.0 * pow(2.0, zoom_level)) * map->tile_size;
}
gint
-osm_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
+osm_mapnik_latitude_to_y (Map* map, gdouble latitude, guint zoom_level)
{
return ((1.0 - log( tan(latitude * M_PI/180.0) + 1.0 / cos(latitude * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, zoom_level)) * map->tile_size;
}
gdouble
-osm_x_to_longitude (Map* map, gint x, guint zoom_level)
+osm_mapnik_x_to_longitude (Map* map, gint x, guint zoom_level)
{
gdouble dx = (float)x / map->tile_size;
return dx / pow(2.0, zoom_level) * 360.0 - 180;
}
gdouble
-osm_y_to_latitude (Map* map, gint y, guint zoom_level)
+osm_mapnik_y_to_latitude (Map* map, gint y, guint zoom_level)
{
gdouble dy = (float)y / map->tile_size;
double n = M_PI - 2.0 * M_PI * dy / pow(2.0, zoom_level);
return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
}
-gchar* osm_get_tile_filename(Tile* tile)
+gchar* osm_mapnik_get_tile_filename(Map* map, Tile* tile)
{
return g_build_filename (g_strdup_printf("%d_%d_%d.png", tile->level, tile->y, tile->x), NULL);
}
-gchar* osm_get_tile_uri(Tile* tile)
+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);
}
--- /dev/null
+/*
+ * Copyright (C) 2008 Pierre-Luc Beaudoin <pierre-luc@squidy.info>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef OSM_MAPNIK_H
+#define OSM_MAPNIK_H
+
+#include <map.h>
+
+void osm_mapnik_init(Map* map);
+
+#endif
if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code))
{
- g_warning ("Unable to download tile %d, %d", tile->x, tile->y);
+ g_warning ("Unable to download tile %d, %d: %s", tile->x, tile->y, soup_status_get_phrase(msg->status_code));
return;
}
}
}
- map_filename = map->get_tile_filename(tile);
+ map_filename = map->get_tile_filename(map, tile);
filename = g_build_filename (g_get_user_cache_dir (),
CACHE_DIR,
map->name,
ptr->tile = tile;
// Try the cached version first
- map_filename = map->get_tile_filename(tile);
+ map_filename = map->get_tile_filename(map, tile);
filename = g_build_filename (g_get_user_cache_dir (),
CACHE_DIR,
map->name,
SoupMessage *msg;
if (!session)
session = soup_session_async_new ();
-
- msg = soup_message_new (SOUP_METHOD_GET, g_strdup_printf("http://tile.openstreetmap.org/%d/%d/%d.png", zoom_level, x, y));
+
+ msg = soup_message_new (SOUP_METHOD_GET, map->get_tile_uri(map, tile));
soup_session_queue_message (session, msg,
file_loaded_cb,