]> git.street.me.uk Git - andy/viking.git/blob - src/vikmaptype.c
Remove dependencies to gob2
[andy/viking.git] / src / vikmaptype.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3  * viking
4  * Copyright (C) Guilhem Bonnefille 2009 <guilhem.bonnefille@gmail.com>
5  * 
6  * viking is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  * 
11  * viking is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along
17  * with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22
23 #include "vikmaptype.h"
24 #include "vikmapslayer_compat.h"
25
26 static gboolean map_type_coord_to_mapcoord (VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest );
27 static void map_type_mapcoord_to_center_coord (VikMapSource *self, MapCoord *src, VikCoord *dest);
28 static int map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn);
29
30 typedef struct _VikMapTypePrivate VikMapTypePrivate;
31 struct _VikMapTypePrivate
32 {
33         VikMapsLayer_MapType map_type;
34 };
35
36 #define VIK_MAP_TYPE_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE ((o), VIK_TYPE_MAP_TYPE, VikMapTypePrivate))
37
38
39 G_DEFINE_TYPE (VikMapType, vik_map_type, VIK_TYPE_MAP_SOURCE);
40
41 static void
42 vik_map_type_init (VikMapType *object)
43 {
44         /* TODO: Add initialization code here */
45 }
46
47 VikMapType *
48 vik_map_type_new_with_id (VikMapsLayer_MapType map_type)
49 {
50         VikMapType *ret = (VikMapType *)g_object_new(vik_map_type_get_type(), NULL);
51         VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(ret);
52         priv->map_type = map_type;
53         return ret;
54 }
55
56 static void
57 vik_map_type_finalize (GObject *object)
58 {
59         /* TODO: Add deinitalization code here */
60
61         G_OBJECT_CLASS (vik_map_type_parent_class)->finalize (object);
62 }
63
64 static void
65 vik_map_type_class_init (VikMapTypeClass *klass)
66 {
67         GObjectClass* object_class = G_OBJECT_CLASS (klass);
68         VikMapSourceClass* parent_class = VIK_MAP_SOURCE_CLASS (klass);
69
70         /* Overiding methods */
71         parent_class->coord_to_mapcoord =        map_type_coord_to_mapcoord;
72         parent_class->mapcoord_to_center_coord = map_type_mapcoord_to_center_coord;
73         parent_class->download =                 map_type_download;
74
75         g_type_class_add_private (klass, sizeof (VikMapTypePrivate));
76
77         object_class->finalize = vik_map_type_finalize;
78 }
79
80 static gboolean
81 map_type_coord_to_mapcoord (VikMapSource *self, const VikCoord *src, gdouble xzoom, gdouble yzoom, MapCoord *dest )
82 {
83     VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self);
84         g_return_val_if_fail (priv != NULL, FALSE);
85
86         return (priv->map_type.coord_to_mapcoord)(src, xzoom, yzoom, dest);
87 }
88
89 static void
90 map_type_mapcoord_to_center_coord (VikMapSource *self, MapCoord *src, VikCoord *dest)
91 {
92     VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self);
93         g_return_if_fail (self != NULL);
94
95         return (priv->map_type.mapcoord_to_center_coord)(src, dest);
96 }
97
98 static int
99 map_type_download (VikMapSource * self, MapCoord * src, const gchar * dest_fn)
100 {
101     VikMapTypePrivate *priv = VIK_MAP_TYPE_PRIVATE(self);
102         g_return_val_if_fail (priv != NULL, 0);
103
104         return (priv->map_type.download)(src, dest_fn);
105 }
106