* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * SECTION:map
+ * @short_description: Map plugin
+ *
+ * #GisPluginMap provides map overlays. Much of this data is obtained from the
+ * OpenStreetMap project.
+ */
+
#include <time.h>
#include <stdlib.h>
#include <glib/gstdio.h>
(alpha ? GL_RGBA : GL_RGB), GL_UNSIGNED_BYTE, pixels);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glFlush();
tile->data = tex;
{
g_debug("GisPluginMap: _update_tiles");
GisPluginMap *map = _map;
- g_mutex_lock(map->mutex);
- gdouble lat, lon, elev;
- gis_viewer_get_location(map->viewer, &lat, &lon, &elev);
- gis_tile_update(map->tiles,
+ if (!g_mutex_trylock(map->mutex))
+ return NULL;
+ GisPoint eye;
+ gis_viewer_get_location(map->viewer, &eye.lat, &eye.lon, &eye.elev);
+ gis_tile_update(map->tiles, &eye,
MAX_RESOLUTION, TILE_WIDTH, TILE_WIDTH,
- lat, lon, elev,
_load_tile, map);
gis_tile_gc(map->tiles, time(NULL)-10,
_free_tile, map);
g_thread_create(_update_tiles, map, FALSE, NULL);
}
+static gpointer _threaded_init(GisPluginMap *map)
+{
+ _load_tile(map->tiles, map);
+ _update_tiles(map);
+ return NULL;
+}
+
/***********
* Methods *
***********/
+/**
+ * gis_plugin_map_new:
+ * @viewer: the #GisViewer to use for drawing
+ *
+ * Create a new instance of the map plugin.
+ *
+ * Returns: the new #GisPluginMap
+ */
GisPluginMap *gis_plugin_map_new(GisViewer *viewer)
{
g_debug("GisPluginMap: new");
map->viewer = g_object_ref(viewer);
/* Load initial tiles */
- _load_tile(map->tiles, map);
- g_thread_create(_update_tiles, map, FALSE, NULL);
+ g_thread_create((GThreadFunc)_threaded_init, map, FALSE, NULL);
/* Connect signals */
map->sigid = g_signal_connect(map->viewer, "location-changed",
G_CALLBACK(_on_location_changed), map);
/* Add renderers */
- gis_viewer_add(viewer, GIS_OBJECT(map->tiles), GIS_LEVEL_OVERLAY, 0);
+ gis_viewer_add(viewer, GIS_OBJECT(map->tiles), GIS_LEVEL_OVERLAY-1, 0);
return map;
}