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
566 /* svn_cmdline_init configures the locale. Setup environment to ensure the
567 * default "C" locale remains active, since fgfs isn't locale aware - especially
568 * requires "." as decimal point in strings containing floating point varibales. */
569 setenv("LC_ALL", "C", 1);
572 // there is a segfault when providing an error stream.
573 // Apparently, calling setvbuf with a nul buffer is
574 // not supported under msvc 7.1 ( code inside svn_cmdline_init )
575 if (svn_cmdline_init("terrasync", 0) != EXIT_SUCCESS)
578 if (svn_cmdline_init("terrasync", stderr) != EXIT_SUCCESS)
583 apr_pool_create(&pool, NULL);
584 svn_error_t *err = NULL;
585 SVN_VERSION_DEFINE(_svn_version);
586 err = svn_ver_check_list(&_svn_version, mysvn_checklist);
588 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
589 err = svn_ra_initialize(pool);
591 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
592 char *config_dir = NULL;
593 err = svn_config_ensure(config_dir, pool);
595 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
596 err = svn_client_create_context(&_svn_ctx, pool);
598 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
599 err = svn_config_get_config(&(_svn_ctx->config),
602 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
604 cfg = ( svn_config_t*) apr_hash_get(
606 SVN_CONFIG_CATEGORY_CONFIG,
607 APR_HASH_KEY_STRING);
609 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
611 svn_auth_baton_t *ab=NULL;
613 #if (SVN_VER_MINOR >= 6)
614 err = svn_cmdline_create_auth_baton (&ab,
615 TRUE, NULL, NULL, config_dir, TRUE, FALSE, cfg,
616 _svn_ctx->cancel_func, _svn_ctx->cancel_baton, pool);
618 err = svn_cmdline_setup_auth_baton(&ab,
619 TRUE, NULL, NULL, config_dir, TRUE, cfg,
620 _svn_ctx->cancel_func, _svn_ctx->cancel_baton, pool);
624 return svn_cmdline_handle_exit_error(err, pool, "fgfs: ");
626 _svn_ctx->auth_baton = ab;
627 #if (SVN_VER_MINOR >= 5)
628 _svn_ctx->conflict_func = NULL;
629 _svn_ctx->conflict_baton = NULL;
632 // Now our magic revisions
633 _svn_rev = (svn_opt_revision_t*) apr_palloc(pool,
634 sizeof(svn_opt_revision_t));
637 _svn_rev_peg = (svn_opt_revision_t*) apr_palloc(pool,
638 sizeof(svn_opt_revision_t));
641 _svn_rev->kind = svn_opt_revision_head;
642 _svn_rev_peg->kind = svn_opt_revision_unspecified;
643 // Success if we got this far
649 ///////////////////////////////////////////////////////////////////////////////
650 // SGTerraSync ////////////////////////////////////////////////////////////////
651 ///////////////////////////////////////////////////////////////////////////////
652 SGTerraSync::SGTerraSync(SGPropertyNode_ptr root) :
656 _terraRoot(root->getNode("/sim/terrasync",true)),
659 _svnThread = new SvnThread();
662 SGTerraSync::~SGTerraSync()
664 _tiedProperties.Untie();
669 void SGTerraSync::init()
671 _refresh_display = _terraRoot->getNode("refresh-display",true);
672 _terraRoot->getNode("built-in-svn-available",true)->setBoolValue(svn_built_in_available);
676 void SGTerraSync::reinit()
678 // do not reinit when enabled and we're already up and running
679 if ((_terraRoot->getBoolValue("enabled",false))&&
680 (_svnThread->_active && _svnThread->_running))
685 if (_terraRoot->getBoolValue("enabled",false))
687 _svnThread->setSvnServer(_terraRoot->getStringValue("svn-server",""));
688 _svnThread->setRsyncServer(_terraRoot->getStringValue("rsync-server",""));
689 _svnThread->setLocalDir(_terraRoot->getStringValue("scenery-dir",""));
691 #ifdef HAVE_SVN_CLIENT_H
692 _svnThread->setUseBuiltin(_terraRoot->getBoolValue("use-built-in-svn",true));
694 _terraRoot->getNode("use-built-in-svn",true)->setBoolValue(false);
696 _svnThread->setUseSvn(_terraRoot->getBoolValue("use-svn",true));
697 _svnThread->setExtSvnUtility(_terraRoot->getStringValue("ext-svn-utility","svn"));
699 if (_svnThread->start())
700 syncAirportsModels();
703 _stalled_node->setBoolValue(_svnThread->_stalled);
708 void SGTerraSync::bind()
710 _tiedProperties.Tie( _terraRoot->getNode("busy", true), (bool*) &_svnThread->_busy );
711 _tiedProperties.Tie( _terraRoot->getNode("active", true), (bool*) &_svnThread->_active );
712 _tiedProperties.Tie( _terraRoot->getNode("update-count", true), (int*) &_svnThread->_success_count );
713 _tiedProperties.Tie( _terraRoot->getNode("error-count", true), (int*) &_svnThread->_fail_count );
714 _tiedProperties.Tie( _terraRoot->getNode("tile-count", true), (int*) &_svnThread->_updated_tile_count );
715 _terraRoot->getNode("busy", true)->setAttribute(SGPropertyNode::WRITE,false);
716 _terraRoot->getNode("active", true)->setAttribute(SGPropertyNode::WRITE,false);
717 _terraRoot->getNode("update-count", true)->setAttribute(SGPropertyNode::WRITE,false);
718 _terraRoot->getNode("error-count", true)->setAttribute(SGPropertyNode::WRITE,false);
719 _terraRoot->getNode("tile-count", true)->setAttribute(SGPropertyNode::WRITE,false);
720 _terraRoot->getNode("use-built-in-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
721 _terraRoot->getNode("use-svn", true)->setAttribute(SGPropertyNode::USERARCHIVE,false);
722 // stalled is used as a signal handler (to connect listeners triggering GUI pop-ups)
723 _stalled_node = _terraRoot->getNode("stalled", true);
724 _stalled_node->setBoolValue(_svnThread->_stalled);
725 _stalled_node->setAttribute(SGPropertyNode::PRESERVE,true);
728 void SGTerraSync::unbind()
731 _tiedProperties.Untie();
734 void SGTerraSync::update(double)
736 static SGBucket bucket;
737 if (_svnThread->isDirty())
739 if (!_svnThread->_active)
741 if (_svnThread->_stalled)
743 SG_LOG(SG_TERRAIN,SG_ALERT,
744 "Automatic scenery download/synchronization stalled. Too many errors.");
748 // not really an alert - just always show this message
749 SG_LOG(SG_TERRAIN,SG_ALERT,
750 "Automatic scenery download/synchronization has stopped.");
752 _stalled_node->setBoolValue(_svnThread->_stalled);
755 if (!_refresh_display->getBoolValue())
758 while (_svnThread->hasNewTiles())
760 WaitingTile next = _svnThread->getNewTile();
761 if (next._refreshScenery)
763 refreshScenery(_svnThread->getLocalDir(),next._dir);
769 void SGTerraSync::refreshScenery(SGPath path,const string& relativeDir)
771 // find tiles to be refreshed
774 path.append(relativeDir);
777 simgear::Dir dir(path);
778 //TODO need to be smarter here. only update tiles which actually
779 // changed recently. May also be possible to use information from the
780 // built-in SVN client directly (instead of checking directory contents).
781 PathList tileList = dir.children(simgear::Dir::TYPE_FILE, ".stg");
782 for (unsigned int i=0; i<tileList.size(); ++i)
784 // reload scenery tile
785 long index = atoi(tileList[i].file().c_str());
786 _tile_cache->refresh_tile(index);
792 bool SGTerraSync::isIdle() {return _svnThread->isIdle();}
794 void SGTerraSync::setTileCache(TileCache* tile_cache)
796 _tile_cache = tile_cache;
799 void SGTerraSync::syncAirportsModels()
801 static const char bounds[] = "KZAJ";
802 for( unsigned i = 0; i < sizeof(bounds)/sizeof(bounds[0])/2; i+= 2 )
804 for ( char synced_other = bounds[i]; synced_other <= bounds[i+1]; synced_other++ )
807 dir << "Airports/" << synced_other;
808 WaitingTile w(dir.str(),false);
809 _svnThread->request( w );
812 WaitingTile w("Models",false);
813 _svnThread->request( w );
817 void SGTerraSync::syncArea( int lat, int lon )
819 if ( lat < -90 || lat > 90 || lon < -180 || lon > 180 )
822 int baselat, baselon;
825 int base = (int)(lat / 10);
826 if ( lat == base * 10 ) {
829 baselat = (base - 1) * 10;
833 baselat = (int)(lat / 10) * 10;
837 int base = (int)(lon / 10);
838 if ( lon == base * 10 ) {
841 baselon = (base - 1) * 10;
845 baselon = (int)(lon / 10) * 10;
849 const char* terrainobjects[3] = { "Terrain", "Objects", 0 };
851 for (const char** tree = &terrainobjects[0]; *tree; tree++)
854 dir << *tree << "/" << setfill('0')
855 << EW << setw(3) << abs(baselon) << NS << setw(2) << abs(baselat) << "/"
856 << EW << setw(3) << abs(lon) << NS << setw(2) << abs(lat);
857 WaitingTile w(dir.str(),refresh);
858 _svnThread->request( w );
864 void SGTerraSync::syncAreas( int lat, int lon, int lat_dir, int lon_dir )
866 if ( lat_dir == 0 && lon_dir == 0 ) {
867 // do surrounding 8 1x1 degree areas.
868 for ( int i = lat - 1; i <= lat + 1; ++i ) {
869 for ( int j = lon - 1; j <= lon + 1; ++j ) {
870 if ( i != lat || j != lon ) {
876 if ( lat_dir != 0 ) {
877 syncArea( lat + lat_dir, lon - 1 );
878 syncArea( lat + lat_dir, lon + 1 );
879 syncArea( lat + lat_dir, lon );
881 if ( lon_dir != 0 ) {
882 syncArea( lat - 1, lon + lon_dir );
883 syncArea( lat + 1, lon + lon_dir );
884 syncArea( lat, lon + lon_dir );
888 // do current 1x1 degree area first
889 syncArea( lat, lon );
893 bool SGTerraSync::schedulePosition(int lat, int lon)
895 // Ignore messages where the location does not change
896 if ( lat != last_lat || lon != last_lon )
898 SG_LOG(SG_TERRAIN,SG_DEBUG, "Requesting scenery update for position " <<
900 int lat_dir, lon_dir, dist;
901 if ( last_lat == NOWHERE || last_lon == NOWHERE )
903 lat_dir = lon_dir = 0;
906 dist = lat - last_lat;
909 lat_dir = dist / abs(dist);
915 dist = lon - last_lon;
918 lon_dir = dist / abs(dist);
925 SG_LOG(SG_TERRAIN,SG_DEBUG, "Scenery update for " <<
926 "lat = " << lat << ", lon = " << lon <<
927 ", lat_dir = " << lat_dir << ", " <<
928 "lon_dir = " << lon_dir);
930 syncAreas( lat, lon, lat_dir, lon_dir );