diff --git a/DEM.Net.Core/Services/DemProviders/OpenTopography/GDALVRTFileService.cs b/DEM.Net.Core/Services/DemProviders/OpenTopography/GDALVRTFileService.cs
index e8fddbad..c5d280b8 100644
--- a/DEM.Net.Core/Services/DemProviders/OpenTopography/GDALVRTFileService.cs
+++ b/DEM.Net.Core/Services/DemProviders/OpenTopography/GDALVRTFileService.cs
@@ -111,7 +111,7 @@ void IDEMDataSetIndex.Setup(DEMDataSet dataSet, string dataSetLocalDir)
{
_logger?.LogInformation($"Downloading index file from {dataSet.DataSource.IndexFilePath}... This file will be downloaded once and stored locally.");
- HttpClient client = _httpClientFactory.CreateClient();
+ HttpClient client = _httpClientFactory == null ? new HttpClient() : _httpClientFactory.CreateClient();
using (HttpResponseMessage response = client.GetAsync(dataSet.DataSource.IndexFilePath).Result)
using (FileStream fs = new FileStream(vrtFileName, FileMode.Create, FileAccess.Write))
@@ -209,7 +209,7 @@ public void DownloadRasterFile(DemFileReport report, DEMDataSet dataset)
// Create directories if not existing
new FileInfo(report.LocalName).Directory.Create();
- HttpClient client = _httpClientFactory.CreateClient();
+ HttpClient client = _httpClientFactory == null ? new HttpClient() : _httpClientFactory.CreateClient();
var contentbytes = client.GetByteArrayAsync(report.URL).Result;
using (FileStream fs = new FileStream(report.LocalName, FileMode.Create, FileAccess.Write))
diff --git a/DEM.Net.TestWinForm/DEM.Net.TestWinForm.csproj b/DEM.Net.TestWinForm/DEM.Net.TestWinForm.csproj
index fd670043..cc34e8c8 100644
--- a/DEM.Net.TestWinForm/DEM.Net.TestWinForm.csproj
+++ b/DEM.Net.TestWinForm/DEM.Net.TestWinForm.csproj
@@ -114,8 +114,8 @@
-
- 1.9.0
+
+ 1.0.0
2.2.0
diff --git a/DEM.Net.TestWinForm/EchantillonsTestsServices.cs b/DEM.Net.TestWinForm/EchantillonsTestsServices.cs
index 97e733c8..7b5a37ac 100644
--- a/DEM.Net.TestWinForm/EchantillonsTestsServices.cs
+++ b/DEM.Net.TestWinForm/EchantillonsTestsServices.cs
@@ -5,6 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using DEM.Net.Core;
+using DEM.Net.Core.Datasets;
namespace DEM.Net.TestWinForm
{
@@ -15,7 +16,18 @@ public List GetPointsTestsByBBox(string p_bbox, DEMDataSet d
List v_pointsToTest = new List();
try
{
- RasterService v_rasterService = new RasterService(null);
+ // fix issue #86 to work with opentopography files without proper DI injection
+ RasterIndexServiceResolver rasterIndexServiceResolver = dataSourceType =>
+ {
+ switch (dataSourceType)
+ {
+ case DEMDataSourceType.GDALVrt:
+ return new GDALVRTFileService(null, null);
+ default:
+ throw new KeyNotFoundException(); // or maybe return null, up to you
+ }
+ };
+ RasterService v_rasterService = new RasterService(rasterIndexServiceResolver);
ElevationService v_elevationService = new ElevationService(v_rasterService, null);
BoundingBox v_bbox = GeometryService.GetBoundingBox(p_bbox);
v_elevationService.DownloadMissingFiles(dataset, v_bbox);