From becee285e152746e64b6d3984e2a7229f664062d Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 9 Nov 2009 15:00:20 +0000 Subject: [PATCH] Fix misc bugs and bump version to 0.3 --- Makefile.am | 2 +- configure.ac | 2 +- docs/api/Makefile.am | 4 ++-- docs/api/libgis-docs.sgml | 37 +++++++++++++++++++++++++++++++++++++ src/Makefile.am | 2 +- src/gis-opengl.c | 19 +++++++++++++++++++ src/gis-opengl.h | 2 ++ src/gis-plugin.c | 3 ++- src/gis-prefs.c | 7 +++---- src/gis-tile.c | 4 ++-- src/gis-wms.c | 8 +++----- src/plugins/Makefile.am | 18 +++++++----------- src/plugins/bmng.c | 9 ++++++--- src/plugins/bmng.h | 1 + src/plugins/srtm.c | 11 +++++++---- src/plugins/srtm.h | 1 + src/roam.c | 3 ++- src/wms_test.c | 2 +- 18 files changed, 98 insertions(+), 37 deletions(-) create mode 100644 docs/api/libgis-docs.sgml diff --git a/Makefile.am b/Makefile.am index 3f41410..f8becba 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,7 +16,7 @@ release: all dist git push --all echo $(VERSION) > LATEST scp LATEST $(PACKAGE)-$(VERSION).tar.* \ - "lug@lug.rose-hulman.edu:/home/lug/htdocs/proj/$(PACKAGE)"; \ + "spenceal@lug.rose-hulman.edu:/home/lug/htdocs/proj/$(PACKAGE)"; \ rm -f LATEST depscan: diff --git a/configure.ac b/configure.ac index d3b9360..e9d4b08 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Init and options -AC_INIT([libgis], [0.3-p1], [spenceal@rose-hulman.edu]) +AC_INIT([libgis], [0.3], [spenceal@rose-hulman.edu]) AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability foreign]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/docs/api/Makefile.am b/docs/api/Makefile.am index 57a416d..742a495 100644 --- a/docs/api/Makefile.am +++ b/docs/api/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS=$(SOUP_CFLAGS) $(GLIB_CFLAGS) $(GTK_CFLAGS) -GTKDOC_LIBS = $(SOUP_LIBS) $(GLIB_LIBS) $(GTK_LIBS) $(top_srcdir)/src/libgis.la +GTKDOC_LIBS = $(SOUP_LIBS) $(GLIB_LIBS) $(GTK_LIBS) $(top_srcdir)/src/libgis.la $(top_srcdir)/src/plugins/*.la DOC_MODULE = libgis DOC_SOURCE_DIR = $(top_srcdir)/src/ DOC_MAIN_SGML_FILE = $(DOC_MODULE)-docs.sgml @@ -10,4 +10,4 @@ include $(top_srcdir)/gtk-doc.make CLEANFILES += libgis-sections.txt MAINTAINERCLEANFILES=\ - tmpl/* Makefile.in libgis-docs.sgml libgis-overrides.txt libgis.types libgis-scan.* + tmpl/* Makefile.in libgis-overrides.txt libgis.types libgis-scan.* diff --git a/docs/api/libgis-docs.sgml b/docs/api/libgis-docs.sgml new file mode 100644 index 0000000..16957c0 --- /dev/null +++ b/docs/api/libgis-docs.sgml @@ -0,0 +1,37 @@ + + + + + libgis Reference Manual + + + + Core API + + + + + + + + Support + + + + + + + + + Plugins + + + + + + + Index + + + diff --git a/src/Makefile.am b/src/Makefile.am index 5e3da6d..70ebf3c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = plugins +SUBDIRS = . plugins AM_CFLAGS = -Wall --std=gnu99 AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) $(SOUP_CFLAGS) diff --git a/src/gis-opengl.c b/src/gis-opengl.c index 86fba80..1b21990 100644 --- a/src/gis-opengl.c +++ b/src/gis-opengl.c @@ -370,6 +370,25 @@ void gis_opengl_set_height_func(GisOpenGL *self, GisTile *tile, g_list_free(triangles); } +static void _gis_opengl_clear_height_func_rec(RoamTriangle *root) +{ + if (!root) + return; + RoamPoint *points[] = {root->p.l, root->p.m, root->p.r, root->split}; + for (int i = 0; i < G_N_ELEMENTS(points); i++) { + points[i]->height_func = NULL; + points[i]->height_data = NULL; + roam_point_update_height(points[i]); + } + _gis_opengl_clear_height_func_rec(root->kids[0]); + _gis_opengl_clear_height_func_rec(root->kids[1]); +} +void gis_opengl_clear_height_func(GisOpenGL *self) +{ + for (int i = 0; i < G_N_ELEMENTS(self->sphere->roots); i++) + _gis_opengl_clear_height_func_rec(self->sphere->roots[i]); +} + void gis_opengl_redraw(GisOpenGL *self) { g_debug("GisOpenGL: redraw"); diff --git a/src/gis-opengl.h b/src/gis-opengl.h index 37099a7..256d0d0 100644 --- a/src/gis-opengl.h +++ b/src/gis-opengl.h @@ -74,6 +74,8 @@ void gis_opengl_render_tiles(GisOpenGL *opengl, GisTile *root); void gis_opengl_set_height_func(GisOpenGL *self, GisTile *tile, RoamHeightFunc height_func, gpointer user_data, gboolean update); +void gis_opengl_clear_height_func(GisOpenGL *self); + void gis_opengl_redraw(GisOpenGL *opengl); void gis_opengl_begin(GisOpenGL *opengl); diff --git a/src/gis-plugin.c b/src/gis-plugin.c index b0619f9..eb162b7 100644 --- a/src/gis-plugin.c +++ b/src/gis-plugin.c @@ -56,7 +56,8 @@ void gis_plugin_expose(GisPlugin *self) GtkWidget *gis_plugin_get_config(GisPlugin *self) { g_return_val_if_fail(GIS_IS_PLUGIN(self), NULL); - return GIS_PLUGIN_GET_INTERFACE(self)->get_config(self); + GisPluginInterface *iface = GIS_PLUGIN_GET_INTERFACE(self); + return iface->get_config ? iface->get_config (self) : NULL; } diff --git a/src/gis-prefs.c b/src/gis-prefs.c index 02d456d..d7d7d6d 100644 --- a/src/gis-prefs.c +++ b/src/gis-prefs.c @@ -15,18 +15,18 @@ * along with this program. If not, see . */ +#include + #include #include "gis-marshal.h" #include "gis-prefs.h" - enum { SIG_PREF_CHANGED, NUM_SIGNALS, }; static guint signals[NUM_SIGNALS]; - /*********** * Methods * ***********/ @@ -38,7 +38,7 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults) self->key_path = g_strdup(config); else self->key_path = g_build_filename(g_get_user_config_dir(), - "gis", "config.ini", NULL); + PACKAGE, "config.ini", NULL); GError *error = NULL; g_key_file_load_from_file(self->key_file, self->key_path, G_KEY_FILE_KEEP_COMMENTS, &error); @@ -57,7 +57,6 @@ GisPrefs *gis_prefs_new(const gchar *config, const gchar *defaults) g_free(tmp); } if (error) { - g_clear_error(&error); g_warning("GisPrefs: new - Unable to load key file `%s': %s", self->key_path, error->message); } diff --git a/src/gis-tile.c b/src/gis-tile.c index 7a0f0b8..07baa09 100644 --- a/src/gis-tile.c +++ b/src/gis-tile.c @@ -22,8 +22,8 @@ #include "gis-tile.h" gchar *gis_tile_path_table[2][2] = { - {".00", ".01"}, - {".10", ".11"}, + {"00.", "01."}, + {"10.", "11."}, }; GisTile *gis_tile_new(GisTile *parent, diff --git a/src/gis-wms.c b/src/gis-wms.c index 0c15e87..bd4704d 100644 --- a/src/gis-wms.c +++ b/src/gis-wms.c @@ -86,11 +86,9 @@ char *gis_wms_make_local(GisWms *self, GisTile *tile) { /* Get file path */ gchar *tile_path = gis_tile_get_path(tile); - gchar *path = g_strdup_printf("%s/wms/%s%s%s", - g_get_user_cache_dir(), - self->cache_prefix, - tile_path, - self->cache_ext); + gchar *path = g_strdup_printf("%s/%s/%s%s%s", + g_get_user_cache_dir(), PACKAGE, + self->cache_prefix, tile_path, self->cache_ext); g_free(tile_path); /* Return if it already exists */ diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 6e49cb8..3ebba58 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -1,21 +1,17 @@ MAINTAINERCLEANFILES = Makefile.in -AM_CFLAGS = -Wall --std=gnu99 -I../ -AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) $(SOUP_CFLAGS) -AM_LDFLAGS = -module -avoid-version -LIBS = $(top_srcdir)/src/libgis.la +AM_CFLAGS = -Wall --std=gnu99 -I../ +AM_CPPFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) $(SOUP_CFLAGS) +AM_LDFLAGS = -module -avoid-version +LIBS = $(top_srcdir)/src/libgis.la -pluginsdir = $(pkglibdir) +pluginsdir = "$(libdir)/gis" plugins_LTLIBRARIES = bmng.la srtm.la bmng_la_SOURCES = bmng.c bmng.h +bmng_la_LIBADD = $(top_srcdir)/src/libgis.la srtm_la_SOURCES = srtm.c srtm.h +srtm_la_LIBADD = $(top_srcdir)/src/libgis.la test: ( cd ../; make test ) - -# Fixme... -bmng_la_DEPENDENCIES = $(top_srcdir)/src/libgis.la -srtm_la_DEPENDENCIES = $(top_srcdir)/src/libgis.la -$(top_srcdir)/src/libgis.la: $(wildcard ../*.[ch]) - ( cd ../; make libgis.la ) diff --git a/src/plugins/bmng.c b/src/plugins/bmng.c index 8b02749..7aff2a7 100644 --- a/src/plugins/bmng.c +++ b/src/plugins/bmng.c @@ -136,7 +136,8 @@ GisPluginBmng *gis_plugin_bmng_new(GisWorld *world, GisView *view, GisOpenGL *op g_thread_create(_update_tiles, self, FALSE, NULL); /* Connect signals */ - g_signal_connect(self->view, "location-changed", G_CALLBACK(_on_location_changed), self); + self->sigid = g_signal_connect(self->view, "location-changed", + G_CALLBACK(_on_location_changed), self); return self; } @@ -144,7 +145,8 @@ GisPluginBmng *gis_plugin_bmng_new(GisWorld *world, GisView *view, GisOpenGL *op static void gis_plugin_bmng_expose(GisPlugin *_self) { GisPluginBmng *self = GIS_PLUGIN_BMNG(_self); - g_debug("GisPluginBmng: expose"); + g_debug("GisPluginBmng: expose opengl=%p tiles=%p,%p", + self->opengl, self->tiles, self->tiles->data); gis_opengl_render_tiles(self->opengl, self->tiles); } @@ -172,13 +174,14 @@ static void gis_plugin_bmng_init(GisPluginBmng *self) self->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); self->wms = gis_wms_new( "http://www.nasa.network.com/wms", "bmng200406", "image/jpeg", - "bmng", ".jpg", TILE_WIDTH, TILE_HEIGHT); + "bmng/", "jpg", TILE_WIDTH, TILE_HEIGHT); } static void gis_plugin_bmng_dispose(GObject *gobject) { g_debug("GisPluginBmng: dispose"); GisPluginBmng *self = GIS_PLUGIN_BMNG(gobject); /* Drop references */ + g_signal_handler_disconnect(self->view, self->sigid); G_OBJECT_CLASS(gis_plugin_bmng_parent_class)->dispose(gobject); } static void gis_plugin_bmng_finalize(GObject *gobject) diff --git a/src/plugins/bmng.h b/src/plugins/bmng.h index 5ebed78..f8eadca 100644 --- a/src/plugins/bmng.h +++ b/src/plugins/bmng.h @@ -39,6 +39,7 @@ struct _GisPluginBmng { GisTile *tiles; GisWms *wms; GMutex *mutex; + gulong sigid; }; struct _GisPluginBmngClass { diff --git a/src/plugins/srtm.c b/src/plugins/srtm.c index 67dd7e0..e4460fe 100644 --- a/src/plugins/srtm.c +++ b/src/plugins/srtm.c @@ -162,8 +162,7 @@ static gboolean _load_tile_cb(gpointer _load) /* Do necessasairy processing */ /* TODO: Lock this and move to thread, can remove self from _load then */ if (LOAD_BIL) - gis_opengl_set_height_func(self->opengl, tile, - _height_func, self, TRUE); + gis_opengl_set_height_func(self->opengl, tile, _height_func, self, TRUE); /* Cleanup unneeded things */ if (!LOAD_BIL) @@ -250,7 +249,8 @@ GisPluginSrtm *gis_plugin_srtm_new(GisWorld *world, GisView *view, GisOpenGL *op g_thread_create(_update_tiles, self, FALSE, NULL); /* Connect signals */ - g_signal_connect(view, "location-changed", G_CALLBACK(_on_location_changed), self); + self->sigid = g_signal_connect(self->view, "location-changed", + G_CALLBACK(_on_location_changed), self); return self; } @@ -288,13 +288,16 @@ static void gis_plugin_srtm_init(GisPluginSrtm *self) self->tiles = gis_tile_new(NULL, NORTH, SOUTH, EAST, WEST); self->wms = gis_wms_new( "http://www.nasa.network.com/elev", "srtm30", "application/bil", - "srtm", ".bil", TILE_WIDTH, TILE_HEIGHT); + "srtm/", "bil", TILE_WIDTH, TILE_HEIGHT); } static void gis_plugin_srtm_dispose(GObject *gobject) { g_debug("GisPluginSrtm: dispose"); GisPluginSrtm *self = GIS_PLUGIN_SRTM(gobject); /* Drop references */ + g_signal_handler_disconnect(self->view, self->sigid); + if (LOAD_BIL) + gis_opengl_clear_height_func(self->opengl); G_OBJECT_CLASS(gis_plugin_srtm_parent_class)->dispose(gobject); } static void gis_plugin_srtm_finalize(GObject *gobject) diff --git a/src/plugins/srtm.h b/src/plugins/srtm.h index 32fc08a..890fd2e 100644 --- a/src/plugins/srtm.h +++ b/src/plugins/srtm.h @@ -39,6 +39,7 @@ struct _GisPluginSrtm { GisTile *tiles; GisWms *wms; GMutex *mutex; + gulong sigid; }; struct _GisPluginSrtmClass { diff --git a/src/roam.c b/src/roam.c index 9f2474f..de09bce 100644 --- a/src/roam.c +++ b/src/roam.c @@ -672,7 +672,8 @@ GList *roam_sphere_get_intersect(RoamSphere *self, * time = 30 * 2*333 * i_cost = 20000 * i_cost */ GList *list = NULL; for (int i = 0; i < G_N_ELEMENTS(self->roots); i++) - list = _roam_sphere_get_intersect_rec(self->roots[i], list, n, s, e, w); + list = _roam_sphere_get_intersect_rec(self->roots[i], + list, n, s, e, w); return list; } void roam_sphere_free_tri(RoamTriangle *tri) diff --git a/src/wms_test.c b/src/wms_test.c index c456659..625d83f 100644 --- a/src/wms_test.c +++ b/src/wms_test.c @@ -40,7 +40,7 @@ gpointer do_cache(gpointer _image) g_message("Fetching image"); GisWms *bmng_wms = gis_wms_new( "http://www.nasa.network.com/wms", "bmng200406", "image/jpeg", - "bmng", ".jpg", 512, 256); + "bmng_test/", "jpg", 512, 256); const char *path = gis_wms_make_local(bmng_wms, tile); g_message("Loading image: [%s]", path); -- 2.41.0