1 // terrasync.cxx -- scenery fetcher
3 // Started by Curtis Olson, November 2002.
5 // Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
6 // Copyright (C) 2008 Alexander R. Perry <alex.perry@ieee.org>
7 // Copyright (C) 2011 Thorsten Brehm <brehmt@gmail.com>
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License as
11 // published by the Free Software Foundation; either version 2 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 # include <simgear_config.h>
29 #include <simgear/compiler.h>
38 #elif defined(_MSC_VER)
40 # ifndef HAVE_SVN_CLIENT_H
46 #include <stdlib.h> // atoi() atof() abs() system()
47 #include <signal.h> // signal()
54 #include <simgear/compiler.h>
56 #include "terrasync.hxx"
57 #include <simgear/bucket/newbucket.hxx>
58 #include <simgear/misc/sg_path.hxx>
59 #include <simgear/misc/strutils.hxx>
60 #include <simgear/threads/SGQueue.hxx>
61 #include <simgear/scene/tgdb/TileCache.hxx>
62 #include <simgear/misc/sg_dir.hxx>
63 #include <OpenThreads/Thread>
65 #ifdef HAVE_SVN_CLIENT_H
66 # ifdef HAVE_LIBSVN_CLIENT_1
67 # include <svn_version.h>
68 # include <svn_auth.h>
69 # include <svn_client.h>
70 # include <svn_cmdline.h>
71 # include <svn_pools.h>
73 # undef HAVE_SVN_CLIENT_H
77 #ifdef HAVE_SVN_CLIENT_H
78 static const svn_version_checklist_t mysvn_checklist[] = {
79 { "svn_subr", svn_subr_version },
80 { "svn_client", svn_client_version },
83 static const bool svn_built_in_available = true;
85 static const bool svn_built_in_available = false;
88 using namespace simgear;
90 const char* rsync_cmd =
91 "rsync --verbose --archive --delete --perms --owner --group";
93 const char* svn_options =
96 namespace UpdateInterval
98 // interval in seconds to allow an update to repeat after a successful update (=daily)
99 static const double SuccessfulAttempt = 24*60*60;
100 // interval in seconds to allow another update after a failed attempt (10 minutes)
101 static const double FailedAttempt = 10*60;
104 typedef map<string,time_t> CompletedTiles;
106 ///////////////////////////////////////////////////////////////////////////////
107 // helper functions ///////////////////////////////////////////////////////////
108 ///////////////////////////////////////////////////////////////////////////////
109 string stripPath(string path)
111 // svn doesn't like trailing white-spaces or path separators - strip them!
112 path = simgear::strutils::strip(path);
113 int slen = path.length();
115 ((path[slen-1]=='/')||(path[slen-1]=='\\')))
119 return path.substr(0,slen);
122 bool hasWhitespace(string path)
124 return path.find(' ')!=string::npos;
127 ///////////////////////////////////////////////////////////////////////////////
128 // WaitingTile ////////////////////////////////////////////////////////////////
129 ///////////////////////////////////////////////////////////////////////////////
133 WaitingTile(string dir,bool refresh) :
134 _dir(dir), _refreshScenery(refresh) {}
136 bool _refreshScenery;
139 ///////////////////////////////////////////////////////////////////////////////
140 // SGTerraSync::SvnThread /////////////////////////////////////////////////////
141 ///////////////////////////////////////////////////////////////////////////////
142 class SGTerraSync::SvnThread : public OpenThreads::Thread
146 virtual ~SvnThread( ) { stop(); }
151 bool isIdle() {return waitingTiles.empty();}
152 void request(const WaitingTile& dir) {waitingTiles.push_front(dir);}
153 bool isDirty() { bool r = _is_dirty;_is_dirty = false;return r;}
154 bool hasNewTiles() { return !_freshTiles.empty();}
155 WaitingTile getNewTile() { return _freshTiles.pop_front();}
157 void setSvnServer(string server) { _svn_server = stripPath(server);}
158 void setExtSvnUtility(string svn_util) { _svn_command = simgear::strutils::strip(svn_util);}
159 void setRsyncServer(string server) { _rsync_server = simgear::strutils::strip(server);}
160 void setLocalDir(string dir) { _local_dir = stripPath(dir);}
161 string getLocalDir() { return _local_dir;}
162 void setUseSvn(bool use_svn) { _use_svn = use_svn;}
164 #ifdef HAVE_SVN_CLIENT_H
165 void setUseBuiltin(bool built_in) { _use_built_in = built_in;}
168 volatile bool _active;
169 volatile bool _running;
171 volatile bool _stalled;
172 volatile int _fail_count;
173 volatile int _updated_tile_count;
174 volatile int _success_count;
175 volatile int _consecutive_errors;
179 bool syncTree(const char* dir, bool& isNewDirectory);
180 bool syncTreeExternal(const char* dir);
182 #ifdef HAVE_SVN_CLIENT_H
183 static int svnClientSetup(void);
184 bool syncTreeInternal(const char* dir);
188 // Things we need for doing subversion checkout - often
189 static apr_pool_t *_svn_pool;
190 static svn_client_ctx_t *_svn_ctx;
191 static svn_opt_revision_t *_svn_rev;
192 static svn_opt_revision_t *_svn_rev_peg;
195 volatile bool _is_dirty;
197 SGBlockingDeque <WaitingTile> waitingTiles;
198 CompletedTiles _completedTiles;
199 SGBlockingDeque <WaitingTile> _freshTiles;
203 string _rsync_server;
207 #ifdef HAVE_SVN_CLIENT_H
208 apr_pool_t* SGTerraSync::SvnThread::_svn_pool = NULL;
209 svn_client_ctx_t* SGTerraSync::SvnThread::_svn_ctx = NULL;
210 svn_opt_revision_t* SGTerraSync::SvnThread::_svn_rev = NULL;
211 svn_opt_revision_t* SGTerraSync::SvnThread::_svn_rev_peg = NULL;
214 SGTerraSync::SvnThread::SvnThread() :
220 _updated_tile_count(0),
222 _consecutive_errors(0),
223 #ifdef HAVE_SVN_CLIENT_H
230 #ifdef HAVE_SVN_CLIENT_H
231 int errCode = SGTerraSync::SvnThread::svnClientSetup();
232 if (errCode != EXIT_SUCCESS)
234 SG_LOG(SG_TERRAIN,SG_ALERT,
235 "Failed to initialize built-in SVN client, error = " << errCode);
240 void SGTerraSync::SvnThread::stop()
242 // drop any pending requests
243 waitingTiles.clear();
248 // set stop flag and wake up the thread with an empty request
250 WaitingTile w("",false);
256 bool SGTerraSync::SvnThread::start()
263 SG_LOG(SG_TERRAIN,SG_ALERT,
264 "Cannot start scenery download. Local cache directory is undefined.");
270 SGPath path(_local_dir);
273 SG_LOG(SG_TERRAIN,SG_ALERT,
274 "Cannot start scenery download. Directory '" << _local_dir <<
275 "' does not exist. Set correct directory path or create directory folder.");
281 path.append("version");
284 SG_LOG(SG_TERRAIN,SG_ALERT,
285 "Cannot start scenery download. Directory '" << _local_dir <<
286 "' contains the base package. Use a separate directory.");
292 #ifdef HAVE_SVN_CLIENT_H
293 _use_svn |= _use_built_in;
296 if ((_use_svn)&&(_svn_server==""))
298 SG_LOG(SG_TERRAIN,SG_ALERT,
299 "Cannot start scenery download. Subversion scenery server is undefined.");
304 if ((!_use_svn)&&(_rsync_server==""))
306 SG_LOG(SG_TERRAIN,SG_ALERT,
307 "Cannot start scenery download. Rsync scenery server is undefined.");
314 _updated_tile_count = 0;
316 _consecutive_errors = 0;
322 #ifdef HAVE_SVN_CLIENT_H
323 if (_use_svn && _use_built_in)
324 status = "Using built-in SVN support. ";
329 status = "Using external SVN utility '";
330 status += _svn_command;
335 status = "Using RSYNC. ";
338 // not really an alert - but we want to (always) see this message, so user is
339 // aware we're downloading scenery (and using bandwidth).
340 SG_LOG(SG_TERRAIN,SG_ALERT,
341 "Starting automatic scenery download/synchronization. "
343 << "Directory: '" << _local_dir << "'.");
345 OpenThreads::Thread::start();
349 // sync one directory tree
350 bool SGTerraSync::SvnThread::syncTree(const char* dir, bool& isNewDirectory)
353 SGPath path( _local_dir );
356 isNewDirectory = !path.exists();
359 rc = path.create_dir( 0755 );
362 SG_LOG(SG_TERRAIN,SG_ALERT,
363 "Cannot create directory '" << dir << "', return code = " << rc );
368 #ifdef HAVE_SVN_CLIENT_H
370 return syncTreeInternal(dir);
374 return syncTreeExternal(dir);
379 #ifdef HAVE_SVN_CLIENT_H
380 bool SGTerraSync::SvnThread::syncTreeInternal(const char* dir)
382 SG_LOG(SG_TERRAIN,SG_DEBUG, "Synchronizing scenery directory " << dir);
385 SG_LOG(SG_TERRAIN,SG_ALERT,
386 "Built-in SVN client failed to initialize.");
390 ostringstream command;
391 command << _svn_server << "/" << dir;
393 ostringstream dest_base_dir;
394 dest_base_dir << _local_dir << "/" << dir;
396 apr_pool_t *subpool = svn_pool_create(_svn_pool);
398 svn_error_t *err = NULL;
399 #if (SVN_VER_MINOR >= 5)
400 err = svn_client_checkout3(NULL,
401 command.str().c_str(),
402 dest_base_dir.str().c_str(),
406 0, // ignore-externals = false
407 0, // allow unver obstructions = false
412 err = svn_client_checkout2(NULL,
413 command.str().c_str(),
414 dest_base_dir.str().c_str(),
417 1, // recurse=true - same as svn_depth_infinity for checkout3 above
418 0, // ignore externals = false
423 bool ReturnValue = true;
426 // Report errors from the checkout attempt
427 if (err->apr_err == SVN_ERR_RA_ILLEGAL_URL)
429 // ignore errors when remote path doesn't exist (no scenery data for ocean areas)
433 SG_LOG(SG_TERRAIN,SG_ALERT,
434 "Failed to synchronize directory '" << dir << "', " <<
435 err->message << " (code " << err->apr_err << ").");
436 svn_error_clear(err);
438 err = svn_client_cleanup(dest_base_dir.str().c_str(),
442 SG_LOG(SG_TERRAIN,SG_ALERT,
443 "SVN repository cleanup successful for '" << dir << "'.");
449 SG_LOG(SG_TERRAIN,SG_DEBUG, "Done with scenery directory " << dir);
451 svn_pool_destroy(subpool);
456 bool SGTerraSync::SvnThread::syncTreeExternal(const char* dir)
459 SGPath localPath( _local_dir );
460 localPath.append( dir );
464 buf << "\"" << _svn_command << "\" "
465 << svn_options << " "
466 << "\"" << _svn_server << "/" << dir << "\" "
467 << "\"" << localPath.str_native() << "\"";
469 buf << rsync_cmd << " "
470 << "\"" << _rsync_server << "/" << dir << "/\" "
471 << "\"" << localPath.str_native() << "/\"";
476 // windows command line parsing is just lovely...
477 // to allow white spaces, the system call needs this:
478 // ""C:\Program Files\something.exe" somearg "some other arg""
479 // Note: whitespace strings quoted by a pair of "" _and_ the
480 // entire string needs to be wrapped by "" too.
481 // The svn url needs forward slashes (/) as a path separator while
482 // the local path needs windows-native backslash as a path separator.
483 command = "\"" + buf.str() + "\"";
487 SG_LOG(SG_TERRAIN,SG_DEBUG, "sync command '" << command << "'");
488 int rc = system( command.c_str() );
491 SG_LOG(SG_TERRAIN,SG_ALERT,
492 "Failed to synchronize directory '" << dir << "', " <<
493 "error code= " << rc);
499 void SGTerraSync::SvnThread::run()
504 WaitingTile next = waitingTiles.pop_front();
508 CompletedTiles::iterator ii =
509 _completedTiles.find( next._dir );
510 time_t now = time(0);
511 if ((ii == _completedTiles.end())||
514 bool isNewDirectory = false;
517 if (!syncTree(next._dir.c_str(),isNewDirectory))
519 _consecutive_errors++;
521 _completedTiles[ next._dir ] = now + UpdateInterval::FailedAttempt;
525 _consecutive_errors = 0;
527 SG_LOG(SG_TERRAIN,SG_INFO,
528 "Successfully synchronized directory '" << next._dir << "'");
529 if (next._refreshScenery)
532 _updated_tile_count++;
535 // for now only report new directories to refresh display
536 // (i.e. only when ocean needs to be replaced with actual data)
537 _freshTiles.push_back(next);
541 _completedTiles[ next._dir ] = now + UpdateInterval::SuccessfulAttempt;
546 if (_consecutive_errors >= 5)
558 #ifdef HAVE_SVN_CLIENT_H
559 // Configure our subversion session
560 int SGTerraSync::SvnThread::svnClientSetup(void)
562 // Are we already prepared?
563 if (_svn_pool) return EXIT_SUCCESS;
564 // No, so initialize svn internals generally
567 // there is a segfault when providing an error stream.
568 // Apparently, calling setvbuf with a nul buffer is
569 // not supported under msvc 7.1 ( code inside svn_cmdline_init )
570 if (svn_cmdline_init("terrasync", 0) != EXIT_SUCCESS)
573 // revert locale setting
574 setlocale(LC_ALL,"C");
576 /* svn_cmdline_init configures the locale. Setup environment to ensure the
577 * default "C" locale remains active, since fgfs isn't locale aware - especially
578 * requires "." as decimal point in strings containing floating point varibales. */
579 setenv("LC_ALL", "C", 1);
581 if (svn_cmdline_init("terrasync", stderr) != EXIT_SUCCESS)
586 apr_pool_create(&pool, NULL);
587 svn_error_t *err = NULL;
588 SVN_VERSION_DEFINE(_svn_version);
589 err = svn_ver_check_list(&_svn_version, mysvn_checklist);
591 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
592 err = svn_ra_initialize(pool);
594 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
595 char *config_dir = NULL;
596 err = svn_config_ensure(config_dir, pool);
598 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
599 err = svn_client_create_context(&_svn_ctx, pool);
601 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
602 err = svn_config_get_config(&(_svn_ctx->config),
605 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
607 cfg = ( svn_config_t*) apr_hash_get(
609 SVN_CONFIG_CATEGORY_CONFIG,
610 APR_HASH_KEY_STRING);
612 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
614 svn_auth_baton_t *ab=NULL;
616 #if (SVN_VER_MINOR >= 6)
617 err = svn_cmdline_create_auth_baton (&ab,
618 TRUE, NULL, NULL, config_dir, TRUE, FALSE, cfg,
619 _svn_ctx->cancel_func, _svn_ctx->cancel_baton, pool);
621 err = svn_cmdline_setup_auth_baton(&ab,
622 TRUE, NULL, NULL, config_dir, TRUE, cfg,
623 _svn_ctx->cancel_func, _svn_ctx->cancel_baton, pool);
627 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
629 _svn_ctx->auth_baton = ab;
630 #if (SVN_VER_MINOR >= 5)
631 _svn_ctx->conflict_func = NULL;
632 _svn_ctx->conflict_baton = NULL;
635 // Now our magic revisions
636 _svn_rev = (svn_opt_revision_t*) apr_palloc(pool,
637 sizeof(svn_opt_revision_t));
640 _svn_rev_peg = (svn_opt_revision_t*) apr_palloc(pool,
641 sizeof(svn_opt_revision_t));
644 _svn_rev->kind = svn_opt_revision_head;
645 _svn_rev_peg->kind = svn_opt_revision_unspecified;
646 // Success if we got this far
652 ///////////////////////////////////////////////////////////////////////////////
653 // SGTerraSync ////////////////////////////////////////////////////////////////
654 ///////////////////////////////////////////////////////////////////////////////
655 SGTerraSync::SGTerraSync(SGPropertyNode_ptr root) :
659 _terraRoot(root->getNode("/sim/terrasync",true)),
662 _svnThread = new SvnThread();
665 SGTerraSync::~SGTerraSync()
667 _tiedProperties.Untie();
672 void SGTerraSync::init()
674 _refresh_display = _terraRoot->getNode("refresh-display",true);
675 _terraRoot->getNode("built-in-svn-available",true)->setBoolValue(svn_built_in_available);
679 void SGTerraSync::reinit()
681 // do not reinit when enabled and we're already up and running
682 if ((_terraRoot->getBoolValue("enabled",false))&&
683 (_svnThread->_active && _svnThread->_running))
688 if (_terraRoot->getBoolValue("enabled",false))
690 _svnThread->setSvnServer(_terraRoot->getStringValue("svn-server",""));
691 _svnThread->setRsyncServer(_terraRoot->getStringValue("rsync-server",""));
692 _svnThread->setLocalDir(_terraRoot->getStringValue("scenery-dir",""));
694 #ifdef HAVE_SVN_CLIENT_H
695 _svnThread->setUseBuiltin(_terraRoot->getBoolValue("use-built-in-svn",true));
697 _terraRoot->getNode("use-built-in-svn",true)->setBoolValue(false);
699 _svnThread->setUseSvn(_terraRoot->getBoolValue("use-svn",true));
700 _svnThread->setExtSvnUtility(_terraRoot->getStringValue("ext-svn-utility","svn"));
702 if (_svnThread->start())
703 syncAirportsModels();
706 _stalled_node->setBoolValue(_svnThread->_stalled);
711 void SGTerraSync::bind()
713 _tiedProperties.Tie( _terraRoot->getNode("busy", true), (bool*) &_svnThread->_busy );
714 _tiedProperties.Tie( _terraRoot->getNode("active", true), (bool*) &_svnThread->_active );
715 _tiedProperties.Tie( _terraRoot->getNode("update-count", true), (int*) &_svnThread->_success_count );
716 _tiedProperties.Tie( _terraRoot->getNode("error-count", true), (int*) &_svnThread->_fail_count );
717 _tiedProperties.Tie( _terraRoot->getNode("tile-count", true), (int*) &_svnThread->_updated_tile_count );
718 _terraRoot->getNode("busy", true)->setAttribute(SGPropertyNode::WRITE,false);
719 _terraRoot->getNode("active", true)->setAttribute(SGPropertyNode::WRITE,false);
720 _terraRoot->getNode("update-count", true)->setAttribute(SGPropertyNode::WRITE,false);
721 _terraRoot->getNode("error-count", true)->setAttribute(SGPropertyNode::WRITE,false);
722 _terraRoot->getNode("tile-count", true)->setAttribute(SGPropertyNode::WRITE,false);
723 _terraRoot->getNode("use-built-in-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
724 _terraRoot->getNode("use-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
725 // stalled is used as a signal handler (to connect listeners triggering GUI pop-ups)
726 _stalled_node = _terraRoot->getNode("stalled", true);
727 _stalled_node->setBoolValue(_svnThread->_stalled);
728 _stalled_node->setAttribute(SGPropertyNode::PRESERVE,true);
731 void SGTerraSync::unbind()
734 _tiedProperties.Untie();
737 void SGTerraSync::update(double)
739 static SGBucket bucket;
740 if (_svnThread->isDirty())
742 if (!_svnThread->_active)
744 if (_svnThread->_stalled)
746 SG_LOG(SG_TERRAIN,SG_ALERT,
747 "Automatic scenery download/synchronization stalled. Too many errors.");
751 // not really an alert - just always show this message
752 SG_LOG(SG_TERRAIN,SG_ALERT,
753 "Automatic scenery download/synchronization has stopped.");
755 _stalled_node->setBoolValue(_svnThread->_stalled);
758 if (!_refresh_display->getBoolValue())
761 while (_svnThread->hasNewTiles())
763 WaitingTile next = _svnThread->getNewTile();
764 if (next._refreshScenery)
766 refreshScenery(_svnThread->getLocalDir(),next._dir);
772 void SGTerraSync::refreshScenery(SGPath path,const string& relativeDir)
774 // find tiles to be refreshed
777 path.append(relativeDir);
780 simgear::Dir dir(path);
781 //TODO need to be smarter here. only update tiles which actually
782 // changed recently. May also be possible to use information from the
783 // built-in SVN client directly (instead of checking directory contents).
784 PathList tileList = dir.children(simgear::Dir::TYPE_FILE, ".stg");
785 for (unsigned int i=0; i<tileList.size(); ++i)
787 // reload scenery tile
788 long index = atoi(tileList[i].file().c_str());
789 _tile_cache->refresh_tile(index);
795 bool SGTerraSync::isIdle() {return _svnThread->isIdle();}
797 void SGTerraSync::setTileCache(TileCache* tile_cache)
799 _tile_cache = tile_cache;
802 void SGTerraSync::syncAirportsModels()
804 static const char bounds[] = "KZAJ";
805 for( unsigned i = 0; i < sizeof(bounds)/sizeof(bounds[0])/2; i+= 2 )
807 for ( char synced_other = bounds[i]; synced_other <= bounds[i+1]; synced_other++ )
810 dir << "Airports/" << synced_other;
811 WaitingTile w(dir.str(),false);
812 _svnThread->request( w );
815 WaitingTile w("Models",false);
816 _svnThread->request( w );
820 void SGTerraSync::syncArea( int lat, int lon )
822 if ( lat < -90 || lat > 90 || lon < -180 || lon > 180 )
825 int baselat, baselon;
828 int base = (int)(lat / 10);
829 if ( lat == base * 10 ) {
832 baselat = (base - 1) * 10;
836 baselat = (int)(lat / 10) * 10;
840 int base = (int)(lon / 10);
841 if ( lon == base * 10 ) {
844 baselon = (base - 1) * 10;
848 baselon = (int)(lon / 10) * 10;
852 const char* terrainobjects[3] = { "Terrain", "Objects", 0 };
854 for (const char** tree = &terrainobjects[0]; *tree; tree++)
857 dir << *tree << "/" << setfill('0')
858 << EW << setw(3) << abs(baselon) << NS << setw(2) << abs(baselat) << "/"
859 << EW << setw(3) << abs(lon) << NS << setw(2) << abs(lat);
860 WaitingTile w(dir.str(),refresh);
861 _svnThread->request( w );
867 void SGTerraSync::syncAreas( int lat, int lon, int lat_dir, int lon_dir )
869 if ( lat_dir == 0 && lon_dir == 0 ) {
870 // do surrounding 8 1x1 degree areas.
871 for ( int i = lat - 1; i <= lat + 1; ++i ) {
872 for ( int j = lon - 1; j <= lon + 1; ++j ) {
873 if ( i != lat || j != lon ) {
879 if ( lat_dir != 0 ) {
880 syncArea( lat + lat_dir, lon - 1 );
881 syncArea( lat + lat_dir, lon + 1 );
882 syncArea( lat + lat_dir, lon );
884 if ( lon_dir != 0 ) {
885 syncArea( lat - 1, lon + lon_dir );
886 syncArea( lat + 1, lon + lon_dir );
887 syncArea( lat, lon + lon_dir );
891 // do current 1x1 degree area first
892 syncArea( lat, lon );
896 bool SGTerraSync::schedulePosition(int lat, int lon)
898 // Ignore messages where the location does not change
899 if ( lat != last_lat || lon != last_lon )
901 SG_LOG(SG_TERRAIN,SG_DEBUG, "Requesting scenery update for position " <<
903 int lat_dir, lon_dir, dist;
904 if ( last_lat == NOWHERE || last_lon == NOWHERE )
906 lat_dir = lon_dir = 0;
909 dist = lat - last_lat;
912 lat_dir = dist / abs(dist);
918 dist = lon - last_lon;
921 lon_dir = dist / abs(dist);
928 SG_LOG(SG_TERRAIN,SG_DEBUG, "Scenery update for " <<
929 "lat = " << lat << ", lon = " << lon <<
930 ", lat_dir = " << lat_dir << ", " <<
931 "lon_dir = " << lon_dir);
933 syncAreas( lat, lon, lat_dir, lon_dir );