X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Fgis-tile.c;h=cf3f85777743042923693282ada0e6d9d9dc3b96;hb=8b64adae18ba4c5429919866551d19a7310c49ad;hp=07baa09d6b4ab12e3f8b1a4d0bf070291a691810;hpb=becee285e152746e64b6d3984e2a7229f664062d;p=grits diff --git a/src/gis-tile.c b/src/gis-tile.c index 07baa09..cf3f857 100644 --- a/src/gis-tile.c +++ b/src/gis-tile.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 @@ -18,8 +18,8 @@ #include #include -#include "gis-world.h" #include "gis-tile.h" +#include "gis-util.h" gchar *gis_tile_path_table[2][2] = { {"00.", "01."}, @@ -29,7 +29,7 @@ gchar *gis_tile_path_table[2][2] = { GisTile *gis_tile_new(GisTile *parent, gdouble n, gdouble s, gdouble e, gdouble w) { - GisTile *self = g_new0(GisTile, 1); + GisTile *self = g_object_new(GIS_TYPE_TILE, NULL); self->parent = parent; self->edge.n = n; self->edge.s = s; @@ -142,6 +142,13 @@ GisTile *gis_tile_find(GisTile *self, gdouble lat, gdouble lon) gint row = lat_offset / lat_step; gint col = lon_offset / lon_step; + if (lon == 180) col--; + if (lat == -90) row--; + + //if (lon == 180 || lon == -180) + // g_message("lat=%f,lon=%f step=%f,%f off=%f,%f row=%d/%d,col=%d/%d", + // lat,lon, lat_step,lon_step, lat_offset,lon_offset, row,rows,col,cols); + if (row < 0 || row >= rows || col < 0 || col >= cols) return NULL; else if (self->children[row][col] && self->children[row][col]->data) @@ -183,5 +190,10 @@ void gis_tile_free(GisTile *self, GisTileFreeFunc free_func, gpointer user_data) gis_tile_free(child, free_func, user_data); if (free_func) free_func(self, user_data); - g_free(self); + g_object_unref(self); } + +/* GObject code */ +G_DEFINE_TYPE(GisTile, gis_tile, GIS_TYPE_OBJECT); +static void gis_tile_init(GisTile *self) { } +static void gis_tile_class_init(GisTileClass *klass) { }