Exemple #1
0
        private void GenerateTMCFile(AFS2GridSquare afs2GridSquare, string stitchedTilesDirectory, string afsGridSquareDirectory, StitchedImage firstStitchedImageAeroFile)
        {
            // Create directories for Geoconvert output if they do not exist.
            // Better to do this here in case anyone wants to run Geoconvert manually
            var geoConvertRawDirectory = String.Format("{0}-geoconvert-raw\\", firstStitchedImageAeroFile.ZoomLevel);
            var geoConvertTTCDirectory = String.Format("{0}-geoconvert-ttc\\", firstStitchedImageAeroFile.ZoomLevel);
            var geoConvertRawPath      = afsGridSquareDirectory + geoConvertRawDirectory;
            var geoConvertTTCPath      = afsGridSquareDirectory + geoConvertTTCDirectory;

            if (!Directory.Exists(geoConvertRawPath))
            {
                Directory.CreateDirectory(geoConvertRawPath);
            }

            if (!Directory.Exists(geoConvertTTCPath))
            {
                Directory.CreateDirectory(geoConvertTTCPath);
            }

            var tmcFile = new TMCFile();

            tmcFile.AlwaysOverwrite      = true;
            tmcFile.DoHeightmaps         = false;
            tmcFile.FolderDestinationRaw = geoConvertRawPath;
            tmcFile.FolderDestinationTTC = geoConvertTTCPath;
            tmcFile.FolderSourceFiles    = stitchedTilesDirectory;
            tmcFile.WriteImagesWithMask  = AeroSceneryManager.Instance.Settings.GeoConvertWriteImagesWithMask.Value;
            tmcFile.WriteRawFiles        = AeroSceneryManager.Instance.Settings.GeoConvertWriteRawFiles.Value;
            tmcFile.WriteTTCFiles        = true;

            // All TMC regions will have the same lat / lon max and min
            // Create a template Region here to base other regions off
            TMCRegion tmcRegionTemplate = new TMCRegion();

            // Really NW Corner
            tmcRegionTemplate.LatMin = afs2GridSquare.NorthLatitude;
            tmcRegionTemplate.LonMin = afs2GridSquare.WestLongitude;

            // Realy SE Corner
            tmcRegionTemplate.LatMax = afs2GridSquare.SouthLatitude;
            tmcRegionTemplate.LonMax = afs2GridSquare.EastLongitude;

            tmcFile.Regions = this.GenerateTMCFileRegions(tmcRegionTemplate);

            var tmcFileStr = tmcFile.ToString();

            var filenameParts = firstStitchedImageAeroFile.FileName.Split('_');
            var tmcFilename   = String.Format("{0}_{1}_{2}", filenameParts[0], filenameParts[1], filenameParts[2]);

            string path = String.Format("{0}{1}.tmc", stitchedTilesDirectory, tmcFilename);

            File.WriteAllText(path, tmcFileStr);
        }
Exemple #2
0
        private List <TMCRegion> GenerateTMCFileRegions(TMCRegion tmcRegionTemplate)
        {
            var settings = AeroSceneryManager.Instance.Settings;

            List <TMCRegion> regions = new List <TMCRegion>();

            foreach (int afsLevel in settings.AFSLevelsToGenerate)
            {
                var region = new TMCRegion();
                region.LatMax = tmcRegionTemplate.LatMax;
                region.LonMax = tmcRegionTemplate.LonMax;
                region.LatMin = tmcRegionTemplate.LatMin;
                region.LonMin = tmcRegionTemplate.LonMin;
                region.Level  = afsLevel;
                region.WriteImagesWithMask = AeroSceneryManager.Instance.Settings.GeoConvertWriteImagesWithMask.Value;
                regions.Add(region);
            }

            return(regions);
        }