improved shapetogeotiff method

This commit is contained in:
Mark van der Wal 2021-07-01 12:47:04 +02:00
parent 61985f9079
commit 6a3baeb8ad
2 changed files with 8 additions and 3 deletions

View File

@ -66,10 +66,15 @@ namespace FarmmapsApi.Services
i.Name.ToLower().Contains(itemName.ToLower())); ; i.Name.ToLower().Contains(itemName.ToLower())); ;
} }
public async Task<Item> ShapeToGeotiff(Item shapeItem) public async Task<Item> ShapeToGeotiff(Item shapeItem, int resolution = 1, params string[] inputLayerNames)
{ {
var startUpload = DateTime.UtcNow.AddSeconds(-3); var startUpload = DateTime.UtcNow.AddSeconds(-3);
await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff"); await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff", request =>
{
request.attributes["resolution"] = resolution.ToString();
if(inputLayerNames.Length > 0)
request.attributes["inputLayers"] = $"[{string.Join(",", inputLayerNames)}]";
});
return await FindChildItemAsync(shapeItem.ParentCode, GEOTIFF_PROCESSED_ITEMTYPE, shapeItem.Name, return await FindChildItemAsync(shapeItem.ParentCode, GEOTIFF_PROCESSED_ITEMTYPE, shapeItem.Name,
i => i.Created >= startUpload && i => i.Created >= startUpload &&

View File

@ -200,7 +200,7 @@ namespace FarmmapsNbs
} }
_logger.LogInformation($"Converting shape to geotiff"); _logger.LogInformation($"Converting shape to geotiff");
geotiffItem = await _generalService.ShapeToGeotiff(shapeItem); geotiffItem = await _generalService.ShapeToGeotiff(shapeItem, 1, input.InputLayerName);
if (geotiffItem == null) if (geotiffItem == null)
{ {
_logger.LogError("Something went wrong with shape to geotiff transformation"); _logger.LogError("Something went wrong with shape to geotiff transformation");