X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fgis-wms.c;h=defedb3cd7b516dad3f440c37940df77fdbec004;hb=6191cb37c36331a119189699d519d84f359d2c9b;hp=0c15e874d00a71e110cfe1090a2c66c8e04ce166;hpb=2e575e2c348f44d3c723ac344b7296492c76f77a;p=grits diff --git a/src/gis-wms.c b/src/gis-wms.c index 0c15e87..defedb3 100644 --- a/src/gis-wms.c +++ b/src/gis-wms.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Andy Spencer + * Copyright (C) 2009-2010 Andy Spencer * * 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 @@ -15,6 +15,23 @@ * along with this program. If not, see . */ +/** + * Metacarte + * --------- + * http://labs.metacarta.com/wms/vmap0? + * LAYERS=basic& + * SERVICE=WMS& + * VERSION=1.1.1& + * REQUEST=GetMap& + * STYLES=& + * EXCEPTIONS=application/vnd.ogc.se_inimage& + * FORMAT=image/jpeg& + * SRS=EPSG:4326& + * BBOX=0,-90,180,90& + * WIDTH=256& + * HEIGHT=256 + */ + /** * http://www.nasa.network.com/elev? * SERVICE=WMS& @@ -72,11 +89,13 @@ static gchar *_make_uri(GisWms *wms, GisTile *tile) tile->edge.n); } -void gis_wms_soup_chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _file) +static void _soup_chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _file) { FILE *file = _file; - if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) + if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) { + g_warning("GisWms: soup_chunk_cb - soup failed with %d", message->status_code); return; + } goffset total = soup_message_headers_get_content_length(message->response_headers); if (fwrite(chunk->data, chunk->length, 1, file) != 1) g_warning("GisWms: soup_chunk_cb - eror writing data"); @@ -86,11 +105,9 @@ char *gis_wms_make_local(GisWms *self, GisTile *tile) { /* Get file path */ gchar *tile_path = gis_tile_get_path(tile); - gchar *path = g_strdup_printf("%s/wms/%s%s%s", - g_get_user_cache_dir(), - self->cache_prefix, - tile_path, - self->cache_ext); + gchar *path = g_strdup_printf("%s/%s/%s%s%s", + g_get_user_cache_dir(), PACKAGE, + self->cache_prefix, tile_path, self->cache_ext); g_free(tile_path); /* Return if it already exists */ @@ -106,10 +123,13 @@ char *gis_wms_make_local(GisWms *self, GisTile *tile) /* Download file */ gchar *uri = _make_uri(self, tile); + g_debug("GisWms: make_local - fetching %s", uri); SoupMessage *message = soup_message_new("GET", uri); - g_signal_connect(message, "got-chunk", G_CALLBACK(gis_wms_soup_chunk_cb), file); + g_signal_connect(message, "got-chunk", G_CALLBACK(_soup_chunk_cb), file); soup_message_headers_set_range(message->request_headers, ftell(file), -1); int status = soup_session_send_message(self->soup, message); + if (!SOUP_STATUS_IS_SUCCESSFUL(message->status_code)) + g_warning("GisWms: make_local - soup failed with %d", message->status_code); g_free(uri); /* Clean up */