]> git.street.me.uk Git - andy/viking.git/commitdiff
[QA] Use the common map_utils_mpp_to_zoom function
authorRob Norris <rw_norris@hotmail.com>
Fri, 30 Aug 2013 08:42:13 +0000 (09:42 +0100)
committerRob Norris <rw_norris@hotmail.com>
Fri, 30 Aug 2013 08:42:13 +0000 (09:42 +0100)
It was introduced in commit SHA1:e1dde2a674348cf8d8805242561df4b0aab55490

However the later merge of DatasourceRemoteFile brought in an earlier version (and different location) of this common method.

So make the webtool_datasource use the new function and remove the old version.

src/util.c
src/util.h
src/vikwebtool_datasource.c

index 11dc0f17502d527e76c4263a7bd7c4da8f2a1f3c..732abbef791346774ffadd7e6a6df451d927fc29 100644 (file)
@@ -164,32 +164,6 @@ gboolean split_string_from_file_on_equals ( const gchar *buf, gchar **key, gchar
   return TRUE;
 }
 
-/* 1 << (x) is like a 2**(x) */
-#define GZ(x) (1<<(x))
-
-static const gdouble scale_mpps[] = { 0.125, 0.25, 0.5, GZ(0), GZ(1), GZ(2), GZ(3), GZ(4), GZ(5), GZ(6), GZ(7), GZ(8), GZ(9),
-                                      GZ(10), GZ(11), GZ(12), GZ(13), GZ(14), GZ(15), GZ(16), GZ(17) };
-
-static const gint num_scales = (sizeof(scale_mpps) / sizeof(scale_mpps[0]));
-
-#define ERROR_MARGIN 0.01
-/**
- * mpp_to_zoom:
- *
- * Returns: a zoom level. see : http://wiki.openstreetmap.org/wiki/Zoom_levels
- */
-guint8 mpp_to_zoom ( gdouble mpp )
-{
-  gint i;
-  for ( i = 0; i < num_scales; i++ ) {
-    if ( ABS(scale_mpps[i] - mpp) < ERROR_MARGIN ) {
-      g_debug ( "mpp_to_zoom: %f -> %d", mpp, i );
-      return 20-i;
-    }
-  }
-  return 17; // a safe zoomed in default
-}
-
 typedef struct {
   GtkWindow *window; // Layer needed for redrawing
   gchar *version;     // Image list
index 069d478c5bcbb0dc838129fdd87602f7d21e83ad..14bd361b2b4f59a0ea9faacbb256df66242b746d 100644 (file)
@@ -38,8 +38,6 @@ GList * str_array_to_glist(gchar* data[]);
 
 gboolean split_string_from_file_on_equals ( const gchar *buf, gchar **key, gchar **val );
 
-guint8 mpp_to_zoom ( gdouble mpp );
-
 void check_latest_version ( GtkWindow *window );
 
 void set_auto_features_on_first_run ( void );
index 299531ee515f970ec3c55554721f609d7c04e66b..b962f584458468d0a02e81b78d7fd265b7a5c204 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "globals.h"
 #include "acquire.h"
-#include "util.h"
+#include "maputils.h"
 
 static GObjectClass *parent_class;
 
@@ -338,7 +338,7 @@ static gchar *webtool_datasource_get_url ( VikWebtool *self, VikWindow *vw )
        guint8 zoom = 17; // A zoomed in default
        // zoom - ideally x & y factors need to be the same otherwise use the default
        if ( vik_viewport_get_xmpp ( viewport ) == vik_viewport_get_ympp ( viewport ) )
-               zoom = mpp_to_zoom ( vik_viewport_get_zoom ( viewport ) );
+               zoom = map_utils_mpp_to_zoom_level ( vik_viewport_get_zoom ( viewport ) );
 
        gchar szoom[G_ASCII_DTOSTR_BUF_SIZE];
        g_snprintf ( szoom, G_ASCII_DTOSTR_BUF_SIZE, "%d", zoom );