コード例 #1
0
        /// <summary>
        /// Test method to load a series of HGT files in a directory
        /// </summary>
        /// <param name="directory"></param>
        public static List<IElevationDataSet> LoadHGTFilesInDirectory(String directoryPath)
        {
            IHgtFileNameParser fileNameParser = new HgtFileNameParser();
            IHgtByteConverter byteConverter = new HgtByteConverter();

            IElevationFileReader elevationDataReader = new LocalFileStorageHgtElevationFileReader(fileNameParser, byteConverter);

            List<String> fileNames = new List<string>();
            List<IElevationDataSet> elevationDataSets = new List<IElevationDataSet>();

            if (!Directory.Exists(directoryPath))
                throw new DirectoryNotFoundException(directoryPath);

            fileNames.AddRange(Directory.GetFiles(directoryPath, "*.hgt", SearchOption.AllDirectories));

            foreach (String fileName in fileNames)
            {
                DecimalGeoCoordinate geoCoordinate = fileNameParser.ParseGeoCoordinateFromFileName(fileName);

                IElevationDataSet dataSet = elevationDataReader.LoadDataSet(fileName);
                elevationDataSets.Add(dataSet);
            }

            return elevationDataSets;
        }
コード例 #2
0
        static void Main(string[] args)
        {
            String demDataFolder = @"D:\\Code\\Projects\\DEMData\\";

            IHgtFileNameParser fileNameParser = new HgtFileNameParser();
            IHgtByteConverter byteConverter = new HgtByteConverter();
            IAzureFileStorageShareProvider azureStorageProvider = new AzureFileStorageShareProvider(
                System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"],
                "hgt");

            IElevationFileReader elevationFileReader = new LocalFileStorageHgtElevationFileReader(fileNameParser, byteConverter);
            IElevationFileReader azureFileReader = new AzureFileStorageHgtElevationFileReader(fileNameParser, byteConverter,  azureStorageProvider);

            CloudFileDirectory cloudDirectoryRoot = azureStorageProvider.GetCloudFileShare().GetRootDirectoryReference();

            IElevationDataSet azureTestSet = azureFileReader.LoadDataSet(
                Path.Combine(cloudDirectoryRoot.Uri.ToString(), "N48E000.hgt"));

            IElevationDataSetRepository dataSetRepository = new ElevationDataSetFileSystemRepository(
                azureFileReader,
                fileNameParser,
                demDataFolder);

            IElevationDataManager elevationDataManager = new ElevationDataManager(dataSetRepository);

            DecimalGeoCoordinate testCoordinate = new DecimalGeoCoordinate(54.5, -2.5);

            int elevation;

            if (elevationDataManager.IsElevationDataSetAvailable(testCoordinate))
                elevation = elevationDataManager.GetElevationAtCoordinate(testCoordinate);

            IElevationProfiler elevationProfiler = new ElevationProfiler(
                elevationDataManager,
                new SimplePathPlotter());               // Used to draw the line by the elevation profiler

            IElevationProfile elevationProfile = elevationProfiler.GetElevationProfile(
                new DecimalGeoCoordinate(55.1, -2.1),   // Start of line
                new DecimalGeoCoordinate(55.2, -2.2),   // End of line
                100);                                   // Number of segments or 'resolution' of the profile

            IElevationProfile elevationProfile2 = elevationProfiler.GetElevationProfile(
                new List<DecimalGeoCoordinate>() { new DecimalGeoCoordinate(52, -1), new DecimalGeoCoordinate(52.2, -1.2), new DecimalGeoCoordinate(52.2, -1.4) }, 10);

            foreach (ElevationDataPoint point in elevationProfile.Points)
                Console.WriteLine("{0} {1}", point.Coordinates, point.ElevationInMetres);

            Console.ReadKey();
        }
コード例 #3
0
        /// <summary>
        /// Convert an elevation data file (.hgt) to an azure table store
        /// </summary>
        /// <param name="message"> Specifies the filename of the .hgt file on azure file storage </param>
        /// <param name="log"></param>
        public static void ProcessHgtElevationFile([QueueTrigger("table-conversion-queue")] string message, TextWriter log)
        {
            IHgtFileNameParser fileNameParser = new HgtFileNameParser();

            if (!fileNameParser.IsValidHGTFileNameFormat(message.Replace(".hgt", String.Empty)))
                throw new ArgumentException(String.Format("'{0}' is not a valid hgt filename.", message));

            IElevationFileReader azureFileReader = GetAzureStorageElevationFileReader();
            CloudTable cloudTable = GetAzureCloudTable();
            IElevationDataSet dataSet = azureFileReader.LoadDataSet(message);

            Stopwatch sw = new Stopwatch();

            Console.WriteLine(String.Format("Processing file: {0}", message));

            sw.Start();
            ConvertToTableStorage(cloudTable, dataSet);
            sw.Stop();

            Console.WriteLine("Finished processing file '{0}'. Time Taken: {1}", message, sw.Elapsed);
        }
コード例 #4
0
        /// <summary>
        /// Create an elevation reader for the azure file storage
        /// </summary>
        /// <returns></returns>
        private static IElevationFileReader GetAzureStorageElevationFileReader()
        {
            IHgtFileNameParser fileNameParser = new HgtFileNameParser();
            IHgtByteConverter byteConverter = new HgtByteConverter();
            IAzureFileStorageShareProvider azureStorageProvider = new AzureFileStorageShareProvider(
                ConfigurationManager.ConnectionStrings["AzureWebJobsStorage"].ConnectionString,
                "hgt");

            return new AzureFileStorageHgtElevationFileReader(fileNameParser, byteConverter, azureStorageProvider);
        }