X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/9a9c986e71c9e77b87a9585c6d3594cf2794c707..70b96cd5a507e68b74797cd3015b7c99805249f6:/src/vikwebtoolbounds.c diff --git a/src/vikwebtoolbounds.c b/src/vikwebtoolbounds.c index b6acf96a..c2d733da 100644 --- a/src/vikwebtoolbounds.c +++ b/src/vikwebtoolbounds.c @@ -2,7 +2,7 @@ /* * viking -- GPS Data and Topo Analyzer, Explorer, and Manager * - * Copyright (C) 2011, Rob Norris + * Copyright (C) 2011-2015, Rob Norris * * 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 @@ -33,14 +33,11 @@ #include "globals.h" -static void webtool_bounds_class_init ( VikWebtoolBoundsClass *klass ); -static void webtool_bounds_init ( VikWebtoolBounds *vwd ); - static GObjectClass *parent_class; static void webtool_bounds_finalize ( GObject *gob ); - static gchar *webtool_bounds_get_url ( VikWebtool *vw, VikWindow *vwindow ); +static gchar *webtool_bounds_get_url_at_position ( VikWebtool *vw, VikWindow *vwindow, VikCoord *vc ); typedef struct _VikWebtoolBoundsPrivate VikWebtoolBoundsPrivate; @@ -53,29 +50,7 @@ struct _VikWebtoolBoundsPrivate VIK_WEBTOOL_BOUNDS_TYPE, \ VikWebtoolBoundsPrivate)) -GType vik_webtool_bounds_get_type() -{ - static GType w_type = 0; - - if (!w_type) - { - static const GTypeInfo w_info = - { - sizeof (VikWebtoolBoundsClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) webtool_bounds_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (VikWebtoolBounds), - 0, - (GInstanceInitFunc) webtool_bounds_init, - }; - w_type = g_type_register_static ( VIK_WEBTOOL_TYPE, "VikWebtoolBounds", &w_info, 0 ); - } - - return w_type; -} +G_DEFINE_TYPE (VikWebtoolBounds, vik_webtool_bounds, VIK_WEBTOOL_TYPE) enum { @@ -130,7 +105,8 @@ webtool_bounds_get_property (GObject *object, } } -static void webtool_bounds_class_init ( VikWebtoolBoundsClass *klass ) +static void +vik_webtool_bounds_class_init ( VikWebtoolBoundsClass *klass ) { GObjectClass *gobject_class; VikWebtoolClass *base_class; @@ -155,8 +131,7 @@ static void webtool_bounds_class_init ( VikWebtoolBoundsClass *klass ) base_class = VIK_WEBTOOL_CLASS ( klass ); base_class->get_url = webtool_bounds_get_url; - - //klass->mpp_to_zoom = webtool_bounds_mpp_to_zoom; + base_class->get_url_at_position = webtool_bounds_get_url_at_position; g_type_class_add_private (klass, sizeof (VikWebtoolBoundsPrivate)); } @@ -176,7 +151,8 @@ VikWebtoolBounds *vik_webtool_bounds_new_with_members ( const gchar *label, cons return result; } -static void webtool_bounds_init ( VikWebtoolBounds *self ) +static void +vik_webtool_bounds_init ( VikWebtoolBounds *self ) { VikWebtoolBoundsPrivate *priv = WEBTOOL_BOUNDS_GET_PRIVATE (self); priv->url = NULL; @@ -214,3 +190,10 @@ static gchar *webtool_bounds_get_url ( VikWebtool *self, VikWindow *vwindow ) return g_strdup_printf ( priv->url, sminlon, smaxlon, sminlat, smaxlat ); } + +static gchar *webtool_bounds_get_url_at_position ( VikWebtool *self, VikWindow *vwindow, VikCoord *vc ) +{ + // TODO: could use zoom level to generate an offset from center lat/lon to get the bounds + // For now simply use the existing function to use bounds from the viewport + return webtool_bounds_get_url ( self, vwindow ); +}