Skip to content

Commit

Permalink
issue #86 tried to get it working without DI. Sharpgltf update broke …
Browse files Browse the repository at this point in the history
…the rest
  • Loading branch information
xfischer committed Jan 8, 2021
1 parent daf291e commit d5af46e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions DEM.Net.TestWinForm/DEM.Net.TestWinForm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="DotSpatial.Projections">
<Version>1.9.0</Version>
<PackageReference Include="DotSpatial.Projections.NetStandard">
<Version>1.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.Platforms">
<Version>2.2.0</Version>
Expand Down
14 changes: 13 additions & 1 deletion DEM.Net.TestWinForm/EchantillonsTestsServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Text;
using System.Threading.Tasks;
using DEM.Net.Core;
using DEM.Net.Core.Datasets;

namespace DEM.Net.TestWinForm
{
Expand All @@ -15,7 +16,18 @@ public List<BeanPoint_internal> GetPointsTestsByBBox(string p_bbox, DEMDataSet d
List<BeanPoint_internal> v_pointsToTest = new List<BeanPoint_internal>();
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);
Expand Down

0 comments on commit d5af46e

Please sign in to comment.