#include "osm.h"
+static guint8 osm_zoom ( gdouble mpp );
+
+static gboolean osm_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
+static void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest );
+static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn );
+static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn );
+static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn );
+
+
/* initialisation */
void osm_init () {
VikMapsLayer_MapType osmarender_type = { 12, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_osmarender_download };
- VikMapsLayer_MapType mapnik_type = { 13, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_mapnik_download };
+ VikMapsLayer_MapType mapnik_type = { 13, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_mapnik_download }; VikMapsLayer_MapType maplint_type = { 14, 256, 256, VIK_VIEWPORT_DRAWMODE_MERCATOR, osm_coord_to_mapcoord, osm_mapcoord_to_center_coord, osm_maplint_download };
+
maps_layer_register_type("OpenStreetMap (Osmarender)", 12, &osmarender_type);
maps_layer_register_type("OpenStreetMap (Mapnik)", 13, &mapnik_type);
+ maps_layer_register_type("OpenStreetMap (Maplint)", 14, &maplint_type);
}
/* 1 << (x) is like a 2**(x) */
return 255;
}
-gboolean osm_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
+static gboolean osm_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
{
g_assert ( src->mode == VIK_COORD_LATLON );
return TRUE;
}
-void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
+static void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
{
gdouble socalled_mpp = GZ(src->scale);
dest->mode = VIK_COORD_LATLON;
dest->north_south = DEMERCLAT(180 - ((src->y+0.5) / GZ(17) * socalled_mpp * 360));
}
-void osm_mapnik_download ( MapCoord *src, const gchar *dest_fn )
+/* Maplint tiles
+ * Ex: http://dev.openstreetmap.org/~ojw/Tiles/maplint.php/10/517/375.png
+ */
+static int osm_maplint_download ( MapCoord *src, const gchar *dest_fn )
+{
+ int res = -1;
+ gchar *uri = g_strdup_printf ( "/~ojw/Tiles/maplint.php/%d/%d/%d.png", 17-src->scale, src->x, src->y );
+ res = a_http_download_get_url ( "dev.openstreetmap.org", uri, dest_fn );
+ g_free ( uri );
+ return res;
+}
+
+static int osm_mapnik_download ( MapCoord *src, const gchar *dest_fn )
{
+ int res = -1;
gchar *uri = g_strdup_printf ( "/osamrender/%d/%d/%d.png", 17-src->scale, src->x, src->y );
- a_http_download_get_url ( "tile.openstreetmap.org", uri, dest_fn );
+ res = a_http_download_get_url ( "tile.openstreetmap.org", uri, dest_fn );
g_free ( uri );
+ return res;
}
-void osm_osmarender_download ( MapCoord *src, const gchar *dest_fn )
+static int osm_osmarender_download ( MapCoord *src, const gchar *dest_fn )
{
+ int res = -1;
gchar *uri = g_strdup_printf ( "/~ojw/Tiles/tile.php/%d/%d/%d.png", 17-src->scale, src->x, src->y );
- a_http_download_get_url ( "dev.openstreetmap.org", uri, dest_fn );
+ res = a_http_download_get_url ( "dev.openstreetmap.org", uri, dest_fn );
g_free ( uri );
+ return res;
}