2 * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "gis-world.h"
24 gchar *gis_tile_path_table[2][2] = {
29 GisTile *gis_tile_new(GisTile *parent,
30 gdouble n, gdouble s, gdouble e, gdouble w)
32 GisTile *self = g_new0(GisTile, 1);
33 self->parent = parent;
41 gchar *gis_tile_get_path(GisTile *child)
43 /* This could be easily cached if necessasairy */
46 for (GisTile *parent = child->parent; parent; child = parent, parent = child->parent)
47 gis_tile_foreach_index(child, x, y)
48 if (parent->children[x][y] == child)
49 parts = g_list_prepend(parts, gis_tile_path_table[x][y]);
50 GString *path = g_string_new("");
51 for (; parts; parts = parts->next)
52 g_string_append(path, parts->data);
54 return g_string_free(path, FALSE);
58 void gis_tile_free(GisTile *self, GisTileFreeFunc free_func, gpointer user_data)
63 gis_tile_foreach(self, child)
64 gis_tile_free(child, free_func, user_data);
66 free_func(self, user_data);