Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE][GWELLS-2051] Added "Well - aquifer parameters" filter on the map on Aquifer Summary page and Aquifer Search Page #2144

Merged
merged 13 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

from django.db import migrations

UPDATE_GWELLS_WELLS_VIEW_SQL = """
DROP VIEW postgis_ftw.gwells_well_view;
CREATE VIEW postgis_ftw.gwells_well_view AS
SELECT
well_tag_number,
aquifer_id,
artesian_conditions AS artesian,
COALESCE
(hydraulic_conductivity::text, transmissivity::text, storativity::text)
IS NOT NULL
as has_hydraulic_info,
street_address,
identification_plate_number,
observation_well_number,
obs_well_status_code AS observation_well_status_code,
ems,
well_publication_status_code = 'Published' AS is_published,
geom,
EXISTS (
SELECT 1
FROM aquifer_parameters
WHERE aquifer_parameters.well_tag_number = well.well_tag_number
) as has_aquifer_parameters
FROM well
WHERE geom IS NOT NULL;
GRANT SELECT ON postgis_ftw.gwells_well_view TO ftw_reader;
"""

class Migration(migrations.Migration):
"""
This migration adds the field 'has_aquifer_parameters' to the gwells_well_view
under the postgis_ftw schema in the gwells database. The purpose of this field
is to check whether there is existing pump test/aquifer parameter data for a well, and then display
a different well icon on the well search map if this data exists.
"""
dependencies = [
('wells', '0145_auto_20231127_2105'),
]

operations = [
migrations.RunSQL(
UPDATE_GWELLS_WELLS_VIEW_SQL
)
]
32 changes: 24 additions & 8 deletions app/frontend/src/aquifers/components/AquiferMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ import {
WELLS_SOURCE,
AQUIFERS_SOURCE,
observationWellsLayer,
WELLS_OBSERVATION_LAYER_ID
WELLS_OBSERVATION_LAYER_ID,
WELLS_AQUIFER_PARAMETER_LAYER_ID,
wellsAquiferParameters,
} from '../../common/mapbox/layers'
import {
LayersControl,
Expand All @@ -68,7 +70,8 @@ import {
createAquiferPopupElement,
createWellPopupElement,
createEcocatPopupElement,
createWaterLicencePopupElement
createWaterLicencePopupElement,
createWellAquiferParametersPopupElement
} from '../popup'

import cadastralLegendSrc from '../../common/assets/images/cadastral.png'
Expand Down Expand Up @@ -146,13 +149,15 @@ export default {
{
imageSrc: wellsArtesianLegendSrc,
label: 'artesian'
},
{
imageSrc: wellsHydraulicLegendSrc,
label: 'aquifer parameters'
}
]
},
{
show: false,
id: WELLS_AQUIFER_PARAMETER_LAYER_ID,
label: 'Wells - aquifer parameters',
imageSrc: wellsHydraulicLegendSrc
},
{
show: false,
id: WELLS_OBSERVATION_LAYER_ID,
Expand Down Expand Up @@ -312,6 +317,10 @@ export default {
[WELLS_BASE_AND_ARTESIAN_LAYER_ID]: {
snapToCenter: true,
createTooltipContent: this.createWellPopupElement
},
[WELLS_AQUIFER_PARAMETER_LAYER_ID]: {
snapToCenter: true,
createTooltipContent: this.createWellPopupElement
}
}

Expand Down Expand Up @@ -349,7 +358,8 @@ export default {
surfaceWaterLicencesLayer({ layout: { visibility: 'none' } }),
groundWaterLicencesLayer({ layout: { visibility: 'none' } }),
wellsBaseAndArtesianLayer({ layout: { visibility: 'none' }, filter: wellLayerFilter(this.showUnpublishedWells) }),
observationWellsLayer({ layout: { visibility: 'none' } })
observationWellsLayer({ layout: { visibility: 'none' } }),
wellsAquiferParameters({ layout: { visibility: 'none' } })
]
}
},
Expand Down Expand Up @@ -468,7 +478,13 @@ export default {
createWellPopupElement (features, { canInteract }) {
return createWellPopupElement(features, this.map, this.$router, {
canInteract,
wellLayerIds: [ WELLS_BASE_AND_ARTESIAN_LAYER_ID, WELLS_OBSERVATION_LAYER_ID ]
wellLayerIds: [ WELLS_BASE_AND_ARTESIAN_LAYER_ID, WELLS_OBSERVATION_LAYER_ID, WELLS_AQUIFER_PARAMETER_LAYER_ID ]
})
},
createWellAquiferParametersPopupElement (features, { canInteract }) {
return createWellAquiferParametersPopupElement(features, this.map, this.$router, {
canInteract,
wellLayerIds: [ WELLS_AQUIFER_PARAMETER_LAYER_ID]
})
},
createEcocatPopupElement (features, { canInteract }) {
Expand Down
24 changes: 18 additions & 6 deletions app/frontend/src/aquifers/components/SingleAquiferMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
wellsEmsLayer,
wellsUncorrelatedLayer,
wellsBaseAndArtesianLayer,
wellsAquiferParameters,
aquifersLineLayer,
aquifersFillLayer,
setupAquiferHover,
Expand All @@ -44,6 +45,7 @@ import {
DATABC_ECOCAT_SOURCE_ID,
AQUIFERS_FILL_LAYER_ID,
WELLS_BASE_AND_ARTESIAN_LAYER_ID,
WELLS_AQUIFER_PARAMETER_LAYER_ID,
WELLS_EMS_LAYER_ID,
WELLS_UNCORRELATED_LAYER_ID,
aquiferLayerFilter,
Expand All @@ -56,7 +58,9 @@ import {
WELLS_SOURCE,
AQUIFERS_SOURCE,
observationWellsLayer,
WELLS_OBSERVATION_LAYER_ID
WELLS_OBSERVATION_LAYER_ID,


} from '../../common/mapbox/layers'
import { computeBoundsFromMultiPolygon } from '../../common/mapbox/geometry'
import { LayersControl, LegendControl } from '../../common/mapbox/controls'
Expand Down Expand Up @@ -134,13 +138,15 @@ export default {
{
imageSrc: wellsArtesianLegendSrc,
label: 'artesian'
},
{
imageSrc: wellsHydraulicLegendSrc,
label: 'aquifer parameters'
}
]
},
{
show: true,
id: WELLS_AQUIFER_PARAMETER_LAYER_ID,
label: 'Wells - aquifer parameters',
imageSrc: wellsHydraulicLegendSrc
},
{
show: false,
id: WELLS_OBSERVATION_LAYER_ID,
Expand Down Expand Up @@ -274,6 +280,10 @@ export default {
[WELLS_UNCORRELATED_LAYER_ID]: {
snapToCenter: true,
createTooltipContent: this.createWellPopupElement
},
[WELLS_AQUIFER_PARAMETER_LAYER_ID]: {
snapToCenter: true,
createTooltipContent: this.createWellPopupElement
}
}
setupFeatureTooltips(this.map, tooltipLayers)
Expand Down Expand Up @@ -317,6 +327,7 @@ export default {
surfaceWaterLicencesLayer({ layout: { visibility: 'none' } }),
groundWaterLicencesLayer({ layout: { visibility: 'none' } }),
wellsBaseAndArtesianLayer(),
wellsAquiferParameters(),
observationWellsLayer({ layout: { visibility: 'none' } }),
wellsEmsLayer({ layout: { visibility: 'none' } }),
wellsUncorrelatedLayer({ layout: { visibility: 'none' } })
Expand Down Expand Up @@ -425,7 +436,8 @@ export default {
WELLS_BASE_AND_ARTESIAN_LAYER_ID,
WELLS_OBSERVATION_LAYER_ID,
WELLS_UNCORRELATED_LAYER_ID,
WELLS_EMS_LAYER_ID
WELLS_EMS_LAYER_ID,
WELLS_AQUIFER_PARAMETER_LAYER_ID
]
})
},
Expand Down
4 changes: 2 additions & 2 deletions app/frontend/src/aquifers/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
AQUIFERS_FILL_LAYER_ID,
DATABC_ECOCAT_LAYER_ID,
DATABC_GROUND_WATER_LICENCES_LAYER_ID,
DATABC_SURFACE_WATER_LICENCES_LAYER_ID
DATABC_SURFACE_WATER_LICENCES_LAYER_ID,
WELLS_AQUIFER_PARAMETER_LAYER_ID
} from '../common/mapbox/layers'
import { popupItems, popupItem } from '../common/mapbox/popup'

Expand Down Expand Up @@ -132,7 +133,6 @@ export function createAquiferPopupElement (features, map, $router, options = {})

return container
}

// Creates a <div> for the ecocat's popup content
export function createEcocatPopupElement (features, map, options = {}) {
const canInteract = Boolean(options.canInteract)
Expand Down
20 changes: 16 additions & 4 deletions app/frontend/src/common/mapbox/layers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const VECTOR_TILE_SERVER = `${window.location.protocol}//${window.location.host}

export const WELLS_SOURCE_ID = 'postgis_ftw.gwells_well_view'
export const WELLS_BASE_AND_ARTESIAN_LAYER_ID = 'wells-with-artesian'
export const WELLS_AQUIFER_PARAMETER_LAYER_ID = 'wells-with-aquifer-parameters'
export const WELLS_UNCORRELATED_LAYER_ID = 'wells-uncorrelated'
export const WELLS_EMS_LAYER_ID = 'wells-ems'
export const WELLS_OBSERVATION_LAYER_ID = 'wells-observation'
Expand Down Expand Up @@ -283,7 +284,6 @@ export function wellsBaseAndArtesianLayer (options = {}) {
'circle-radius': 3,
'circle-stroke-color': [
'case',
['boolean', ['get', 'has_hydraulic_info']], '#5dfa57',
['to-boolean', ['get', 'artesian']], '#EE14CA',
'transparent'
],
Expand All @@ -294,7 +294,22 @@ export function wellsBaseAndArtesianLayer (options = {}) {

return vectorLayerConfig(layerId, options.source || WELLS_SOURCE_ID, options.layerType || 'circle', styles, options.layout, filter)
}
// Builds MapBox layer config object for wells with aquifer parameters with a green outline
export function wellsAquiferParameters (options = {}) {
const layerId = options.id || WELLS_AQUIFER_PARAMETER_LAYER_ID
const styles = defaultsDeep(options.styles, {
'circle-color' : '#0162FE',
'circle-radius' : 3,
'circle-stroke-color': '#5dfc00',
'circle-stroke-width': 2.5
})

const filter = [
'to-boolean', ['get', 'has_aquifer_parameters']
]

return vectorLayerConfig(layerId, options.source || WELLS_SOURCE_ID, options.layerType || 'circle', styles, options.layout, filter)
}
// Builds MapBox layer config object for searched wells with artesian ones with a fuchsia outline
export function searchedWellsLayer (options = {}) {
const layerId = options.id || SEARCHED_WELLS_LAYER_ID
Expand All @@ -307,9 +322,6 @@ export function searchedWellsLayer (options = {}) {
'circle-radius': 5,
'circle-stroke-color': [
'case',
['to-boolean', ['get', 'storativity']], '#5dfa57',
['to-boolean', ['get', 'transmissivity']], '#5dfa57',
['to-boolean', ['get', 'hydraulic_conductivity']], '#5dfa57',
['to-boolean', ['get', 'artesian_conditions']], '#EE14CA',
'black'
],
Expand Down
Loading