Add horizon test
authorAndy Spencer <andy753421@gmail.com>
Fri, 12 Feb 2010 21:55:49 +0000 (21:55 +0000)
committerAndy Spencer <andy753421@gmail.com>
Fri, 12 Feb 2010 22:54:51 +0000 (22:54 +0000)
src/data/gis-http.c
src/gis-opengl.c

index 0765415f3e974d87c42d4879d63a663274cd7974..144168d3e9e3d556f8a48a231c4ee2aaad979509 100644 (file)
@@ -117,7 +117,7 @@ static void _chunk_cb(SoupMessage *message, SoupBuffer *chunk, gpointer _info)
 gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
                GisCacheType mode, GisChunkCallback callback, gpointer user_data)
 {
-       g_debug("GisHttp: fetch - %.20s... >> %s/%s  mode=%d",
+       g_debug("GisHttp: fetch - %s... >> %s/%s  mode=%d",
                        uri, http->prefix, local, mode);
 
        gchar *path = g_build_filename(g_get_user_cache_dir(), PACKAGE,
@@ -130,7 +130,7 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
        /* Do the cache if necessasairy */
        if (!(mode == GIS_ONCE && g_file_test(path, G_FILE_TEST_EXISTS)) &&
                        mode != GIS_LOCAL) {
-               g_debug("GisHttp: do_cache - Caching file %s", local);
+               g_debug("GisHttp: fetch - Caching file %s", local);
 
                /* Open the file for writting */
                gchar *part = path;
index 8f03e8df4cc9c95f568877dfc2c1d7d7ce7ad625..a70c6a8ebb3e251fda82c3a24ab2b711a514d5af 100644 (file)
@@ -233,6 +233,7 @@ static void _draw_marker(GisOpenGL *opengl, GisMarker *marker)
        gis_viewer_project(GIS_VIEWER(opengl),
                        point->lat, point->lon, point->elev,
                        &px, &py, &pz);
+
        gint win_width  = GTK_WIDGET(opengl)->allocation.width;
        gint win_height = GTK_WIDGET(opengl)->allocation.height;
        py = win_height - py;
@@ -275,14 +276,23 @@ static void _draw_object(GisOpenGL *opengl, GisObject *object)
        //g_debug("GisOpenGL: draw_object");
        /* Skip out of range objects */
        if (object->lod > 0) {
+               /* LOD test */
                gdouble eye[3], obj[3];
                gis_viewer_get_location(GIS_VIEWER(opengl), &eye[0], &eye[1], &eye[2]);
+               gdouble elev = eye[2];
                lle2xyz(eye[0], eye[1], eye[2], &eye[0], &eye[1], &eye[2]);
                lle2xyz(object->center.lat, object->center.lon, object->center.elev,
                        &obj[0], &obj[1], &obj[2]);
                gdouble dist = distd(obj, eye);
                if (object->lod < dist)
                        return;
+
+               /* Horizon testing */
+               gdouble c = EARTH_R+elev;
+               gdouble a = EARTH_R;
+               gdouble horizon = sqrt(c*c - a*a);
+               if (dist > horizon)
+                       return;
        }
 
        /* Draw */