command = buf.str();
#endif
SG_LOG(SG_TERRAIN,SG_DEBUG, "sync command '" << command << "'");
+
+#ifdef SG_WINDOWS
+ // tbd: does Windows support "popen"?
int rc = system( command.c_str() );
+#else
+ FILE* pipe = popen( command.c_str(), "r");
+ int rc=-1;
+ // wait for external process to finish
+ if (pipe)
+ rc = pclose(pipe);
+#endif
+
if (rc)
{
SG_LOG(SG_TERRAIN,SG_ALERT,
_svnThread->setExtSvnUtility(_terraRoot->getStringValue("ext-svn-utility","svn"));
if (_svnThread->start())
+ {
syncAirportsModels();
+ if (last_lat != NOWHERE && last_lon != NOWHERE)
+ {
+ // reschedule most recent position
+ int lat = last_lat;
+ int lon = last_lon;
+ last_lat = NOWHERE;
+ last_lon = NOWHERE;
+ schedulePosition(lat, lon);
+ }
+ }
}
_stalled_node->setBoolValue(_svnThread->_stalled);
- last_lat = NOWHERE;
- last_lon = NOWHERE;
}
void SGTerraSync::bind()
bool SGTerraSync::schedulePosition(int lat, int lon)
{
+ bool Ok = false;
+
// Ignore messages where the location does not change
if ( lat != last_lat || lon != last_lon )
{
- SG_LOG(SG_TERRAIN,SG_DEBUG, "Requesting scenery update for position " <<
- lat << "," << lon);
- int lat_dir, lon_dir, dist;
- if ( last_lat == NOWHERE || last_lon == NOWHERE )
- {
- lat_dir = lon_dir = 0;
- } else
+ if (_svnThread->_running)
{
- dist = lat - last_lat;
- if ( dist != 0 )
- {
- lat_dir = dist / abs(dist);
- }
- else
+ SG_LOG(SG_TERRAIN,SG_DEBUG, "Requesting scenery update for position " <<
+ lat << "," << lon);
+ int lat_dir=0;
+ int lon_dir=0;
+ if ( last_lat != NOWHERE && last_lon != NOWHERE )
{
- lat_dir = 0;
- }
- dist = lon - last_lon;
- if ( dist != 0 )
- {
- lon_dir = dist / abs(dist);
- } else
- {
- lon_dir = 0;
+ int dist = lat - last_lat;
+ if ( dist != 0 )
+ {
+ lat_dir = dist / abs(dist);
+ }
+ else
+ {
+ lat_dir = 0;
+ }
+ dist = lon - last_lon;
+ if ( dist != 0 )
+ {
+ lon_dir = dist / abs(dist);
+ } else
+ {
+ lon_dir = 0;
+ }
}
- }
- SG_LOG(SG_TERRAIN,SG_DEBUG, "Scenery update for " <<
- "lat = " << lat << ", lon = " << lon <<
- ", lat_dir = " << lat_dir << ", " <<
- "lon_dir = " << lon_dir);
-
- syncAreas( lat, lon, lat_dir, lon_dir );
+ SG_LOG(SG_TERRAIN,SG_DEBUG, "Scenery update for " <<
+ "lat = " << lat << ", lon = " << lon <<
+ ", lat_dir = " << lat_dir << ", " <<
+ "lon_dir = " << lon_dir);
+ syncAreas( lat, lon, lat_dir, lon_dir );
+ Ok = true;
+ }
last_lat = lat;
last_lon = lon;
- return true;
}
- return false;
+
+ return Ok;
}