Skip to content

Commit

Permalink
0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xfischer committed May 3, 2021
1 parent db59631 commit fe8e837
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions DEM.Net.Core/DEM.Net.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackageId>DEM.Net.Core</PackageId>
<Version>0.3.1.0</Version>
<Version>0.3.2.0</Version>
<Authors>Xavier Fischer, Frédéric Aubin</Authors>
<Copyright>Xavier Fischer, Frédéric Aubin and Contributors</Copyright>
<Owners>Xavier Fischer</Owners>
Expand All @@ -21,8 +21,8 @@
</PackageLicenseExpression>
<PackageIconUrl>https://raw.githubusercontent.com/dem-net/Resources/master/images/DEMnet_512.png</PackageIconUrl>
<PackageIcon>DEMnet_64.png</PackageIcon>
<AssemblyVersion>0.3.1.0</AssemblyVersion>
<FileVersion>0.3.1.0</FileVersion>
<AssemblyVersion>0.3.2.0</AssemblyVersion>
<FileVersion>0.3.2.0</FileVersion>
<UserSecretsId>a9a5d6e1-3bb8-4dfd-ac6a-861f60dada50</UserSecretsId>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand Down
23 changes: 13 additions & 10 deletions DEM.Net.Core/Services/Raster/RasterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ public RasterService(RasterIndexServiceResolver rasterResolver, IOptions<DEMNetO
{
this._logger = logger;
this._rasterIndexServiceResolver = rasterResolver;
//_localDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), APP_NAME);
_localDirectory = options?.Value?.LocalDirectory ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), APP_NAME);
string directoryFromOptions = options?.Value?.LocalDirectory;
_localDirectory = string.IsNullOrWhiteSpace(directoryFromOptions) ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), APP_NAME)
: directoryFromOptions;
if (!Directory.Exists(_localDirectory))
Directory.CreateDirectory(_localDirectory);

_logger.LogInformation($"Local data directory : {_localDirectory}");

_metadataCatalogCache = new ConcurrentDictionary<string, List<FileMetadata>>();
}

Expand Down Expand Up @@ -132,12 +135,12 @@ public string GetLocalDEMPath(DEMDataSet dataset)
else
{
path = Path.Combine(_localDirectory, dataset.Name);
}
}
}
else
{
path = Path.Combine(_localDirectory, dataset.Name);
}
}

return path;
}
Expand All @@ -157,7 +160,7 @@ public FileMetadata ParseMetadata(string fileName, DEMFileDefinition fileFormat)

using (IRasterFile rasterFile = OpenFile(fileName, fileFormat.Type))
{
metadata = rasterFile.ParseMetaData(fileFormat);
metadata = rasterFile.ParseMetaData(fileFormat);
}

Uri fullPath = new Uri(metadata.Filename, UriKind.Absolute);
Expand Down Expand Up @@ -365,7 +368,7 @@ public async Task<List<DatasetReport>> GenerateReportAsync()
public IEnumerable<DatasetReport> GenerateReport()
{
StringBuilder sb = new StringBuilder();

// Get report for downloaded files
foreach (DEMDataSet dataset in DEMDataSet.RegisteredDatasets)
{
Expand Down Expand Up @@ -418,7 +421,7 @@ private DatasetReport GenerateReportSummary(DEMDataSet dataset)
/// <returns>A Dictionnary</returns>
public List<DemFileReport> GenerateReport(DEMDataSet dataSet, BoundingBox bbox = null)
{
List<DemFileReport> statusByFile = new List<DemFileReport>();
List<DemFileReport> statusByFile = new List<DemFileReport>();

var indexService = this._rasterIndexServiceResolver(dataSet.DataSource.DataSourceType);
indexService.Setup(dataSet, GetLocalDEMPath(dataSet));
Expand Down Expand Up @@ -533,7 +536,7 @@ public void DownloadRasterFile(DemFileReport report, DEMDataSet dataset)
/// <returns></returns>
internal HeightMap GetVirtualHeightMapInBBox(BoundingBox bbox, FileMetadata metadata, float? noDataValue)
{

int registrationOffset = metadata.FileFormat.Registration == DEMFileRegistrationMode.Grid ? 1 : 0;

int yNorth = (int)Math.Floor((bbox.yMax - metadata.PhysicalEndLat) / metadata.pixelSizeY);
Expand All @@ -542,9 +545,9 @@ internal HeightMap GetVirtualHeightMapInBBox(BoundingBox bbox, FileMetadata meta
int xEast = (int)Math.Ceiling((bbox.xMax - metadata.PhysicalStartLon) / metadata.pixelSizeX);

xWest = Math.Max(0, xWest);
xEast = Math.Min(metadata.Width - 1 , xEast) - registrationOffset;
xEast = Math.Min(metadata.Width - 1, xEast) - registrationOffset;
yNorth = Math.Max(0, yNorth);
ySouth = Math.Min(metadata.Height - 1 , ySouth) - registrationOffset;
ySouth = Math.Min(metadata.Height - 1, ySouth) - registrationOffset;

HeightMap heightMap = new HeightMap(xEast - xWest + 1, ySouth - yNorth + 1);
heightMap.Count = heightMap.Width * heightMap.Height;
Expand Down

0 comments on commit fe8e837

Please sign in to comment.