]> git.street.me.uk Git - andy/viking.git/commitdiff
Add compatibility facilities
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Tue, 13 Jan 2009 21:25:51 +0000 (22:25 +0100)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Fri, 27 Mar 2009 11:14:42 +0000 (12:14 +0100)
src/Makefile.am
src/bluemarble.c
src/old-vik-map-type.gob [new file with mode: 0644]
src/openaerial.c
src/osm.c
src/terraserver.c
src/vikmapslayer.c
src/vikmapslayer.h
src/vikmapslayer_compat.c [new file with mode: 0644]
src/vikmapslayer_compat.h [new file with mode: 0644]

index 8bfabad6d6448d741f35c01a88d7458ade36c086..9cbd2de99461fee91e94eb72646e763dc4310d17 100644 (file)
@@ -56,8 +56,10 @@ libviking_a_SOURCES = \
        vikcoord.c vikcoord.h \
        mapcache.c mapcache.h \
        vikmapslayer.c vikmapslayer.h \
+       vikmapslayer_compat.c vikmapslayer_compat.h \
        vik-map-type.c vik-map-type.h \
        vik-map-type-default.c vik-map-type-default.h \
+       old-vik-map-type.c old-vik-map-type.h \
        slippy-map-type-abstract.c slippy-map-type-abstract.h \
        slippy-map-type.c slippy-map-type.h \
         gpx.c gpx.h \
@@ -84,7 +86,8 @@ BUILT_SOURCES += \
        vik-map-type.c vik-map-type.h \
        vik-map-type-default.c vik-map-type-default.h \
        slippy-map-type-abstract.c slippy-map-type-abstract.h \
-       slippy-map-type.c slippy-map-type.h
+       slippy-map-type.c slippy-map-type.h \
+       old-vik-map-type.c old-vik-map-type.h
 
 if GOOGLE
 libviking_a_SOURCES += \
index 5028a681df3eaba48e464c84de0aa1e727df444b..bfc710a0ccdbbcd1cac6a032c2eb16f4d4fc2546 100644 (file)
@@ -28,6 +28,6 @@
 void bluemarble_init () {
   VikMapType *bluemarble_type = VIK_MAP_TYPE(slippy_map_type_new_with_id( 15, "s3.amazonaws.com", "/com.modestmaps.bluemarble/%d-r%3$d-c%2$d.jpg" ));
 
-  maps_layer_register_type("BlueMarble", 15, bluemarble_type);
+  maps_layer_register_map_type("BlueMarble", bluemarble_type);
 }
 
diff --git a/src/old-vik-map-type.gob b/src/old-vik-map-type.gob
new file mode 100644 (file)
index 0000000..df16811
--- /dev/null
@@ -0,0 +1,40 @@
+%headertop{
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vik-map-type.h"
+#include "vikmapslayer_compat.h"
+%}
+
+class Old:Vik:Map:Type from Vik:Map:Type {
+
+  private VikMapsLayer_MapType map_type;
+  public GObject *
+  new_with_id (VikMapsLayer_MapType map_type) {
+         OldVikMapType *ret = GET_NEW;
+         ret->_priv->map_type = map_type;
+         return G_OBJECT (ret);
+  }
+
+  override (Vik:Map:Type) gboolean
+  coord_to_mapcoord ( Vik:Map:Type *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
+  {
+    return SELF(self)->_priv->map_type.coord_to_mapcoord (src, xzoom, yzoom, dest);
+  }
+
+  override (Vik:Map:Type) void
+  mapcoord_to_center_coord ( Vik:Map:Type *self, MapCoord *src, VikCoord *dest )
+  {
+    SELF(self)->_priv->map_type.mapcoord_to_center_coord (src, dest);
+  }
+
+  override (Vik:Map:Type) int
+  download ( Vik:Map:Type *self, MapCoord *src, const gchar *dest_fn )
+  {
+    return SELF(self)->_priv->map_type.download(src, dest_fn);
+  }
+
+}
+
index 2fd3853f3df4749e34c69cb4f8b84b44064d6527..5f1de45a08f86fae327a4d969a30ba21d65ee457 100644 (file)
@@ -28,6 +28,6 @@
 void openaerial_init () {
   VikMapType *openaerialmap_type = VIK_MAP_TYPE(slippy_map_type_new_with_id( 20, "tile.openaerialmap.org", "/tiles/1.0.0/openaerialmap-900913/%d/%d/%d.jpg" ));
 
-  maps_layer_register_type("OpenAerialMap", 20, openaerialmap_type);
+  maps_layer_register_map_type("OpenAerialMap", openaerialmap_type);
 }
 
index 5fc9043d60d6e5d7b2add41c61e1e43a267518cd..1f72675afd298a45f2efa9efdce3fabffedf2ea4 100644 (file)
--- a/src/osm.c
+++ b/src/osm.c
@@ -30,9 +30,9 @@ void osm_init () {
   VikMapType *maplint_type = VIK_MAP_TYPE(slippy_map_type_new_with_id( 14, "tah.openstreetmap.org", "/Tiles/maplint.php/%d/%d/%d.png"));
   VikMapType *cycle_type = VIK_MAP_TYPE(slippy_map_type_new_with_id( 17, "thunderflames.org/tiles/cycle/", "%d/%d/%d.png" ));
 
-  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);
-  maps_layer_register_type("OpenStreetMap (Cycle)", 17, cycle_type);
+  maps_layer_register_map_type("OpenStreetMap (Osmarender)", osmarender_type);
+  maps_layer_register_map_type("OpenStreetMap (Mapnik)", mapnik_type);
+  maps_layer_register_map_type("OpenStreetMap (Maplint)", maplint_type);
+  maps_layer_register_map_type("OpenStreetMap (Cycle)", cycle_type);
 }
 
index 78c148672fa6c6563b829628ffee08aeca2571ab..9bbc6abfcdcf8aa9d850dfb78cfe6b12eb3e1b05 100644 (file)
@@ -28,7 +28,7 @@ void terraserver_init () {
   VikMapType *map_type_2 = VIK_MAP_TYPE(terraserver_map_type_new_with_id( 1, 1 ));
   VikMapType *map_type_3 = VIK_MAP_TYPE(terraserver_map_type_new_with_id( 4, 4 ));
 
-  maps_layer_register_type("Terraserver Topos", 2, map_type_1);
-  maps_layer_register_type("Terraserver Aerials", 1, map_type_2);
-  maps_layer_register_type("Terraserver Urban Areas", 4, map_type_3);
+  maps_layer_register_map_type("Terraserver Topos", map_type_1);
+  maps_layer_register_map_type("Terraserver Aerials", map_type_2);
+  maps_layer_register_map_type("Terraserver Urban Areas", map_type_3);
 }
index cdb3d677a7e905e48c69602d16600b7c2847a33e..c229ca6f4f13569f8fb7c8baafca80e897b89959 100644 (file)
@@ -201,11 +201,12 @@ enum { REDOWNLOAD_NONE = 0, REDOWNLOAD_BAD, REDOWNLOAD_ALL, DOWNLOAD_OR_REFRESH
 /******** MAPS LAYER TYPES **************/
 /****************************************/
 
-void maps_layer_register_type ( const char *label, guint id, VikMapType *map_type )
+void maps_layer_register_map_type ( const char *label, VikMapType *map_type )
 {
   g_assert(label != NULL);
   g_assert(map_type != NULL);
-  g_assert(id == vik_map_type_get_uniq_id(map_type));
+  
+  guint id = vik_map_type_get_uniq_id(map_type);
 
   /* Add the label */
   params_maptypes = g_list_append(params_maptypes, g_strdup(label));
index 7686d3f2ad827a3842905266f818f2b26ca7fcee..20822d74c8d31dac4a4e6ef686edad657b85e67b 100644 (file)
@@ -27,6 +27,7 @@
 #include "vikviewport.h"
 #include "vik-map-type.h"
 #include "mapcoord.h"
+#include "vikmapslayer_compat.h"
 
 #define VIK_MAPS_LAYER_TYPE            (vik_maps_layer_get_type ())
 #define VIK_MAPS_LAYER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_MAPS_LAYER_TYPE, VikMapsLayer))
@@ -44,7 +45,7 @@ GType vik_maps_layer_get_type ();
 
 typedef struct _VikMapsLayer VikMapsLayer;
 
-void maps_layer_register_type ( const char *label, guint id, VikMapType *map_type );
+void maps_layer_register_map_type ( const char *label, VikMapType *map_type );
 void maps_layer_download_section_without_redraw ( VikMapsLayer *vml, VikViewport *vvp, VikCoord *ul, VikCoord *br, gdouble zoom);
 gint vik_maps_layer_get_map_type(VikMapsLayer *vml);
 gchar *vik_maps_layer_get_map_label(VikMapsLayer *vml);
diff --git a/src/vikmapslayer_compat.c b/src/vikmapslayer_compat.c
new file mode 100644 (file)
index 0000000..b5177c6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
+ *
+ * Copyright (C) 2005, Evan Battaglia <viking@greentorch.org>
+ * Copyright (C) 2008-2009, Guilhem Bonnefille <guilem.bonnefille@gmail.com>
+ * UTM multi-zone stuff by Kit Transue <notlostyet@didactek.com>
+ * Dynamic map type by Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "vikmapslayer.h"
+#include "vikmapslayer_compat.h"
+#include "old-vik-map-type.h"
+
+void maps_layer_register_type ( const char *label, guint id, VikMapsLayer_MapType *map_type )
+{
+    g_assert(id == map_type->uniq_id);
+    GObject *object = old_vik_map_type_new_with_id (*map_type);
+    maps_layer_register_map_type ( label, VIK_MAP_TYPE (object) );
+}
diff --git a/src/vikmapslayer_compat.h b/src/vikmapslayer_compat.h
new file mode 100644 (file)
index 0000000..67ec71a
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
+ *
+ * Copyright (C) 2003-2005, Evan Battaglia <gtoevan@gmx.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#ifndef _VIKING_MAPSLAYER_COMPAT_H
+#define _VIKING_MAPSLAYER_COMPAT_H
+
+#include "vikcoord.h"
+#include "vikviewport.h"
+#include "mapcoord.h"
+
+typedef struct {
+  guint8 uniq_id;
+  guint16 tilesize_x;
+  guint16 tilesize_y;
+  guint drawmode;
+  gboolean (*coord_to_mapcoord) ( const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
+  void (*mapcoord_to_center_coord) ( MapCoord *src, VikCoord *dest );
+  int (*download) ( MapCoord *src, const gchar *dest_fn );
+  /* TODO: constant size (yay!) */
+} VikMapsLayer_MapType;
+
+void maps_layer_register_type ( const char *label, guint id, VikMapsLayer_MapType *map_type );
+
+#endif