Skip to content

Commit

Permalink
Simplify Canada check for permafrost section.
Browse files Browse the repository at this point in the history
  • Loading branch information
cstephen committed Nov 21, 2023
1 parent 426a5ad commit f8c59ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
8 changes: 4 additions & 4 deletions components/Report.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<a href="#hydrology">Hydrology</a> charts with multiple variables,
models, and scenarios, grouped decadally and by month of the year.
</li>
<li v-if="permafrostData || showPermafrost">
<li v-if="permafrostData || forceShowPermafrost">
<a href="#permafrost">Permafrost</a> with specific visualizations
depending on the presence or absence of permafrost
</li>
Expand Down Expand Up @@ -236,7 +236,7 @@
<strong>Elevation:</strong>
{{ httpErrors[elevationHttpError] }}
</li>
<li v-if="permafrostHttpError && !showPermafrost">
<li v-if="permafrostHttpError && !forceShowPermafrost">
<strong>Permafrost:</strong>
{{ httpErrors[permafrostHttpError] }}
</li>
Expand Down Expand Up @@ -273,7 +273,7 @@
</section>
<section
class="section is-hidden-touch"
v-if="permafrostData || (dataPresent && showPermafrost)"
v-if="permafrostData || (dataPresent && forceShowPermafrost)"
>
<div id="permafrost">
<PermafrostReport />
Expand Down Expand Up @@ -481,7 +481,7 @@ export default {
beetleHttpError: 'beetle/httpError',
hydrologyHttpError: 'hydrology/httpError',
isPointLocation: 'place/isPointLocation',
showPermafrost: 'permafrost/showPermafrost',
forceShowPermafrost: 'permafrost/forceShowPermafrost',
}),
},
// This component initiates the data fetching so that
Expand Down
36 changes: 15 additions & 21 deletions store/permafrost.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,24 @@ export const getters = {
return !permafrosttopValues.every(value => value === 0)
},

showPermafrost: (state, getters, rootState, rootGetters) => {
let communityId = rootGetters['place/communityId']
let latLng = rootGetters['place/latLng']
forceShowPermafrost: (state, getters, rootState, rootGetters) => {
let areaId = rootGetters['place/areaId']

// We do not have permafrost data for Canada, so don't show permafrost
// section for Canadian communities, Canadian protected areas, First Nation
// Traditional Territories, or lat/lon points that are approximately
// Canadian.
if (communityId && !communityId.startsWith('AK')) {
return false
} else if (
areaId &&
(areaId.startsWith('BCPA') ||
// Always show permafrost section for area reports unless the areas are
// Canadian. I.e., do not show permafrost for these area code prefixes:
// BCPA: British Columbia Protected Areas
// FNTT: First Nation Traditional Territories
// YTPA: Yukon Protected Areas
if (areaId) {
if (
areaId.startsWith('BCPA') ||
areaId.startsWith('FNTT') ||
areaId.startsWith('YTPA'))
) {
return false
} else if (latLng && latLng[0] > 60 && latLng[1] > -141.1) {
return false
} else if (latLng && latLng[0] < 60 && latLng[1] > -129.9) {
return false
} else {
return true
areaId.startsWith('YTPA')
) {
return false
} else {
return true
}
}
},
}
Expand Down

0 comments on commit f8c59ce

Please sign in to comment.