Verified Commit 86925e40 authored by James Westman's avatar James Westman
Browse files

Remove ShumateErrorTileSource

Errors are now handled using GError and
shumate_map_source_fill_tile_finish().
parent 7a490bfc
......@@ -97,7 +97,7 @@ on_layers_dropdown_notify_selected (ShumateDemoWindow *self, GParamSpec *pspec,
switch (gtk_drop_down_get_selected (dropdown)) {
case 0:
factory = shumate_map_source_factory_dup_default ();
set_map_source (self, shumate_map_source_factory_create_cached_source (factory, SHUMATE_MAP_SOURCE_OSM_MAPNIK));
set_map_source (self, shumate_map_source_factory_create (factory, SHUMATE_MAP_SOURCE_OSM_MAPNIK));
break;
case 1:
set_map_source (self, SHUMATE_MAP_SOURCE (shumate_test_tile_source_new ()));
......
......@@ -77,7 +77,6 @@
<title>Tile Sources</title>
<xi:include href="xml/shumate-tile-source.xml"/>
<xi:include href="xml/shumate-network-tile-source.xml"/>
<xi:include href="xml/shumate-error-tile-source.xml"/>
</chapter>
<chapter>
<title>Tile Caches</title>
......
......@@ -195,24 +195,6 @@ ShumateNetworkTileSourceClass
ShumateNetworkTileSourcePrivate
</SECTION>
<SECTION>
<FILE>shumate-error-tile-source</FILE>
<TITLE>ShumateErrorTileSource</TITLE>
ShumateErrorTileSource
shumate_error_tile_source_new_full
<SUBSECTION Standard>
SHUMATE_ERROR_TILE_SOURCE
SHUMATE_IS_ERROR_TILE_SOURCE
SHUMATE_TYPE_ERROR_TILE_SOURCE
shumate_error_tile_source_get_type
SHUMATE_ERROR_TILE_SOURCE_CLASS
SHUMATE_IS_ERROR_TILE_SOURCE_CLASS
SHUMATE_ERROR_TILE_SOURCE_GET_CLASS
<SUBSECTION Private>
ShumateErrorTileSourceClass
ShumateErrorTileSourcePrivate
</SECTION>
<SECTION>
<FILE>shumate-tile</FILE>
<TITLE>ShumateTile</TITLE>
......
shumate_coordinate_get_type
shumate_error_tile_source_get_type
shumate_file_cache_get_type
shumate_layer_get_type
shumate_license_get_type
......
libshumate_public_h = [
'shumate-coordinate.h',
'shumate-error-tile-source.h',
'shumate-file-cache.h',
'shumate-layer.h',
'shumate-license.h',
......@@ -33,7 +32,6 @@ libshumate_private_h = [
libshumate_sources = [
'shumate-coordinate.c',
'shumate-debug.c',
'shumate-error-tile-source.c',
'shumate-file-cache.c',
'shumate-kinetic-scrolling.c',
'shumate-layer.c',
......
/*
* Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* SECTION:shumate-error-tile-source
* @short_description: A tile source that doesn't load map data from anywhere
*/
#include "shumate-error-tile-source.h"
#include "shumate-debug.h"
#include "shumate-enum-types.h"
#include "shumate-tile.h"
#include "shumate-network-tile-source.h"
G_DEFINE_TYPE (ShumateErrorTileSource, shumate_error_tile_source, SHUMATE_TYPE_TILE_SOURCE)
static void
fill_tile_async (ShumateMapSource *self,
ShumateTile *tile,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (SHUMATE_IS_ERROR_TILE_SOURCE (self));
g_return_if_fail (SHUMATE_IS_TILE (tile));
g_task_report_new_error (self, callback, user_data, fill_tile_async,
SHUMATE_NETWORK_SOURCE_ERROR, SHUMATE_NETWORK_SOURCE_ERROR_FAILED,
"No tile found.");
}
static void
shumate_error_tile_source_class_init (ShumateErrorTileSourceClass *klass)
{
ShumateMapSourceClass *map_source_class = SHUMATE_MAP_SOURCE_CLASS (klass);
map_source_class->fill_tile_async = fill_tile_async;
}
static void
shumate_error_tile_source_init (ShumateErrorTileSource *self)
{
}
/**
* shumate_error_tile_source_new_full:
*
* Constructor of #ShumateErrorTileSource.
*
* Returns: a constructed #ShumateErrorTileSource object
*/
ShumateErrorTileSource *
shumate_error_tile_source_new_full (void)
{
return g_object_new (SHUMATE_TYPE_ERROR_TILE_SOURCE, NULL);
}
/*
* Copyright (C) 2010-2013 Jiri Techet <techet@gmail.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined (__SHUMATE_SHUMATE_H_INSIDE__) && !defined (SHUMATE_COMPILATION)
#error "Only <shumate/shumate.h> can be included directly."
#endif
#ifndef __SHUMATE_ERROR_TILE_SOURCE__
#define __SHUMATE_ERROR_TILE_SOURCE__
#include <glib-object.h>
#include <shumate/shumate-tile-source.h>
G_BEGIN_DECLS
#define SHUMATE_TYPE_ERROR_TILE_SOURCE shumate_error_tile_source_get_type ()
G_DECLARE_DERIVABLE_TYPE (ShumateErrorTileSource, shumate_error_tile_source, SHUMATE, ERROR_TILE_SOURCE, ShumateTileSource)
/**
* ShumateErrorTileSource:
*
* The #ShumateErrorTileSource structure contains only private data
* and should be accessed using the provided API
*/
struct _ShumateErrorTileSourceClass
{
ShumateTileSourceClass parent_class;
};
ShumateErrorTileSource *shumate_error_tile_source_new_full (void);
G_END_DECLS
#endif /* __SHUMATE_ERROR_TILE_SOURCE__ */
......@@ -290,67 +290,6 @@ shumate_map_source_factory_create (ShumateMapSourceFactory *factory,
}
/**
* shumate_map_source_factory_create_cached_source:
* @factory: the Factory
* @id: the wanted map source id
*
* Creates a cached map source.
*
* Returns: (transfer none): a ready to use #ShumateMapSourceChain consisting of
* #ShumateMapSource matching the given name and
* an error tile source created with shumate_map_source_factory_create_error_source ().
* Returns NULL if the source with the given name doesn't exist.
*/
ShumateMapSource *
shumate_map_source_factory_create_cached_source (ShumateMapSourceFactory *factory,
const char *id)
{
ShumateMapSourceChain *source_chain;
ShumateMapSource *tile_source;
ShumateMapSource *error_source;
guint tile_size;
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_FACTORY (factory), NULL);
tile_source = shumate_map_source_factory_create (factory, id);
if (!tile_source)
return NULL;
tile_size = shumate_map_source_get_tile_size (tile_source);
error_source = shumate_map_source_factory_create_error_source (factory, tile_size);
source_chain = shumate_map_source_chain_new ();
shumate_map_source_chain_push (source_chain, error_source);
shumate_map_source_chain_push (source_chain, tile_source);
return SHUMATE_MAP_SOURCE (source_chain);
}
/**
* shumate_map_source_factory_create_error_source:
* @factory: the Factory
* @tile_size: the size of the error tile
*
* Creates a map source generating error tiles.
*
* Returns: (transfer none): a ready to use map source generating error tiles.
*/
ShumateMapSource *
shumate_map_source_factory_create_error_source (ShumateMapSourceFactory *factory,
guint tile_size)
{
ShumateMapSource *error_source;
g_return_val_if_fail (SHUMATE_IS_MAP_SOURCE_FACTORY (factory), NULL);
error_source = SHUMATE_MAP_SOURCE (shumate_error_tile_source_new_full ());
return error_source;
}
static int
compare_id (ShumateMapSourceDesc *a, ShumateMapSourceDesc *b)
{
......
......@@ -46,10 +46,6 @@ ShumateMapSourceFactory *shumate_map_source_factory_dup_default (void);
ShumateMapSource *shumate_map_source_factory_create (ShumateMapSourceFactory *factory,
const char *id);
ShumateMapSource *shumate_map_source_factory_create_cached_source (ShumateMapSourceFactory *factory,
const char *id);
ShumateMapSource *shumate_map_source_factory_create_error_source (ShumateMapSourceFactory *factory,
guint tile_size);
gboolean shumate_map_source_factory_register (ShumateMapSourceFactory *factory,
ShumateMapSourceDesc *desc);
......
......@@ -922,7 +922,7 @@ shumate_view_new_simple (void)
viewport = shumate_view_get_viewport (view);
factory = shumate_map_source_factory_dup_default ();
source = shumate_map_source_factory_create_cached_source (factory, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
source = shumate_map_source_factory_create (factory, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
shumate_viewport_set_reference_map_source (viewport, source);
map_layer = shumate_map_layer_new (source, viewport);
shumate_view_add_layer (view, SHUMATE_LAYER (map_layer));
......
......@@ -48,7 +48,6 @@
#include "shumate/shumate-map-source-chain.h"
#include "shumate/shumate-network-tile-source.h"
#include "shumate/shumate-error-tile-source.h"
#include "shumate/shumate-memory-cache.h"
#include "shumate/shumate-file-cache.h"
......
......@@ -16,7 +16,7 @@ test_coordinate_convert (void)
g_assert_nonnull (factory);
source = shumate_map_source_factory_create_cached_source (factory, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
source = shumate_map_source_factory_create (factory, SHUMATE_MAP_SOURCE_OSM_MAPNIK);
g_assert_nonnull (source);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment