--- /dev/null
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="terrasync"
+ ProjectGUID="{874D3F55-6048-4068-A7C2-7FA6AF1F30EA}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="Terrasync_Debug"
+ IntermediateDirectory="Terrasync_Debug"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="..\..\..\SimGear;..\..\..\install\msvc71\OpenSceneGraph\include;..\..\.."
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;NOMINMAX"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ RuntimeTypeInfo="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ul_d.lib sg_d.lib net_d.lib ws2_32.lib"
+ OutputFile="$(OutDir)/terrasync.exe"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\..\plib"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/terrasync.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="Terrasync_Release"
+ IntermediateDirectory="Terrasync_Release"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\..\SimGear;..\..\..\install\msvc71\OpenSceneGraph\include;..\..\.."
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NOMINMAX"
+ RuntimeLibrary="2"
+ RuntimeTypeInfo="TRUE"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ul.lib sg.lib net.lib ws2_32.lib"
+ OutputFile="$(OutDir)/terrasync.exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="..\..\..\plib"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\utils\TerraSync\terrasync.cxx">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
// Written by Curtis Olson, started November 2002.
//
// Copyright (C) 2002 Curtis L. Olson - http://www.flightgear.org/~curt
+// Copyright (C) 2008 Alexander R. Perry <alex.perry@ieee.org>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
#include <plib/ul.h>
#include <simgear/bucket/newbucket.hxx>
+#include <simgear/misc/sg_path.hxx>
using std::string;
using std::cout;
using std::endl;
-static string server = "scenery.flightgear.org";
-static string source_module = "Scenery";
-static string source_base = server + (string)"::" + source_module;
-static string dest_base = "/dest/scenery/dir";
+const char* svn_base =
+ "http://terrascenery.googlecode.com/svn/trunk/data/Scenery";
+const char* rsync_base = "scenery.flightgear.org::Scenery";
+const char* source_base = NULL;
+const char* dest_base = "terrasyncdir";
+bool use_svn = false;
+
+const char* svn_cmd = "svn checkout";
+const char* rsync_cmd =
+ "rsync --verbose --archive --delete --perms --owner --group";
// display usage
static void usage( const string& prog ) {
- cout << "Usage: " << prog
- << " -p <port> [ -s <rsync_source> ] -d <rsync_dest>" << endl;
+ cout << "Usage: " << endl
+ << prog << " -p <port> "
+ << "[ -R ] [ -s <rsync_source> ] -d <dest>" << endl
+ << prog << " -p <port> "
+ << " -S [ -s <svn_source> ] -d <dest>" << endl;
}
+const int nowhere = -9999;
+
// parse message
static void parse_message( const string &msg, int *lat, int *lon ) {
double dlat, dlon;
} else {
*lon = (int)dlon;
}
+
+ if ((dlon == 0) && (dlat == 0)) {
+ *lon = nowhere;
+ *lat = nowhere;
+ }
+
+}
+
+// sync one directory tree
+void sync_tree(char* dir) {
+ int rc;
+ char command[512];
+ SGPath path( dest_base );
+
+ path.append( dir );
+ rc = path.create_dir( 0755 );
+ if (rc) {
+ cout << "Return code = " << rc << endl;
+ exit(1);
+ }
+
+ if (use_svn) {
+ snprintf( command, 512,
+ "%s %s/%s %s/%s", svn_cmd,
+ source_base, dir,
+ dest_base, dir );
+ } else {
+ snprintf( command, 512,
+ "%s %s/%s/ %s/%s/", rsync_cmd,
+ source_base, dir,
+ dest_base, dir );
+ }
+ cout << command << endl;
+ rc = system( command );
+ if (rc) {
+ cout << "Return code = " << rc << endl;
+ if (rc == 5120) exit(1);
+ }
}
}
EW = 'w';
} else {
- baselon = (int)(lon / 10) * 10;
- EW = 'e';
- }
-
- char command[512];
- char container_dir[512];
+ baselon = (int)(lon / 10) * 10;
+ EW = 'e';
+ }
+
+ const char* terrainobjects[3] = { "Terrain", "Objects", 0 };
+ const char** tree;
char dir[512];
-
- // Sync Terrain
- snprintf( container_dir, 512, "%s/Terrain/%c%03d%c%02d",
- dest_base.c_str(), EW, abs(baselon), NS, abs(baselat) );
- snprintf( command, 512, "mkdir -p %s", container_dir );
- cout << command << endl;
- system( command );
-
- snprintf( dir, 512, "Terrain/%c%03d%c%02d/%c%03d%c%02d",
- EW, abs(baselon), NS, abs(baselat),
- EW, abs(lon), NS, abs(lat) );
-
- snprintf( command, 512,
- "rsync --verbose --archive --delete --perms --owner --group %s/%s/ %s/%s",
- source_base.c_str(), dir, dest_base.c_str(), dir );
- cout << command << endl;
- system( command );
-
- // Sync Objects
- snprintf( container_dir, 512, "%s/Objects/%c%03d%c%02d",
- dest_base.c_str(), EW, abs(baselon), NS, abs(baselat) );
- snprintf( command, 512, "mkdir -p %s", container_dir );
- cout << command << endl;
- system( command );
-
- snprintf( dir, 512, "Objects/%c%03d%c%02d/%c%03d%c%02d",
- EW, abs(baselon), NS, abs(baselat),
- EW, abs(lon), NS, abs(lat) );
-
- snprintf( command, 512,
- "rsync --verbose --archive --delete --perms --owner --group %s/%s/ %s/%s",
- source_base.c_str(), dir, dest_base.c_str(), dir );
- cout << command << endl;
- system( command );
+
+ for (tree = &terrainobjects[0]; *tree; tree++) {
+ snprintf( dir, 512, "%s/%c%03d%c%02d/%c%03d%c%02d",
+ *tree,
+ EW, abs(baselon), NS, abs(baselat),
+ EW, abs(lon), NS, abs(lat) );
+ sync_tree(dir);
+ }
}
} else if ( (string)argv[i] == "-d" ) {
++i;
dest_base = argv[i];
+ } else if ( (string)argv[i] == "-R" ) {
+ use_svn = false;
+ } else if ( (string)argv[i] == "-S" ) {
+ use_svn = true;
+ } else if ( (string)argv[i] == "-T" ) {
+ sync_areas( 37, -123, 0, 0 );
+ exit(0);
} else {
usage( argv[0] );
exit(-1);
++i;
}
+ // Use the appropriate default for the "-s" flag
+ if (source_base == NULL) {
+ if (use_svn)
+ source_base = svn_base;
+ else
+ source_base = rsync_base;
+ }
+
// Must call this before any other net stuff
netInit( &argc,argv );
int maxlen = 256;
int len;
int lat, lon;
- int last_lat = -9999;
- int last_lon = -9999;
+ int last_lat = nowhere;
+ int last_lon = nowhere;
bool recv_msg = false;
+ int synced_other = 0;
while ( true ) {
recv_msg = false;
recv_msg = true;
parse_message( msg, &lat, &lon );
- cout << "pos = " << lat << "," << lon << endl;
+ cout << "pos in msg = " << lat << "," << lon << endl;
}
if ( recv_msg ) {
if ( lat != last_lat || lon != last_lon ) {
int lat_dir, lon_dir, dist;
- if ( last_lat == -9999 || last_lon == -9999 ) {
+ if ( last_lat == nowhere || last_lon == nowhere ) {
lat_dir = lon_dir = 0;
} else {
dist = lat - last_lat;
}
}
cout << "lat = " << lat << " lon = " << lon << endl;
- cout << "lat_dir = " << lat_dir << " " << " lon_dir = " << lon_dir << endl;
+ cout << "lat_dir = " << lat_dir << " "
+ << "lon_dir = " << lon_dir << endl;
sync_areas( lat, lon, lat_dir, lon_dir );
- }
+ } else if ( last_lat == nowhere || last_lon == nowhere ) {
+ cout << "Waiting for FGFS to finish startup" << endl;
+ } else {
+ switch (synced_other++) {
+ case 0:
+ sync_tree((char*) "Airports/K");
+ break;
+ case 1:
+ sync_tree((char*) "Airports");
+ break;
+ default:
+ cout << "Done non-tile syncs" << endl;
+ break;
+ }
+ }
last_lat = lat;
last_lon = lon;
- }
+ }
ulSleep( 1 );
- }
+ } // while true
return 0;
}