private const string DATA_FILES_PATH = null; //@"C:\Users\ElevationAPI\AppData\Local"; // Leave to null for default location (Environment.SpecialFolder.LocalApplicationData)

        public SampleApplication(ILogger <SampleApplication> logger, IServiceProvider services,
                                 RasterService rasterService)
        {
            _logger            = logger;
            this.rasterService = rasterService;
            this.services      = services;

            // Change data dir if not null
            if (!string.IsNullOrWhiteSpace(DATA_FILES_PATH))
            {
                rasterService.SetLocalDirectory(DATA_FILES_PATH);
            }
        }
Ejemplo n.º 2
0
        public void Start(IServiceProvider services)
        {
            //Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            Stopwatch sw = Stopwatch.StartNew();

            _logger.LogInformation("Application started");

            bool pauseAfterEachSample = true;

            // Change data dir if not null
            if (!string.IsNullOrWhiteSpace(DATA_FILES_PATH))
            {
                rasterService.SetLocalDirectory(DATA_FILES_PATH);
            }

            //using (_logger.BeginScope($"Running {nameof(Gpx3DSamples)}.."))
            //{
            //    var gpx3DSamples = services.GetService<Gpx3DSamples>();
            //    gpx3DSamples.Run(gpx3DSamples.GetUSGSNED(@"C:\Repos\DEM.Net.Samples\DEMNet.Sample\SampleData",true), true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    //gpx3DSamples.Run(DEMDataSet.SRTM_GL1, true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    //gpx3DSamples.Run(DEMDataSet.SRTM_GL3, true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    //gpx3DSamples.Run(DEMDataSet.ASTER_GDEMV3, true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    _logger.LogInformation($"Sample {gpx3DSamples.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //}

            using (_logger.BeginScope($"Running {nameof(Text3DSample)}.."))
            {
                var sample = services.GetService <Text3DSample>();
                sample.Run();
                _logger.LogInformation($"Sample {sample.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }
            using (_logger.BeginScope($"Running {nameof(CustomRasterElevationSample)}.."))
            {
                var sample = services.GetService <CustomRasterElevationSample>();
                sample.Run();
                _logger.LogInformation($"Sample {sample.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }
            //using (_logger.BeginScope($"Running {nameof(ElevationSamples)}.."))
            //{
            //    var elevationSamples = services.GetService<ElevationSamples>();
            //    elevationSamples.Run();
            //    _logger.LogInformation($"Sample {elevationSamples.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //}
            //using (_logger.BeginScope($"Running {nameof(GpxSTLSample)}.."))
            //{
            //    var sample = services.GetService<GpxSTLSample>();
            //    sample.Run(Path.Combine("SampleData", "GPX", "Mt_Whitney_2017.gpx"), DEMDataSet.NASADEM);
            //    _logger.LogInformation($"Sample {sample.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //}
            // Visual topo sample moved to DEM.Net.Extensions repo
            //using (_logger.BeginScope($"Running {nameof(VisualTopoSample)}.."))
            //{
            //    var sample = services.GetService<VisualTopoSample>();
            //    sample.Run();
            //    _logger.LogInformation($"Sample {sample.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //}

            //using (_logger.BeginScope($"Running {nameof(AerialGpxSample)}.."))
            //{
            //    var aerialGpxSample = services.GetService<AerialGpxSample>();
            //    aerialGpxSample.Run(DEMDataSet.SRTM_GL3, DEMDataSet.ASTER_GDEMV3, useSensorLog: false);
            //    //aerialGpxSample.Run(DEMDataSet.SRTM_GL1);
            //    //aerialGpxSample.Run(DEMDataSet.AW3D30);
            //    //gpx3DSamples.Run(DEMDataSet.SRTM_GL1, true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    //gpx3DSamples.Run(DEMDataSet.SRTM_GL3, true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    //gpx3DSamples.Run(DEMDataSet.ASTER_GDEMV3, true, false, Reprojection.SRID_PROJECTED_MERCATOR);
            //    _logger.LogInformation($"Sample {aerialGpxSample.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //}
            using (_logger.BeginScope($"Running {nameof(IntervisibilitySample)}.."))
            {
                var intervisibilitySample = services.GetService <IntervisibilitySample>();
                intervisibilitySample.Run();
                _logger.LogInformation($"Sample {nameof(IntervisibilitySample)} done. Press any key to run the next sample...");

                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }
            using (_logger.BeginScope($"Running {nameof(glTF3DSamples)}.."))
            {
                var glTF3DSamples = services.GetService <glTF3DSamples>();
                //glTF3DSamples.Run(DEMDataSet.GEBCO_2019, withTexture: true);
                //glTF3DSamples.Run(DEMDataSet.ASTER_GDEMV3, withTexture:true);
                glTF3DSamples.Run(DEMDataSet.SRTM_GL3, withTexture: true);
                //glTF3DSamples.Run(DEMDataSet.SRTM_GL3, withTexture: true);
                //glTF3DSamples.Run(DEMDataSet.ETOPO1, withTexture:true);
                _logger.LogInformation($"Sample {glTF3DSamples.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }

            using (_logger.BeginScope($"Running {nameof(TINSamples)}.."))
            {
                var tinSamples = services.GetService <TINSamples>();
                tinSamples.Run(TINSamples.WKT_STE_VICTOIRE, nameof(TINSamples.WKT_STE_VICTOIRE), DEMDataSet.AW3D30, 50);
                tinSamples.Run(TINSamples.WKT_EIGER, nameof(TINSamples.WKT_EIGER), DEMDataSet.SRTM_GL3, 50);
                tinSamples.Run(TINSamples.WKT_GORGES_VERDON, nameof(TINSamples.WKT_GORGES_VERDON), DEMDataSet.AW3D30, 50);
                _logger.LogInformation($"Sample {tinSamples.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }
            using (_logger.BeginScope($"Running {nameof(ImagerySample)}.."))
            {
                var imagerySample = services.GetService <ImagerySample>();
                imagerySample.Run();
                _logger.LogInformation($"Sample {imagerySample.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }
            using (_logger.BeginScope($"Running {nameof(STLSamples)}.."))
            {
                var stLSamples = services.GetService <STLSamples>();
                stLSamples.Run();
                _logger.LogInformation($"Sample {stLSamples.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }


            using (_logger.BeginScope($"Running {nameof(DatasetSamples)}.."))
            {
                var datasetSamples = services.GetService <DatasetSamples>();

                datasetSamples.Run();
                _logger.LogInformation($"Sample {datasetSamples.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }
            using (_logger.BeginScope($"Running {nameof(GpxSamples)}.."))
            {
                var gpxSamples = services.GetService <GpxSamples>();
                gpxSamples.Run();
                _logger.LogInformation($"Sample {gpxSamples.GetType().Name} done. Press any key to run the next sample...");
                if (pauseAfterEachSample)
                {
                    Console.ReadLine();
                }
            }


            //using (_logger.BeginScope($"Running {nameof(DownloaderSample)}.."))
            //{
            //    var sample = serviceProvider.GetRequiredService<DownloaderSample>();
            //    sample.Run(DEMDataSet.ASTER_GDEMV3);
            //    _logger.LogInformation($"Sample {sample.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //}
            //using (_logger.BeginScope($"Running {nameof(CustomSamples)}.."))
            //{
            //    customSamples.Run(cancellationToken);
            //    _logger.LogInformation($"Sample {customSamples.GetType().Name} done. Press any key to run the next sample...");
            //    if (pauseAfterEachSample) Console.ReadLine();
            //    if (cancellationToken.IsCancellationRequested) return Task.FromCanceled(cancellationToken);
            //}


            _logger.LogTrace($"Application ran in : {sw.Elapsed:g}");
        }