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] Code With Us QaQc Dashboard Dec 2023 #2109

Merged
merged 35 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e6c3917
feat: qaqc dashboard tables wip
Dec 20, 2023
00fa993
feat: updated cross ref, and record compliance tables
Dec 21, 2023
c161591
feat: mis located wells added, qaqc data processing scripts added
Jan 10, 2024
d9f2e2d
chore: code cleanup
Jan 10, 2024
cb7d88d
chore: code cleanup, batch migration update
Jan 12, 2024
4b72639
chore: warning fix on logging
Jan 12, 2024
44cdcaf
chore: warning fix on logging
Jan 12, 2024
36f6bdb
chore: version fixes
Jan 15, 2024
bde2edf
chore: migration fix
Jan 15, 2024
768805e
feat: updated cql filters, code cleanup
Jan 18, 2024
d3320d9
chore: debug cleanup
Jan 18, 2024
86718b9
fix: updated cql filters
Jan 18, 2024
bd6575d
feat: updated qaqc filters to use custom filtering and nullchecks
Feb 2, 2024
7ac3ff1
feat: updated filters for all fields, null checks finished
Feb 2, 2024
85ba5a2
fix: link rel fix
Feb 2, 2024
2ad96ce
fix: well link fix
Feb 2, 2024
39fecdc
fix: minor bug fixes
Feb 4, 2024
0d8e4a2
feat: updated filters from ba feedback, additional cross reference fi…
Feb 18, 2024
e84eea0
feat: updated additional filters, signal setup to set cross reference…
Feb 20, 2024
70f9bd8
feat: added testing settings for conditional signal
Feb 20, 2024
f038597
fix: migration order fixed
Feb 20, 2024
73788c0
fix: migration order fix
Feb 20, 2024
1ff72af
fix: migration fixes
Feb 20, 2024
e36020b
feat: filter optimizations, activity type fixes
Feb 20, 2024
10d16b1
chore: cleanup table and filters
Feb 20, 2024
da17ef5
feat: updated logic for mislocated well calculations
Feb 25, 2024
e5cc28c
feat: natural region dropdown, hid sorting for lat lon, cross ref loo…
Feb 25, 2024
cde04d0
feat: updated cross referencing logic, updated sorting on calculated …
Feb 26, 2024
b803d0a
feat: updated distance max digits, serializer fixes, tooltip updates
Feb 29, 2024
152c0de
feat: added custom download views for 3 qaqc tables
Feb 29, 2024
fa5acce
chore: code cleanup
Feb 29, 2024
e28d5d2
feat: updated sorting for well subclass, x-ref date fix, geocode defa…
Mar 3, 2024
a364d13
feat: filter updates for well subclass, minor edits from client
Mar 7, 2024
ad20e73
feat: updated qaqc geocode distance values in seeder data
Mar 7, 2024
72b7f32
fix: updated null field value for well_subclass
Mar 9, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*.tar
*.zip
!regional_areas.zip
!qaqc_well_data.zip

# Logs and databases #
######################
Expand Down
32 changes: 28 additions & 4 deletions app/backend/aquifers/fixtures/aquifers.json
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,13 @@
"hydro_fracturing_yield_increase": null,
"decommission_sealant_material": "CONCRETE",
"decommission_backfill_material": "test",
"geom": "POINT(-125.376319 52.528545)"
"geom": "POINT(-125.376319 52.528545)",
"distance_to_pid": "123.45",
"geocode_distance": "543.21",
"score_address": "78.90",
"score_city": "56.78",
"cross_referenced": false,
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -1124,7 +1130,13 @@
"hydro_fracturing_yield_increase": null,
"decommission_sealant_material": "CONCRETE",
"decommission_backfill_material": "test",
"geom": "POINT(-125.351850 52.461419)"
"geom": "POINT(-125.351850 52.461419)",
"distance_to_pid": "234.56",
"geocode_distance": "654.32",
"score_address": "89.01",
"score_city": "67.89",
"cross_referenced": true,
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -1249,7 +1261,13 @@
"hydro_fracturing_yield_increase": null,
"decommission_sealant_material": "CONCRETE",
"decommission_backfill_material": "test",
"geom": "POINT(-125.361842 52.476454)"
"geom": "POINT(-125.361842 52.476454)",
"distance_to_pid": "345.67",
"geocode_distance": "765.43",
"score_address": "90.12",
"score_city": "78.90",
"cross_referenced": false,
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -1373,7 +1391,13 @@
"hydro_fracturing_yield_increase": null,
"decommission_sealant_material": "CONCRETE",
"decommission_backfill_material": "test",
"geom": "POINT(-125.381245 52.466459)"
"geom": "POINT(-125.381245 52.466459)",
"distance_to_pid": "456.78",
"geocode_distance": "876.54",
"score_address": "12.34",
"score_city": "89.01",
"cross_referenced": true,
"natural_resource_region": "Northeast"
}
},
{
Expand Down
50 changes: 44 additions & 6 deletions app/backend/gwells/fixtures/wellsearch.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,15 @@
"decommission_method": null,
"decommission_details": null,
"water_quality_characteristics": [],
"geom": "POINT(-122.540000 49.260000)"
"geom": "POINT(-122.540000 49.260000)",
"distance_to_pid": "123.45",
"geocode_distance": "543.21",
"score_address": "78.90",
"score_city": "56.78",
"cross_referenced": false,
"cross_referenced_date": "2023-02-08T17:06:47.229Z",
"cross_referenced_by": "DATA_LOAD_USER",
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -966,7 +974,13 @@
"drawdown": "190.00",
"hydro_fracturing_performed": false,
"hydro_fracturing_yield_increase": null,
"geom": "POINT(-122.540000 49.200000)"
"geom": "POINT(-122.540000 49.200000)",
"distance_to_pid": "234.56",
"geocode_distance": "654.32",
"score_address": "89.01",
"score_city": "67.89",
"cross_referenced": true,
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -1087,7 +1101,13 @@
"drawdown": null,
"hydro_fracturing_performed": false,
"hydro_fracturing_yield_increase": null,
"geom": "POINT(-122.580000 49.230000)"
"geom": "POINT(-122.580000 49.230000)",
"distance_to_pid": "345.67",
"geocode_distance": "765.43",
"score_address": "90.12",
"score_city": "78.90",
"cross_referenced": false,
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -1208,7 +1228,13 @@
"drawdown": null,
"hydro_fracturing_performed": false,
"hydro_fracturing_yield_increase": null,
"geom": "POINT(-122.590000 49.250000)"
"geom": "POINT(-122.590000 49.250000)",
"distance_to_pid": "456.78",
"geocode_distance": "876.54",
"score_address": "12.34",
"score_city": "89.01",
"cross_referenced": true,
"natural_resource_region": "Northeast"
}
},
{
Expand Down Expand Up @@ -1332,7 +1358,13 @@
"hydro_fracturing_yield_increase": null,
"decommission_sealant_material": "CONCRETE",
"decommission_backfill_material": "test",
"geom": "POINT(-125.360830 52.456449)"
"geom": "POINT(-125.360830 52.456449)",
"distance_to_pid": "567.89",
"geocode_distance": "987.65",
"score_address": "23.45",
"score_city": "90.12",
"cross_referenced": false,
"natural_resource_region": "South Coast"
}
},
{
Expand Down Expand Up @@ -1479,7 +1511,13 @@
],
"decommission_backfill_material": null,
"decommission_sealant_material": null,
"geom": null
"geom": null,
"distance_to_pid": "678.90",
"geocode_distance": "109.87",
"score_address": "34.56",
"score_city": "12.34",
"cross_referenced": true,
"natural_resource_region": "Kootenay"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions app/backend/gwells/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
import sys
import datetime
import logging.config
from pathlib import Path
Expand All @@ -23,6 +24,7 @@

BASE_DIR = str(Path(__file__).parents[2])

TESTING = len(sys.argv) > 1 and sys.argv[1] == 'test'

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
Expand Down
71 changes: 30 additions & 41 deletions app/backend/gwells/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,48 @@ def isPointInsideBC(latitude, longitude):
return False


def geocode_bc_location(options={}):
"""
Makes an HTTP call to the BC Physical Address Geocoder API
(https://www2.gov.bc.ca/gov/content/data/geographic-data-services/location-services/geocoder)
using any options provided as query string parameters. (the 'options'
parameter supports any query string parameter supported by the "addresses.json"
endpoint.
If the address is successfully geocoded then this method returns a
django.contrib.gis.geos.Point object corresponding to the first result.
If a HTTP error occurs during
communication with the remote API then an HTTPError exception is
raised. If the API call succeeds but does not find a coordinate
matching the given address_string, then a ValueError is raised.
:param options: typical options are:
{
"addressString": "101 main st.",
"localityName": "Kelowna"
}
"""
def setup_parameters(options):
default_options = {
"provinceCode": "BC",
"outputSRS": 4326,
"maxResults": 1,
"minScore": 65
"provinceCode": "BC",
"outputSRS": 4326,
"maxResults": 1,
"minScore": 65
}
params = {}
params.update(default_options)
params.update(options)
return {**default_options, **options}

url = "https://geocoder.api.gov.bc.ca/addresses.json"

def perform_api_request(url, params):
try:
resp = requests.get(url, params=params, timeout=10)
resp.raise_for_status()
except HTTPError as e:
#caught and re-raised to be clear ane explicit which exceptions
#this method may cause
return resp
except requests.HTTPError as e:
raise e

features = []

try:
features = resp.json().get('features')
except AttributeError as e:
def process_response(response):
try:
features = response.json().get('features')
if not features:
raise ValueError("Unable to geocode address")
return features[0]
except AttributeError:
raise ValueError("Unable to geocode address")

if not len(features):
raise ValueError("Unable to geocode address")

first_feature = features[0]
def geocode_bc_location(options={}):
"""
Performs an HTTP request to the BC Physical Address Geocoder API,
returning a django.contrib.gis.geos.Point for the first result. Supports query
string parameters via the 'options' argument. Raises HTTPError for
communication issues and ValueError if no matching coordinate is found.
Example 'options': {"addressString": "101 main st.", "localityName": "Kelowna"}.
"""
params = setup_parameters(options)
url = "https://geocoder.api.gov.bc.ca/addresses.json"
response = perform_api_request(url, params)
first_feature = process_response(response)

try:
point = GEOSGeometry(json.dumps(first_feature.get("geometry", {})))
except TypeError as e:
except TypeError:
raise ValueError("Unable to geocode address")

return point
3 changes: 3 additions & 0 deletions app/backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ geojson==2.4.1
MarkupSafe>=2.0.1
djangorestframework-simplejwt==4.4.0
pyjwt>=2.0,<=2.4.0
thefuzz==0.19.0
geopandas==0.9.0
pyproj==3.0.1
2 changes: 2 additions & 0 deletions app/backend/wells/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ class WellsConfig(AppConfig):

def ready(self):
post_migrate.connect(post_migration_callback, sender=self)
import wells.signals #noqa
import wells.utils #noqa
33 changes: 33 additions & 0 deletions app/backend/wells/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,36 @@
WELL_TAGS = []
WELL_TAGS.extend(WELL_TAGS_PUBLIC.copy())
WELL_TAGS.extend(WELL_TAGS_PRIVATE.copy())

# bc geocoder endpoint of interest
GEOCODER_ENDPOINT = "https://geocoder.api.gov.bc.ca/sites/nearest.json"
ADDRESS_COLUMNS = [
"fullAddress",
"siteName",
"unitDesignator",
"unitNumber",
"unitNumberSuffix",
"civicNumber",
"civicNumberSuffix",
"streetName",
"streetType",
"isStreetTypePrefix",
"streetDirection",
"isStreetDirectionPrefix",
"streetQualifier",
"localityName",
"localityType",
"electoralArea",
"provinceCode",
"locationPositionalAccuracy",
"locationDescriptor",
"siteID",
"blockID",
"fullSiteDescriptor",
"accessNotes",
"siteStatus",
"siteRetireDate",
"changeDate",
"isOfficial",
"distance",
]
Loading
Loading