WIP NBS uploads json

This commit is contained in:
2020-06-15 20:50:43 +02:00
parent d1bfd92c78
commit 10b6cc8cd1
6 changed files with 833 additions and 122 deletions

View File

@@ -15,6 +15,7 @@ namespace FarmmapsNbs
public class NbsApplication : IApplication
{
private const string DownloadFolder = "Downloads";
private const string GEOJSON_ITEMTYPE = "vnd.farmmaps.itemtype.geojson";
private readonly ILogger<NbsApplication> _logger;
private readonly FarmmapsApiService _farmmapsApiService;
@@ -77,12 +78,15 @@ namespace FarmmapsNbs
var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code,
$"VRA NBS cropfield {input.OutputFileName}", plantingDate.Year, input.GeometryJson.ToString(Formatting.None));
var dataPath = Path.Combine("Data", input.ZippedShapeFile);
var shapeItem =
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.ZippedShapeFile));
var isGeoJson = input.File.Contains("json");
var dataPath = Path.Combine("Data", input.File);
var shapeItem = isGeoJson ?
await _generalService.UploadDataAsync(uploadedRoot, GEOJSON_ITEMTYPE, dataPath, Path.GetFileNameWithoutExtension(input.File)):
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.File));
if (shapeItem == null)
{
_logger.LogError("Could not find shape item");
_logger.LogError("Could not find item for uploaded data");
return;
}