Skip to content

Commit

Permalink
Merge pull request #44 from dem-net/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
xfischer authored Apr 29, 2019
2 parents 3a407f8 + f0c60e4 commit 15649e9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 33 deletions.
21 changes: 15 additions & 6 deletions DEM.Net.Core/DEM.Net.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,36 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<PackageId>DEM.Net.Core</PackageId>
<Version>0.1.0-beta0009</Version>
<Version>0.1.0-beta0010</Version>
<Authors>Xavier Fischer, Frédéric Aubin</Authors>
<Copyright>Xavier Fischer, Frédéric Aubin</Copyright>
<Owners>Xavier Fischer</Owners>
<PackageProjectUrl>https://github.com/dem-net/DEM.Net</PackageProjectUrl>
<PackageReleaseNotes>DouglasPeucker enhanced
GenerateReportForLocation returns a single or no element
RasterService is a Singleton in DI registration</PackageReleaseNotes>
<PackageReleaseNotes>Dataset reports return a simpler list
TIN fixed when border points were local summits</PackageReleaseNotes>
<PackageTags>DEM, Terrain, Elevation</PackageTags>
<Title>DEM.Net</Title>
<Product>DEM.Net</Product>
<Description>Digital Elevation Model library for .Net. Elevation, Heightmaps, STL, glTF</Description>
<Summary>Digital Elevation Model library for .Net. Elevation, Heightmaps, STL, glTF</Summary>
<RepositoryUrl>https://github.com/dem-net/DEM.Net</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIconUrl>https://raw.githubusercontent.com/dem-net/Resources/master/images/DEMnet_512.png</PackageIconUrl>
</PropertyGroup>

<!-- Build package only in Release -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<!-- Build package only in Release -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<!-- Define NETFULL and NETSTANDARD for all matching targets -->
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETCORE;NETSTANDARD;NETSTANDARD2_0</DefineConstants>
Expand Down
4 changes: 2 additions & 2 deletions DEM.Net.Core/Services/Elevation/ElevationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void DownloadMissingFiles(DEMDataSet dataSet, BoundingBox bbox = null)
{
var report = _IRasterService.GenerateReport(dataSet, bbox);

DownloadMissingFiles_FromReport(report.Values, dataSet);
DownloadMissingFiles_FromReport(report, dataSet);

}
public void DownloadMissingFiles(DEMDataSet dataSet, double lat, double lon)
Expand Down Expand Up @@ -89,7 +89,7 @@ private void DownloadMissingFiles_FromReport(IEnumerable<DemFileReport> report,

if (filesToDownload.Count == 0)
{
_logger?.LogInformation("No missing file(s).");
_logger?.LogTrace("No missing file(s).");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion DEM.Net.Core/Services/Raster/IRasterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public interface IRasterService
/// <param name="dataSet">DEM dataset information</param>
/// <param name="bbox">Bbox for filtering</param>
/// <returns></returns>
Dictionary<string, DemFileReport> GenerateReport(DEMDataSet dataSet, BoundingBox bbox = null);
List<DemFileReport> GenerateReport(DEMDataSet dataSet, BoundingBox bbox = null);

/// <summary>
///
Expand Down
40 changes: 22 additions & 18 deletions DEM.Net.Core/Services/Raster/RasterService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@

namespace DEM.Net.Core
{
public class RasterService : IRasterService
public class RasterService : IRasterService
{
const string APP_NAME = "DEM.Net";
const string MANIFEST_DIR = "manifest";
const int EARTH_CIRCUMFERENCE_METERS = 40075017;
GDALVRTFileService _gdalService;
private readonly ILogger<RasterService> _logger;

Expand Down Expand Up @@ -159,13 +158,6 @@ public List<FileMetadata> LoadManifestMetadata(DEMDataSet dataset, bool force)
return _metadataCatalogCache[localPath];
}


public static int GetResolutionMeters(FileMetadata metadata)
{
double preciseRes = metadata.pixelSizeX * EARTH_CIRCUMFERENCE_METERS / 360d;
return (int)Math.Floor(preciseRes);
}

/// <summary>
/// Generate metadata files for fast in-memory indexing
/// </summary>
Expand Down Expand Up @@ -260,17 +252,23 @@ public void GenerateFileMetadata(string rasterFileName, DEMFileFormat fileFormat

}

/// <summary>
/// Generates a full report of all datasets to check size and number of downloaded tiles
/// </summary>
/// <returns>
/// A string containing the report
/// </returns>
public string GenerateReportAsString()
{
StringBuilder sb = new StringBuilder();
// Get report for downloaded files
foreach (DEMDataSet dataset in DEMDataSet.RegisteredDatasets)
{
Dictionary<string, DemFileReport> report = GenerateReport(dataset);
List<DemFileReport> report = GenerateReport(dataset);
int totalFiles = report.Count;
int downloadedCount = report.Count(kvp => kvp.Value.IsExistingLocally);
int isMetadataGeneratedCount = report.Count(kvp => kvp.Value.IsMetadataGenerated);
int isnotMetadataGeneratedCount = report.Count(kvp => !kvp.Value.IsMetadataGenerated);
int downloadedCount = report.Count(rpt => rpt.IsExistingLocally);
int isMetadataGeneratedCount = report.Count(rpt => rpt.IsMetadataGenerated);
int isnotMetadataGeneratedCount = report.Count(rpt => !rpt.IsMetadataGenerated);

var fileSizeBytes = FileSystem.GetDirectorySize(GetLocalDEMPath(dataset));
var fileSizeMB = fileSizeBytes / 1024f / 1024f;
Expand All @@ -284,18 +282,24 @@ public string GenerateReportAsString()
}


public bool BoundingBoxIntersects(BoundingBox bbox1, BoundingBox bbox2)
bool BoundingBoxIntersects(BoundingBox bbox1, BoundingBox bbox2)
{
return (bbox1.xMax >= bbox2.xMin && bbox1.xMin <= bbox2.xMax) && (bbox1.yMax >= bbox2.yMin && bbox1.yMin <= bbox2.yMax);
}
public bool BoundingBoxIntersects(BoundingBox bbox1, double lat, double lon)
bool BoundingBoxIntersects(BoundingBox bbox1, double lat, double lon)
{
return (bbox1.xMax >= lon && bbox1.xMin <= lon) && (bbox1.yMax >= lat && bbox1.yMin <= lat);
}

public Dictionary<string, DemFileReport> GenerateReport(DEMDataSet dataSet, BoundingBox bbox = null)
/// <summary>
/// Compare LST file and local directory and generates dictionary with key : remoteFile and value = true if file is present and false if it is not downloaded
/// </summary>
/// <param name="dataSet">DEM dataset information</param>
/// <param name="bbox">Bbox for filtering</param>
/// <returns>A Dictionnary</returns>
public List<DemFileReport> GenerateReport(DEMDataSet dataSet, BoundingBox bbox = null)
{
Dictionary<string, DemFileReport> statusByFile = new Dictionary<string, DemFileReport>();
List<DemFileReport> statusByFile = new List<DemFileReport>();
if (_gdalService == null || _gdalService.Dataset.Name != dataSet.Name)
{
_gdalService = new GDALVRTFileService(GetLocalDEMPath(dataSet), dataSet);
Expand All @@ -308,7 +312,7 @@ public Dictionary<string, DemFileReport> GenerateReport(DEMDataSet dataSet, Boun
if (bbox == null || BoundingBoxIntersects(source.BBox, bbox))
{

statusByFile.Add(source.SourceFileNameAbsolute, new DemFileReport()
statusByFile.Add(new DemFileReport()
{
IsExistingLocally = File.Exists(source.LocalFileName),
IsMetadataGenerated = File.Exists(GetMetadataFileName(source.LocalFileName, ".json")),
Expand Down
19 changes: 15 additions & 4 deletions DEM.Net.glTF/DEM.Net.glTF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,36 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<PackageId>DEM.Net.glTF</PackageId>
<Version>0.1.0-beta0009</Version>
<Version>0.1.0-beta0010</Version>
<Authors>Xavier Fischer</Authors>
<Copyright>Xavier Fischer</Copyright>
<Owners>Xavier Fischer</Owners>
<PackageProjectUrl>https://github.com/dem-net/DEM.Net.glTF</PackageProjectUrl>
<PackageReleaseNotes>Support for dependency injection and logging</PackageReleaseNotes>
<PackageReleaseNotes>Dataset reports return a simpler list
TIN fixed when border points were local summits</PackageReleaseNotes>
<PackageTags>DEM, Terrain, Elevation, Mesh, 3D, glTF, Map, STL</PackageTags>
<Title>DEM.Net</Title>
<Product>DEM.Net</Product>
<Description>glTF3D and STL exporters for DEM.Net</Description>
<Summary>glTF3D and STL exporters for DEM.Net</Summary>
<RepositoryUrl>https://github.com/dem-net/DEM.Net.glTF</RepositoryUrl>
<RepositoryType>GitHub</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIconUrl>https://raw.githubusercontent.com/dem-net/Resources/master/images/DEMnet_512.png</PackageIconUrl>
</PropertyGroup>

<!-- Build package only in Release -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release'">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<!-- Build package only in Release -->
<PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="glTF2Loader" Version="1.1.3-alpha" />
<PackageReference Include="IxMilia.Stl" Version="0.1.1" />
Expand Down
4 changes: 2 additions & 2 deletions DEM.Net.xUnit.Test/DatasetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public void DownloadTile_BBox()

Assert.NotNull(report);
Assert.True(report.Count > 0);
Assert.True(report.Values.First().IsExistingLocally);
Assert.Equal("N43E005.hgt", Path.GetFileName(report.Values.First().LocalName));
Assert.True(report.First().IsExistingLocally);
Assert.Equal("N43E005.hgt", Path.GetFileName(report.First().LocalName));

}

Expand Down

0 comments on commit 15649e9

Please sign in to comment.