X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/a3319e114fd4cba45156dc0150ee0c629185bb9f..fe2bbf2a912219b30492d0bd1b79d70fa11e3413:/src/vikwmscmapsource.c diff --git a/src/vikwmscmapsource.c b/src/vikwmscmapsource.c index 8dd74fe5..6c61fc39 100644 --- a/src/vikwmscmapsource.c +++ b/src/vikwmscmapsource.c @@ -5,7 +5,7 @@ * * viking 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 3 of the License, or + * Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * viking is distributed in the hope that it will be useful, but @@ -18,6 +18,11 @@ */ /** + * SECTION:vikwmscmapsource + * @short_description: the class for WMS/WMS-C oriented map sources + * + * The #VikWmscMapSource class handles WMS/WMS-C oriented map sources. + * * http://wiki.osgeo.org/wiki/WMS_Tile_Caching */ @@ -31,10 +36,13 @@ #include "globals.h" #include "vikwmscmapsource.h" +#include "maputils.h" static gboolean _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest ); static void _mapcoord_to_center_coord ( VikMapSource *self, MapCoord *src, VikCoord *dest ); -static gboolean _supports_download_only_new (VikMapSource *self ); +static gboolean _supports_download_only_new ( VikMapSource *self ); +static gboolean _is_direct_file_access ( VikMapSource *self ); +static gboolean _is_mbtiles ( VikMapSource *self ); static gchar *_get_uri( VikMapSourceDefault *self, MapCoord *src ); static gchar *_get_hostname( VikMapSourceDefault *self ); @@ -194,6 +202,8 @@ vik_wmsc_map_source_class_init (VikWmscMapSourceClass *klass) grandparent_class->coord_to_mapcoord = _coord_to_mapcoord; grandparent_class->mapcoord_to_center_coord = _mapcoord_to_center_coord; grandparent_class->supports_download_only_new = _supports_download_only_new; + grandparent_class->is_direct_file_access = _is_direct_file_access; + grandparent_class->is_mbtiles = _is_mbtiles; parent_class->get_uri = _get_uri; parent_class->get_hostname = _get_hostname; @@ -241,36 +251,8 @@ vik_wmsc_map_source_class_init (VikWmscMapSourceClass *klass) object_class->finalize = vik_wmsc_map_source_finalize; } -/* 1 << (x) is like a 2**(x) */ -#define GZ(x) ((1<options.check_file_server_time; } +static gboolean +_is_direct_file_access ( VikMapSource *self ) +{ + return FALSE; +} + +static gboolean +_is_mbtiles ( VikMapSource *self ) +{ + return FALSE; +} + static gboolean _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest ) { @@ -287,18 +281,18 @@ _coord_to_mapcoord ( VikMapSource *self, const VikCoord *src, gdouble xzoom, gdo if ( xzoom != yzoom ) return FALSE; - dest->scale = wmsc_zoom ( xzoom ); + dest->scale = map_utils_mpp_to_scale ( xzoom ); if ( dest->scale == 255 ) return FALSE; - /* Note : GZ(17) / xzoom / 2 = number of tile on Y axis */ + /* Note : VIK_GZ(17) / xzoom / 2 = number of tile on Y axis */ g_debug("%s: xzoom=%f yzoom=%f -> %f", __FUNCTION__, - xzoom, yzoom, GZ(17) / xzoom / 2); - dest->x = floor((src->east_west + 180) / 180 * GZ(17) / xzoom / 2); + xzoom, yzoom, VIK_GZ(17) / xzoom / 2); + dest->x = floor((src->east_west + 180) / 180 * VIK_GZ(17) / xzoom / 2); /* We should restore logic of viking: * tile index on Y axis follow a screen logic (top -> down) */ - dest->y = floor((180 - (src->north_south + 90)) / 180 * GZ(17) / xzoom / 2); + dest->y = floor((180 - (src->north_south + 90)) / 180 * VIK_GZ(17) / xzoom / 2); dest->z = 0; g_debug("%s: %f,%f -> %d,%d", __FUNCTION__, src->east_west, src->north_south, dest->x, dest->y); @@ -310,15 +304,15 @@ _mapcoord_to_center_coord ( VikMapSource *self, MapCoord *src, VikCoord *dest ) { gdouble socalled_mpp; if (src->scale >= 0) - socalled_mpp = GZ(src->scale); + socalled_mpp = VIK_GZ(src->scale); else - socalled_mpp = 1.0/GZ(-src->scale); + socalled_mpp = 1.0/VIK_GZ(-src->scale); dest->mode = VIK_COORD_LATLON; - dest->east_west = (src->x+0.5) * 180 / GZ(17) * socalled_mpp * 2 - 180; + dest->east_west = (src->x+0.5) * 180 / VIK_GZ(17) * socalled_mpp * 2 - 180; /* We should restore logic of viking: * tile index on Y axis follow a screen logic (top -> down) */ - dest->north_south = -((src->y+0.5) * 180 / GZ(17) * socalled_mpp * 2 - 90); + dest->north_south = -((src->y+0.5) * 180 / VIK_GZ(17) * socalled_mpp * 2 - 90); g_debug("%s: %d,%d -> %f,%f", __FUNCTION__, src->x, src->y, dest->east_west, dest->north_south); } @@ -331,16 +325,16 @@ _get_uri( VikMapSourceDefault *self, MapCoord *src ) VikWmscMapSourcePrivate *priv = VIK_WMSC_MAP_SOURCE_PRIVATE(self); gdouble socalled_mpp; if (src->scale >= 0) - socalled_mpp = GZ(src->scale); + socalled_mpp = VIK_GZ(src->scale); else - socalled_mpp = 1.0/GZ(-src->scale); - gdouble minx = (gdouble)src->x * 180 / GZ(17) * socalled_mpp * 2 - 180; - gdouble maxx = (gdouble)(src->x + 1) * 180 / GZ(17) * socalled_mpp * 2 - 180; + socalled_mpp = 1.0/VIK_GZ(-src->scale); + gdouble minx = (gdouble)src->x * 180 / VIK_GZ(17) * socalled_mpp * 2 - 180; + gdouble maxx = (gdouble)(src->x + 1) * 180 / VIK_GZ(17) * socalled_mpp * 2 - 180; /* We should restore logic of viking: * tile index on Y axis follow a screen logic (top -> down) */ - gdouble miny = -((gdouble)(src->y + 1) * 180 / GZ(17) * socalled_mpp * 2 - 90); - gdouble maxy = -((gdouble)(src->y) * 180 / GZ(17) * socalled_mpp * 2 - 90); + gdouble miny = -((gdouble)(src->y + 1) * 180 / VIK_GZ(17) * socalled_mpp * 2 - 90); + gdouble maxy = -((gdouble)(src->y) * 180 / VIK_GZ(17) * socalled_mpp * 2 - 90); gchar sminx[G_ASCII_DTOSTR_BUF_SIZE]; gchar smaxx[G_ASCII_DTOSTR_BUF_SIZE]; @@ -376,7 +370,7 @@ _get_download_options( VikMapSourceDefault *self ) } VikWmscMapSource * -vik_wmsc_map_source_new_with_id (guint8 id, const gchar *label, const gchar *hostname, const gchar *url) +vik_wmsc_map_source_new_with_id (guint16 id, const gchar *label, const gchar *hostname, const gchar *url) { return g_object_new(VIK_TYPE_WMSC_MAP_SOURCE, "id", id, "label", label, "hostname", hostname, "url", url, NULL);