Esempio n. 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;
        }
Esempio n. 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();
        }
Esempio n. 3
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);
        }