From f375c9f5e333a4e55799337546d432c00f0ba5a9 Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Wed, 21 Aug 2024 11:01:01 -0600
Subject: [PATCH] add weighted option

---
 .../src/app/source/mfd/services/app.service.ts        | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts b/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts
index a7dc09077..5dea22443 100644
--- a/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts
+++ b/projects/nshmp-apps/src/app/source/mfd/services/app.service.ts
@@ -75,6 +75,8 @@ export interface MfdQuery {
   sourceTree: string;
   /** Source type */
   sourceType: SourceType;
+  /** Whether to apply weight */
+  weightedMfds: string;
 }
 
 /**
@@ -256,6 +258,7 @@ export class AppService
       source,
       sourceAsString: JSON.stringify(source),
       sourceTree: null,
+      weightedMfds: false,
     };
   }
 
@@ -594,12 +597,13 @@ export class AppService
       : null;
 
     const formValues: ControlForm = {
-      cumulative: queryParams.cumulative === 'true',
+      cumulative: queryParams?.cumulative === 'true',
       mfdType: defaultValues.mfdType,
       model,
       source,
       sourceAsString: JSON.stringify(source),
       sourceTree,
+      weightedMfds: queryParams?.weightedMfds === 'true',
     };
 
     this.formGroup.patchValue(formValues);
@@ -821,7 +825,9 @@ export class AppService
           let plotData: Partial<PlotData> = {
             name: name.length > 50 ? `${name.substring(0, 50)} ...` : name,
             x: xySequence.xs,
-            y: xySequence.ys.map(y => y * branch.weight * mfdInfo.weight),
+            y: form.weightedMfds
+              ? xySequence.ys.map(y => y * branch.weight * mfdInfo.weight)
+              : xySequence.ys,
           };
 
           if (mfdInfo.mfd.props.type === MfdType.SINGLE) {
@@ -894,6 +900,7 @@ export class AppService
       setting: source.tectonicSettings ?? null,
       sourceTree: values.sourceTree?.toString() ?? null,
       sourceType: source.sourceType ?? null,
+      weightedMfds: values.weightedMfds.toString(),
     };
 
     this.router
-- 
GitLab