Skip to content

Commit

Permalink
Remove replicate checks in Habitat Replication tab. Change SMCANT to …
Browse files Browse the repository at this point in the history
…SMCA No Take
  • Loading branch information
avmey committed Jan 24, 2025
1 parent 79f25e5 commit b175e8b
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 595 deletions.
12 changes: 5 additions & 7 deletions src/components/Classification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
RbcsIcon,
GroupPill,
useSketchProperties,
Pill,
VerticalSpacer,
} from "@seasketch/geoprocessing/client-ui";
import {
Expand All @@ -19,7 +18,6 @@ import {
NullSketchCollection,
Metric,
toNullSketchArray,
getUserAttribute,
} from "@seasketch/geoprocessing/client-core";
import { styled } from "styled-components";
import { Trans, useTranslation } from "react-i18next";
Expand Down Expand Up @@ -106,8 +104,6 @@ const sketchReport = (metrics: Metric[], t: any) => {
"In single sketch classification report, and getting !=1 metric",
);

const [{ proposed_lop }] = useSketchProperties();

return (
<>
<div
Expand All @@ -127,8 +123,6 @@ const sketchReport = (metrics: Metric[], t: any) => {
/>
</div>
<VerticalSpacer />
This MPA's level of protection is: <Pill>{lopMap[proposed_lop]}</Pill>
<VerticalSpacer />
<Collapse title={t("Learn More")}>
<ClassificationLearnMore t={t} />
</Collapse>
Expand Down Expand Up @@ -203,7 +197,11 @@ const genMpaSketchTable = (sketches: NullSketch[], t: any) => {
groupColorMap={groupColorMapTransparent}
group={designation}
>
{designation === "Special" ? "Special Closure" : designation}
{designation === "Special"
? "Special Closure"
: designation === "SMCANT"
? "SMCA No-Take"
: designation}
</GroupPill>
);
},
Expand Down
49 changes: 0 additions & 49 deletions src/components/Eelgrass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import { Trans, useTranslation } from "react-i18next";
import {
ClassTable,
Collapse,
ObjectiveStatus,
ReportError,
ResultsCard,
useSketchProperties,
} from "@seasketch/geoprocessing/client-ui";
import {
GeogProp,
Metric,
MetricGroup,
firstMatchingMetric,
metricsWithSketchId,
roundDecimal,
squareMeterToMile,
Expand Down Expand Up @@ -88,13 +85,6 @@ export const Eelgrass: React.FunctionComponent<GeogProp> = (props) => {
</p>
</Trans>

{!isCollection && (
<EelgrassObjectives
metricGroup={metricGroup}
metrics={valueMetrics.filter((m) => m.geographyId === "world")}
/>
)}

<ClassTable
rows={metrics.filter((m) => m.geographyId === "world")}
metricGroup={metricGroup}
Expand Down Expand Up @@ -250,7 +240,6 @@ export const Eelgrass: React.FunctionComponent<GeogProp> = (props) => {
precalcMetrics.filter((m) => m.geographyId === "world"),
metricGroup,
t,
{ replicate: true, replicateMap: { eelgrass: 0.04 } },
)}
</Collapse>
)}
Expand All @@ -275,41 +264,3 @@ export const Eelgrass: React.FunctionComponent<GeogProp> = (props) => {
</ResultsCard>
);
};

const EelgrassObjectives = (props: {
metricGroup: MetricGroup;
metrics: Metric[];
}) => {
const { metricGroup, metrics } = props;
const replicateMap: Record<string, number> = { eelgrass: 0.12 };

// Get habitat replicates passes and fails for this MPA
const { passes, fails } = metricGroup.classes.reduce(
(acc: { passes: string[]; fails: string[] }, curClass) => {
const metric = firstMatchingMetric(
metrics,
(m) => m.classId === curClass.classId,
);
if (!metric) throw new Error(`Expected metric for ${curClass.classId}`);

const value = squareMeterToMile(metric.value);
const replicateValue = replicateMap[curClass.classId];

value > replicateValue || (!replicateValue && value)
? acc.passes.push(curClass.display)
: acc.fails.push(curClass.display);

return acc;
},
{ passes: [], fails: [] },
);

return (
<>
{passes.length > 0 && (
<ObjectiveStatus status={"yes"} msg={<>Eelgrass replicate</>} />
)}
{fails.length > 0 && <></>}
</>
);
};
46 changes: 0 additions & 46 deletions src/components/Estuaries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ export const Estuaries: React.FunctionComponent<GeogProp> = (props) => {
</p>
</Trans>

{!isCollection && (
<EstuariesObjectives
metricGroup={metricGroup}
metrics={valueMetrics.filter((m) => m.geographyId === "world")}
/>
)}

<ClassTable
rows={metrics.filter((m) => m.geographyId === "world")}
metricGroup={metricGroup}
Expand Down Expand Up @@ -246,7 +239,6 @@ export const Estuaries: React.FunctionComponent<GeogProp> = (props) => {
precalcMetrics.filter((m) => m.geographyId === "world"),
metricGroup,
t,
{ replicate: true, replicateMap: { estuaries: 0.12 } },
)}
</Collapse>
)}
Expand All @@ -271,41 +263,3 @@ export const Estuaries: React.FunctionComponent<GeogProp> = (props) => {
</ResultsCard>
);
};

const EstuariesObjectives = (props: {
metricGroup: MetricGroup;
metrics: Metric[];
}) => {
const { metricGroup, metrics } = props;
const replicateMap: Record<string, number> = { estuaries: 0.12 };

// Get habitat replicates passes and fails for this MPA
const { passes, fails } = metricGroup.classes.reduce(
(acc: { passes: string[]; fails: string[] }, curClass) => {
const metric = firstMatchingMetric(
metrics,
(m) => m.classId === curClass.classId,
);
if (!metric) throw new Error(`Expected metric for ${curClass.classId}`);

const value = squareMeterToMile(metric.value);
const replicateValue = replicateMap[curClass.classId];

value > replicateValue || (!replicateValue && value)
? acc.passes.push(curClass.display)
: acc.fails.push(curClass.display);

return acc;
},
{ passes: [], fails: [] },
);

return (
<>
{passes.length > 0 && (
<ObjectiveStatus status={"yes"} msg={<>Estuaries replicate</>} />
)}
{fails.length > 0 && <></>}
</>
);
};
117 changes: 0 additions & 117 deletions src/components/Habitat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ClassTable,
Collapse,
LayerToggle,
ObjectiveStatus,
ReportError,
ResultsCard,
useSketchProperties,
Expand All @@ -13,8 +12,6 @@ import {
import {
GeogProp,
Metric,
MetricGroup,
firstMatchingMetric,
metricsWithSketchId,
roundDecimal,
squareMeterToMile,
Expand Down Expand Up @@ -81,8 +78,6 @@ export const Habitat: React.FunctionComponent<GeogProp> = (props) => {

const metrics = [...valueMetrics, ...percMetrics];

console.log(metrics);

const objectives = (() => {
const objectives = project.getMetricGroupObjectives(metricGroup, t);
if (!objectives.length) return undefined;
Expand Down Expand Up @@ -117,13 +112,6 @@ export const Habitat: React.FunctionComponent<GeogProp> = (props) => {
/>
<VerticalSpacer />

{!isCollection && (
<SubstrateObjectives
metricGroup={metricGroup}
metrics={valueMetrics.filter((m) => m.geographyId === "world")}
/>
)}

<ClassTable
rows={metrics.filter((m) => m.geographyId === "world")}
metricGroup={metricGroup}
Expand Down Expand Up @@ -304,15 +292,6 @@ export const Habitat: React.FunctionComponent<GeogProp> = (props) => {
{
valueFormatter: (val) =>
val * 9.710648864705849093 * 9.710648864705849093,
replicate: true,
replicateMap: {
32: 7,
102: 17,
202: 17,
31: 0.13,
101: 0.13,
201: 0.13,
},
},
)}
</Collapse>
Expand All @@ -339,99 +318,3 @@ export const Habitat: React.FunctionComponent<GeogProp> = (props) => {
</ResultsCard>
);
};

const SubstrateObjectives = (props: {
metricGroup: MetricGroup;
metrics: Metric[];
}) => {
const replicateMap = {
32: 7,
102: 17,
31: 0.13,
101: 0.13,
};
const { metricGroup, metrics } = props;

const substrate31Replicate = (() => {
const metric = firstMatchingMetric(metrics, (m) => m.classId === "31");
if (!metric) throw new Error(`Expected metric for substrate31`);
return (
squareMeterToMile(
metric.value * 9.710648864705849093 * 9.710648864705849093,
) > replicateMap["31"]
);
})();
const substrate32Replicate = (() => {
const metric = firstMatchingMetric(metrics, (m) => m.classId === "32");
if (!metric) throw new Error(`Expected metric for substrate32`);
return (
squareMeterToMile(
metric.value * 9.710648864705849093 * 9.710648864705849093,
) > replicateMap["32"]
);
})();

const substrate101Replicate = (() => {
const metric101 = firstMatchingMetric(metrics, (m) => m.classId === "101");
const metric201 = firstMatchingMetric(metrics, (m) => m.classId === "201");
if (!metric101 || !metric201)
throw new Error(`Expected metric for substrate31`);
return (
squareMeterToMile(
(metric101.value + metric201.value) *
9.710648864705849093 *
9.710648864705849093,
) > replicateMap["101"]
);
})();
const substrate102Replicate = (() => {
const metric102 = firstMatchingMetric(metrics, (m) => m.classId === "102");
const metric202 = firstMatchingMetric(metrics, (m) => m.classId === "202");
if (!metric102 || !metric202)
throw new Error(`Expected metric for substrate31`);
return (
squareMeterToMile(
(metric102.value + metric202.value) *
9.710648864705849093 *
9.710648864705849093,
) > replicateMap["102"]
);
})();

return (
<>
{substrate31Replicate ? (
<ObjectiveStatus
status={"yes"}
msg={<>Hard substrate (30-100m) replicate</>}
/>
) : (
<></>
)}
{substrate32Replicate ? (
<ObjectiveStatus
status={"yes"}
msg={<>Soft substrate (30-100m) replicate</>}
/>
) : (
<></>
)}
{substrate101Replicate ? (
<ObjectiveStatus
status={"yes"}
msg={<>Hard substrate (&gt;100m) replicate</>}
/>
) : (
<></>
)}
{substrate102Replicate ? (
<ObjectiveStatus
status={"yes"}
msg={<>Soft substrate (&gt;100m) replicate</>}
/>
) : (
<></>
)}
</>
);
};
Loading

0 comments on commit b175e8b

Please sign in to comment.