added download of all crop recordings of 1 field - using a manual croprecording itemcode
This commit is contained in:
		| @@ -12,6 +12,7 @@ namespace FarmmapsApiSamples | |||||||
|         public const string SHAPE_ITEMTYPE = "vnd.farmmaps.itemtype.shape"; |         public const string SHAPE_ITEMTYPE = "vnd.farmmaps.itemtype.shape"; | ||||||
|         public const string GEOJSON_ITEMTYPE = "vnd.farmmaps.itemtype.geojson"; |         public const string GEOJSON_ITEMTYPE = "vnd.farmmaps.itemtype.geojson"; | ||||||
|         public const string BLIGHT_ITEMTYPE = "vnd.farmmaps.itemtype.blight"; |         public const string BLIGHT_ITEMTYPE = "vnd.farmmaps.itemtype.blight"; | ||||||
|  |         public const string CROPREC_ITEMTYPE = "vnd.farmmaps.itemtype.crprec.operation"; | ||||||
|  |  | ||||||
|         public const string VRANBS_TASK = "vnd.farmmaps.task.vranbs"; |         public const string VRANBS_TASK = "vnd.farmmaps.task.vranbs"; | ||||||
|         public const string VRAHERBICIDE_TASK = "vnd.farmmaps.task.vraherbicide"; |         public const string VRAHERBICIDE_TASK = "vnd.farmmaps.task.vraherbicide"; | ||||||
|   | |||||||
| @@ -112,9 +112,34 @@ namespace FarmmapsDataDownload | |||||||
|                 cropfieldItem = await _farmmapsApiService.GetItemAsync(_settings.CropfieldItemCode); |                 cropfieldItem = await _farmmapsApiService.GetItemAsync(_settings.CropfieldItemCode); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |             //Get croprecordings | ||||||
|  |             if (input.GetCropRecordings) | ||||||
|  |             { | ||||||
|  |                 var crprecItem = input.CrprecItem; | ||||||
|  |                 //Item cropfieldItem = ; | ||||||
|  |                 _logger.LogInformation($"Trying to get crop recordings of croprecording: {crprecItem}"); | ||||||
|  |  | ||||||
|  |                 var cropRec = await _farmmapsApiService.GetItemChildrenAsync(crprecItem, CROPREC_ITEMTYPE);  | ||||||
|  |                 if (cropRec == null) | ||||||
|  |                 { | ||||||
|  |                     _logger.LogError("Something went wrong while obtaining the croprecordings"); | ||||||
|  |                     return; | ||||||
|  |                 } | ||||||
|  |  | ||||||
|  |                 var cropRecPath = Path.Combine(downloadFolder, $"croprecordings_{crprecItem}.json"); | ||||||
|  |                 _logger.LogInformation($"Found {cropRec.Count} crop recordings"); | ||||||
|  |                 var count = 0; | ||||||
|  |                 TimeSpan.FromSeconds(0.5); | ||||||
|  |                 foreach (var item in cropRec) | ||||||
|  |                 { | ||||||
|  |                     Console.WriteLine($"Crop recording #{count}: {item.Name}"); | ||||||
|  |                     File.AppendAllText(cropRecPath, item.Data +Environment.NewLine); | ||||||
|  |                     count++; | ||||||
|  |                 } | ||||||
|  |                 _logger.LogInformation($"Downloaded file {cropRecPath}"); | ||||||
|  |             } | ||||||
|  |  | ||||||
|             // Get shadow data |             // Get shadow data | ||||||
|  |  | ||||||
|             if (input.GetShadowData) |             if (input.GetShadowData) | ||||||
|             { |             { | ||||||
|                 _logger.LogInformation("Calculate shadow map for field"); |                 _logger.LogInformation("Calculate shadow map for field"); | ||||||
| @@ -220,10 +245,7 @@ namespace FarmmapsDataDownload | |||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 // Select a particular satellite item from satelliteTask |                 // Select a particular satellite item from satelliteTask | ||||||
|                 Item vanDerSatItem = await _generalService.FindVanDerSatItem(cropfieldItem, _settings.VanDerSatTaskCode, fieldName,  input.StoreVanDerSatStatistics); |                 Item vanDerSatItem = await _generalService.FindVanDerSatItem(cropfieldItem, _settings.VanDerSatTaskCode, fieldName,  input.StoreVanDerSatStatistics);                 | ||||||
|                  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,14 +1,16 @@ | |||||||
| [ | [ | ||||||
|   { |   { | ||||||
|     "UseCreatedCropfield": true, |     "UseCreatedCropfield": true, | ||||||
|     "outputFileName": "testSatData2", |     "outputFileName": "TestData", | ||||||
|     "fieldName": "test_satData2", |     "fieldName": "TestField", | ||||||
|     "DownloadFolder": "C:\\workdir\\groenmonitor\\", //"C:\\workdir\\groenmonitor\\", // "Downloads", -> if you just put  "Downloads" the program will download to somewhere in ..\FarmMapsApiClient_WURtest\FarmmapsDataDownload\bin\Debug\netcoreapp3.1\Downloads\ |     "DownloadFolder": "Downloads", //"C:\\workdir\\groenmonitor\\", // "Downloads", -> if you just put  "Downloads" the program will download to somewhere in ..\FarmMapsApiClient_WURtest\FarmmapsDataDownload\bin\Debug\netcoreapp3.1\Downloads\ | ||||||
|  |     "GetCropRecordings": true, | ||||||
|  |     "CrprecItem": "...", //item code of de crop recording parrent - can be found by opening the crop recording page of a field.  | ||||||
|     "GetShadowData": false, |     "GetShadowData": false, | ||||||
|     "GetSatelliteData": true, |     "GetSatelliteData": false, | ||||||
|     "SatelliteBand": "wdvi", // "natural", "ndvi" or "wdvi" |     "SatelliteBand": "wdvi", // "natural", "ndvi" or "wdvi" | ||||||
|     "StoreSatelliteStatisticsSingleImage": true, |     "StoreSatelliteStatisticsSingleImage": false, | ||||||
|     "StoreSatelliteStatisticsCropYear": true, |     "StoreSatelliteStatisticsCropYear": false, | ||||||
|     "GetVanDerSatData": false, |     "GetVanDerSatData": false, | ||||||
|     "StoreVanDerSatStatistics": false, |     "StoreVanDerSatStatistics": false, | ||||||
|     "CropYear": 2020, |     "CropYear": 2020, | ||||||
|   | |||||||
| @@ -21,8 +21,8 @@ namespace FarmmapsDataDownload.Models | |||||||
|         public bool StoreSatelliteStatisticsCropYear { get; set; } |         public bool StoreSatelliteStatisticsCropYear { get; set; } | ||||||
|         public bool StoreVanDerSatStatistics { get; set; } |         public bool StoreVanDerSatStatistics { get; set; } | ||||||
|         public bool GetShadowData { get; set; } |         public bool GetShadowData { get; set; } | ||||||
|  |         public bool GetCropRecordings { get; set; } | ||||||
|  |         public string CrprecItem { get; set; } | ||||||
|  |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -188,7 +188,6 @@ namespace FarmmapsNbs { | |||||||
|                 ////End shape to geotiff transformation |                 ////End shape to geotiff transformation | ||||||
|             } |             } | ||||||
|  |  | ||||||
|  |  | ||||||
|             _logger.LogInformation($"Calculating targetN with targetYield: {input.TargetYield}"); |             _logger.LogInformation($"Calculating targetN with targetYield: {input.TargetYield}"); | ||||||
|             var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem); |             var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem); | ||||||
|             var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate, |             var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate, | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| [ | [ | ||||||
|   { |   { | ||||||
|     "UseCreatedCropfield": false, |     "UseCreatedCropfield": true, | ||||||
|     "file": "Scan1_20190605_sample.json", |     "file": "Scan1_20190605_sample.json", | ||||||
|     "inputVariable": "irmi", |     "inputVariable": "irmi", | ||||||
|     "inputLayerName": "irmi", |     "inputLayerName": "irmi", | ||||||
|     "outputFileName": "vranbs_sample", |     "outputFileName": "vranbs_sample", | ||||||
|     "fieldName": "sampleJson_irmi", |     "fieldName": "sampleJson_irmi-usertest", | ||||||
|     "storeSatelliteStatistics": true, |     "storeSatelliteStatistics": true, | ||||||
|     "plantingDate": "2019-04-18", |     "plantingDate": "2019-04-18", | ||||||
|     "measurementDate": "2019-06-05", |     "measurementDate": "2019-06-05", | ||||||
|   | |||||||
| @@ -2,11 +2,11 @@ | |||||||
|   //There are three farmmaps environments, uncomment the environemnt you want to use with this sample client |   //There are three farmmaps environments, uncomment the environemnt you want to use with this sample client | ||||||
|  |  | ||||||
|   //test environment |   //test environment | ||||||
| //  "Authority": "https://accounts.test.farmmaps.eu/", |   "Authority": "https://accounts.test.farmmaps.eu/", | ||||||
| //  "Endpoint": "https://test.farmmaps.eu/", |   "Endpoint": "https://test.farmmaps.eu/", | ||||||
| //  "BasePath": "api/v1", |   "BasePath": "api/v1", | ||||||
| //  "DiscoveryEndpointUrl": "https://accounts.test.farmmaps.eu/.well-known/openid-configuration", |   "DiscoveryEndpointUrl": "https://accounts.test.farmmaps.eu/.well-known/openid-configuration", | ||||||
| //  "GrantClientId": "farmmapstesteu", |   "GrantClientId": "farmmapstesteu", | ||||||
|  |  | ||||||
|   ////acceptance environment |   ////acceptance environment | ||||||
|   //"Authority": "https://accounts.acc.farmmaps.eu/", |   //"Authority": "https://accounts.acc.farmmaps.eu/", | ||||||
| @@ -15,12 +15,12 @@ | |||||||
|   //"DiscoveryEndpointUrl": "https://accounts.acc.farmmaps.eu/.well-known/openid-configuration", |   //"DiscoveryEndpointUrl": "https://accounts.acc.farmmaps.eu/.well-known/openid-configuration", | ||||||
|   //"GrantClientId": "farmmapsacceu", |   //"GrantClientId": "farmmapsacceu", | ||||||
|  |  | ||||||
|   //production environment |   ////production environment | ||||||
|   "authority": "https://accounts.farmmaps.eu/", |   //"authority": "https://accounts.farmmaps.eu/", | ||||||
|   "endpoint": "https://farmmaps.eu/", |   //"endpoint": "https://farmmaps.eu/", | ||||||
|   "basepath": "api/v1", |   //"basepath": "api/v1", | ||||||
|   "discoveryendpointurl": "https://accounts.farmmaps.eu/.well-known/openid-configuration", |   //"discoveryendpointurl": "https://accounts.farmmaps.eu/.well-known/openid-configuration", | ||||||
|   "GrantClientId": "farmmaps", |   //"GrantClientId": "farmmaps", | ||||||
|  |  | ||||||
|   //overige info |   //overige info | ||||||
|   "RedirectUri": "http://example.nl/api", |   "RedirectUri": "http://example.nl/api", | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user