]> git.street.me.uk Git - andy/viking.git/blobdiff - src/osm.c
Make window dimensions easier to be changed.
[andy/viking.git] / src / osm.c
index 0c5eed74216cca40f3e1bd3c08f56d033b63da4b..352da2a8f08d134eccaa4a461d3ac4fea191baff 100644 (file)
--- a/src/osm.c
+++ b/src/osm.c
 
 #include "osm.h"
 
 
 #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 };
 /* 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 (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) */
 }
 
 /* 1 << (x) is like a 2**(x) */
@@ -56,7 +67,7 @@ guint8 osm_zoom ( gdouble mpp ) {
   return 255;
 }
 
   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 );
 
 {
   g_assert ( src->mode == VIK_COORD_LATLON );
 
@@ -73,7 +84,7 @@ gboolean osm_coord_to_mapcoord ( const VikCoord *src, gdouble xzoom, gdouble yzo
   return TRUE;
 }
 
   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;
 {
   gdouble socalled_mpp = GZ(src->scale);
   dest->mode = VIK_COORD_LATLON;
@@ -81,16 +92,32 @@ void osm_mapcoord_to_center_coord ( MapCoord *src, VikCoord *dest )
   dest->north_south = DEMERCLAT(180 - ((src->y+0.5) / GZ(17) * socalled_mpp * 360));
 }
 
   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 );
    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 );
    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 );
    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 );
    g_free ( uri );
+   return res;
 }
 }