changeset 4513:9b1e5a3ed3cc

FA import: if no LOS is provided assume LOS3. Near the black sea no LOS is provided with available fairway depth data, as the conditions (and requirements) are actually _better_ than LOS3. For gemma it is acceptable to assume LOS3 for these cases to fit into the requirement of given a LOS so that current reports and calculations work.
author Sascha Wilde <wilde@intevation.de>
date Fri, 04 Oct 2019 16:39:42 +0200
parents 7caf620dda50
children 9f2d690b7076 a92239475590
files pkg/imports/fa.go
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/fa.go	Fri Oct 04 11:58:37 2019 +0200
+++ b/pkg/imports/fa.go	Fri Oct 04 16:39:42 2019 +0200
@@ -300,6 +300,8 @@
 	feedback Feedback,
 ) ([]string, error) {
 
+	default_los := ifaf.LosEnumLOS3
+
 	insertFAStmt, err := tx.PrepareContext(ctx, insertFASQL)
 	if err != nil {
 		return nil, err
@@ -371,7 +373,10 @@
 		if faRes.Effective_fairway_availability != nil {
 			efaCount := 0
 			for _, efa := range faRes.Effective_fairway_availability.EffectiveFairwayAvailability {
-				los := efa.Level_of_Service
+				los := &default_los
+				if efa.Level_of_Service != nil {
+					los = efa.Level_of_Service
+				}
 				fgt := efa.Forecast_generation_time
 				if efa.Forecast_generation_time.Status == pgtype.Undefined {
 					fgt = pgtype.Timestamp{
@@ -407,10 +412,14 @@
 		if faRes.Reference_values != nil {
 			rvCount := 0
 			for _, fav := range faRes.Reference_values.ReferenceValue {
+				los := &default_los
+				if fav.Level_of_Service != nil {
+					los = fav.Level_of_Service
+				}
 				res, err := insertFAVStmt.ExecContext(
 					ctx,
 					faID,
-					fav.Level_of_Service,
+					los,
 					fav.Fairway_depth,
 					fav.Fairway_width,
 					fav.Fairway_radius,