コード例 #1
0
        /// <summary>
        /// Load in all the SRTM files to create a virtual map
        /// </summary>
        private void BuildVirtualMap()
        {
            int start_lat = (int)Math.Floor(settings.StartLatitude);
            int end_lat   = (int)(settings.StartLatitude + ((settings.ImageHeight * settings.PixelWidthInMetres) / 111320.0) + 0.5);
            int start_lon = (int)Math.Floor(settings.StartLongitude);

            double width_in_metres = settings.PixelWidthInMetres * settings.ImageWidth;

            double met    = SRTM.GetMetresPerDegreeLongitude(start_lat);
            int    width1 = (int)(width_in_metres / met);

            met = SRTM.GetMetresPerDegreeLongitude(end_lat);
            int width2 = (int)(width_in_metres / met);

            width1 = Math.Max(width1, width2);

            int    LonWidth         = width1 + 2;
            double height_in_metres = settings.PixelWidthInMetres * settings.ImageHeight;
            int    LatHeight        = (int)(height_in_metres / 111320.0) + 1;

            Map = new SRTM[LonWidth, LatHeight];

            for (int i = 0; i < LatHeight; i++)
            {
                for (int j = 0; j < LonWidth; j++)
                {
                    Map[j, i] = new SRTM(start_lat - i, start_lon + j, SRTMdirectory);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Work out the needed SRTM files and download them
        /// </summary>
        private void GetSRTMFiles()
        {
            int    start_lat        = (int)Math.Floor(settings.StartLatitude);
            int    start_lon        = (int)Math.Floor(settings.StartLongitude);
            double met              = SRTM.GetMetresPerDegreeLongitude(start_lat);
            double width_in_metres  = settings.PixelWidthInMetres * settings.ImageWidth;
            int    LonWidth         = (int)(width_in_metres / met) + 2;
            double height_in_metres = settings.PixelWidthInMetres * settings.ImageHeight;
            int    LatHeight        = (int)(height_in_metres / 111320.0) + 1;


            for (int i = 0; i < LatHeight; i++)
            {
                for (int j = 0; j < LonWidth; j++)
                {
                    RequiredFiles.Add(SRTM.GetFileName(start_lat - i, start_lon + j));
                }
            }
            UpdateMainDisplay(1);

            // Remove any files we already have
            downloadstatus = "Removing existing files";
            for (int i = RequiredFiles.Count - 1; i >= 0; i--)
            {
                String fn = System.IO.Path.Combine(SRTMdirectory, RequiredFiles[i]);
                fn += ".hgt";
                if (File.Exists(fn))
                {
                    RequiredFiles.RemoveAt(i);
                    UpdateMainDisplay(1);
                }
            }

            downloadstatus = "Downloading files";
            UpdateMainDisplay(1);

            ThreadStart childref    = new ThreadStart(DownloadFiles);
            Thread      childThread = new Thread(childref);

            childThread.IsBackground = true;
            childThread.Start();
        }