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/>.
18 #ifndef __GIS_TILE_H__
19 #define __GIS_TILE_H__
24 typedef struct _GisTile GisTile;
26 #define gis_tile_foreach(tile, child) \
27 for (int _x = 0; _x < G_N_ELEMENTS(tile->children); _x++) \
28 for (int _y = 0; child = tile->children[_x][_y], \
29 _y < G_N_ELEMENTS(tile->children[_x]); _y++) \
31 #define gis_tile_foreach_index(tile, x, y) \
32 for (x = 0; x < G_N_ELEMENTS(tile->children); x++) \
33 for (y = 0; y < G_N_ELEMENTS(tile->children[x]); y++)
35 typedef void (*GisTileLoadFunc)(GisTile *tile, gpointer user_data);
36 typedef void (*GisTileFreeFunc)(GisTile *tile, gpointer user_data);
39 /* Pointer to the tile data */
42 /* North,South,East,West limits */
47 /* Pointers to parent/child nodes */
49 GisTile *children[2][2];
52 /* Path to string table, keep in sync with tile->children */
53 extern gchar *gis_tile_path_table[2][2];
55 /* Allocate a new Tile */
56 GisTile *gis_tile_new(GisTile *parent,
57 gdouble n, gdouble s, gdouble e, gdouble w);
59 /* Return a string representation of the tile's path */
60 gchar *gis_tile_get_path(GisTile *child);
62 /* Free a tile and all it's children */
63 void gis_tile_free(GisTile *root,
64 GisTileFreeFunc free_func, gpointer user_data);