X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fplugins%2Fsat.c;h=9e1af30e6a5eca5a561c19aac13be5814b4426a9;hp=edbe652834ae855349e3873bf4bcd6cd0cfb3c77;hb=14c34a746fc94a9e5477d081275f04bd1c8b5d6d;hpb=78550a3dc871c42dbc3e124abce78b902f978afd diff --git a/src/plugins/sat.c b/src/plugins/sat.c index edbe652..9e1af30 100644 --- a/src/plugins/sat.c +++ b/src/plugins/sat.c @@ -125,12 +125,12 @@ static gpointer _update_tiles(gpointer _sat) { g_debug("GisPluginSat: _update_tiles"); GisPluginSat *sat = _sat; - g_mutex_lock(sat->mutex); - gdouble lat, lon, elev; - gis_viewer_get_location(sat->viewer, &lat, &lon, &elev); - gis_tile_update(sat->tiles, + if (!g_mutex_trylock(sat->mutex)) + return NULL; + GisPoint eye; + gis_viewer_get_location(sat->viewer, &eye.lat, &eye.lon, &eye.elev); + gis_tile_update(sat->tiles, &eye, MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH, - lat, lon, elev, _load_tile, sat); gis_tile_gc(sat->tiles, time(NULL)-10, _free_tile, sat); @@ -147,6 +147,13 @@ static void _on_location_changed(GisViewer *viewer, g_thread_create(_update_tiles, sat, FALSE, NULL); } +static gpointer _threaded_init(GisPluginSat *sat) +{ + _load_tile(sat->tiles, sat); + _update_tiles(sat); + return NULL; +} + /*********** * Methods * ***********/ @@ -165,15 +172,14 @@ GisPluginSat *gis_plugin_sat_new(GisViewer *viewer) sat->viewer = g_object_ref(viewer); /* Load initial tiles */ - _load_tile(sat->tiles, sat); - g_thread_create(_update_tiles, sat, FALSE, NULL); + g_thread_create((GThreadFunc)_threaded_init, sat, FALSE, NULL); /* Connect signals */ sat->sigid = g_signal_connect(sat->viewer, "location-changed", G_CALLBACK(_on_location_changed), sat); /* Add renderers */ - gis_viewer_add(viewer, GIS_OBJECT(sat->tiles), GIS_LEVEL_WORLD, 0); + gis_viewer_add(viewer, GIS_OBJECT(sat->tiles), GIS_LEVEL_WORLD, FALSE); return sat; }