Skip to content

Commit

Permalink
Top Bedrock Quality Fields als Input (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschumpr authored Dec 6, 2023
2 parents 2db6e5b + 662e746 commit 5b1696d
Show file tree
Hide file tree
Showing 20 changed files with 4,489 additions and 1,926 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Upgraded to OpenLayers 8.
- Upgraded to .NET 8.
- Upgraded to Node 20.
- Use numeric input instead of dropdown for top bedrock quality fields.

## v2.0.452 - 2023-07-05

Expand Down
26 changes: 18 additions & 8 deletions src/api-legacy/v1/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,11 +1039,16 @@ def filterBorehole(self, filter={}):
top_bedrock_bho <= %s
""" % self.getIdx())

if 'qt_top_bedrock' in keys and filter[
'qt_top_bedrock'] not in ['', None]:
params.append(int(filter['qt_top_bedrock']))
if 'qt_top_bedrock_from' in keys and filter['qt_top_bedrock_from'] not in ['', None]:
params.append(float(filter['qt_top_bedrock_from']))
where.append("""
qt_top_bedrock_id_cli = %s
qt_top_bedrock >= %s
""" % self.getIdx())

if 'qt_top_bedrock_to' in keys and filter['qt_top_bedrock_to'] not in ['', None]:
params.append(float(filter['qt_top_bedrock_to']))
where.append("""
qt_top_bedrock <= %s
""" % self.getIdx())

if 'top_bedrock_tvd_from' in keys and filter['top_bedrock_tvd_from'] not in ['', None]:
Expand All @@ -1058,11 +1063,16 @@ def filterBorehole(self, filter={}):
top_bedrock_tvd_bho <= %s
""" % self.getIdx())

if 'qt_top_bedrock_tvd' in keys and filter[
'qt_top_bedrock_tvd'] not in ['', None]:
params.append(int(filter['qt_top_bedrock_tvd']))
if 'qt_top_bedrock_tvd_from' in keys and filter['qt_top_bedrock_tvd_from'] not in ['', None]:
params.append(float(filter['qt_top_bedrock_tvd_from']))
where.append("""
qt_top_bedrock_tvd >= %s
""" % self.getIdx())

if 'qt_top_bedrock_tvd_to' in keys and filter['qt_top_bedrock_tvd_to'] not in ['', None]:
params.append(float(filter['qt_top_bedrock_tvd_to']))
where.append("""
qt_top_bedrock_tvd_id_cli = %s
qt_top_bedrock_tvd <= %s
""" % self.getIdx())

if 'lithology_top_bedrock' in keys and filter[
Expand Down
9 changes: 4 additions & 5 deletions src/api-legacy/v1/borehole/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ async def execute(self, borehole, workgroup, user):
qt_inclination_direction_id_cli,
qt_depth_id_cli,
top_bedrock_bho,
qt_top_bedrock_id_cli,
qt_top_bedrock,
top_bedrock_tvd_bho,
qt_top_bedrock_tvd_id_cli,
qt_top_bedrock_tvd,
groundwater_bho,
--geom_bho,
remarks_bho,
Expand Down Expand Up @@ -92,10 +92,9 @@ async def execute(self, borehole, workgroup, user):
qt_inclination_direction_id_cli,
qt_depth_id_cli,
top_bedrock_bho,
qt_top_bedrock_id_cli,
qt_top_bedrock,
top_bedrock_tvd_bho,
qt_top_bedrock_tvd_id_cli,
groundwater_bho,
qt_top_bedrock_tvd,
--geom_bho,
remarks_bho,
lithology_top_bedrock_id_cli,
Expand Down
4 changes: 2 additions & 2 deletions src/api-legacy/v1/borehole/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def get_sql(sql_lock='', file_permission=''):
drilling_diameter_bho as drill_diameter,
qt_inclination_direction_id_cli as qt_bore_inc_dir,
qt_depth_id_cli as qt_depth,
qt_top_bedrock_id_cli as qt_top_bedrock,
qt_top_bedrock_tvd_id_cli as qt_top_bedrock_tvd,
qt_top_bedrock,
qt_top_bedrock_tvd,
lithology_top_bedrock_id_cli as lithology_top_bedrock,
lithostrat_id_cli as lithostratigraphy_top_bedrock,
chronostrat_id_cli AS chronostratigraphy_top_bedrock,
Expand Down
22 changes: 2 additions & 20 deletions src/api-legacy/v1/borehole/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,10 @@ def get_sql_text(language='en', cols=None):
) as qt_depth,
top_bedrock_bho as top_bedrock,
COALESCE(
qt_tbed.text_cli_{language},
qt_tbed.text_cli_{fallback}
) as qt_top_bedrock,
qt_top_bedrock,
top_bedrock_tvd_bho as top_bedrock_tvd,
COALESCE(
qt_tbed_tvd.text_cli_{language},
qt_tbed_tvd.text_cli_{fallback}
) as qt_top_bedrock_tvd,
qt_top_bedrock_tvd,
groundwater_bho as groundwater,
Expand All @@ -128,12 +122,6 @@ def get_sql_text(language='en', cols=None):
FROM
bdms.borehole
LEFT JOIN bdms.codelist as qt_tbed_tvd
ON qt_tbed_tvd.id_cli = qt_top_bedrock_tvd_id_cli
LEFT JOIN bdms.codelist as qt_tbed
ON qt_tbed.id_cli = qt_top_bedrock_id_cli
LEFT JOIN bdms.codelist as rest
ON rest.id_cli = restriction_id_cli
Expand Down Expand Up @@ -328,12 +316,6 @@ def get_sql_geolcode(cols=None, join=None, where=None):
ON
idf.id_bho_fk = id_bho
LEFT JOIN bdms.codelist as qt_tbed_tvd
ON qt_tbed_tvd.id_cli = qt_top_bedrock_tvd_id_cli
LEFT JOIN bdms.codelist as qt_tbed
ON qt_tbed.id_cli = qt_top_bedrock_id_cli
LEFT JOIN bdms.codelist as rest
ON rest.id_cli = restriction_id_cli
Expand Down
8 changes: 4 additions & 4 deletions src/api-legacy/v1/borehole/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def get_column(field):
column = 'qt_depth_id_cli'

elif field == 'custom.qt_top_bedrock':
column = 'qt_top_bedrock_id_cli'
column = 'qt_top_bedrock'

elif field == 'custom.qt_top_bedrock_tvd':
column = 'qt_top_bedrock_tvd_id_cli'
column = 'qt_top_bedrock_tvd'

elif field == 'custom.lithology_top_bedrock':
column = 'lithology_top_bedrock_id_cli'
Expand Down Expand Up @@ -207,6 +207,8 @@ async def execute(self, id, field, value, user):
'total_depth_tvd',
'extended.top_bedrock',
'extended.top_bedrock_tvd',
'custom.qt_top_bedrock',
'custom.qt_top_bedrock_tvd',
'extended.groundwater',
'custom.mistakes',
'custom.remarks',
Expand Down Expand Up @@ -281,8 +283,6 @@ async def execute(self, id, field, value, user):
'extended.status',
'custom.qt_bore_inc_dir',
'custom.qt_depth',
'custom.qt_top_bedrock',
'custom.qt_top_bedrock_tvd',
'custom.processing_status',
'custom.lithology_top_bedrock',
'custom.lithostratigraphy_top_bedrock',
Expand Down
2 changes: 0 additions & 2 deletions src/api/BdmsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<Borehole>().HasOne(l => l.QtInclinationDirection).WithMany().HasForeignKey(l => l.QtInclinationDirectionId);
modelBuilder.Entity<Borehole>().HasOne(l => l.QtLocation).WithMany().HasForeignKey(l => l.QtLocationId);
modelBuilder.Entity<Borehole>().HasOne(l => l.QtTotalDepthTvd).WithMany().HasForeignKey(l => l.QtTotalDepthTvdId);
modelBuilder.Entity<Borehole>().HasOne(l => l.QtTopBedrock).WithMany().HasForeignKey(l => l.QtTopBedrockId);
modelBuilder.Entity<Borehole>().HasOne(l => l.QtTopBedrockTvd).WithMany().HasForeignKey(l => l.QtTopBedrockTvdId);
modelBuilder.Entity<Borehole>().HasOne(l => l.QtReferenceElevation).WithMany().HasForeignKey(l => l.QtReferenceElevationId);
modelBuilder.Entity<Borehole>().HasOne(l => l.ReferenceElevationType).WithMany().HasForeignKey(l => l.ReferenceElevationTypeId);
modelBuilder.Entity<Borehole>().HasOne(l => l.Restriction).WithMany().HasForeignKey(l => l.RestrictionId);
Expand Down
7 changes: 2 additions & 5 deletions src/api/BdmsContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public static void SeedData(this BdmsContext context)
List<int> layerKindIds = codelists.Where(c => c.Schema == "layer_kind").Select(s => s.Id).ToList();
List<int> purposeIds = codelists.Where(c => c.Schema == "extended.purpose").Select(s => s.Id).ToList();
List<int> statusIds = codelists.Where(c => c.Schema == "extended.status").Select(s => s.Id).ToList();
List<int> qtTopBedrockIds = codelists.Where(c => c.Schema == "custom.qt_top_bedrock").Select(s => s.Id).ToList();
List<int> lithologyTopBedrockIds = codelists.Where(c => c.Schema == "custom.lithology_top_bedrock").Select(s => s.Id).ToList();
List<int> qtInclinationDirectionIds = codelists.Where(c => c.Schema == "custom.qt_bore_inc_dir").Select(s => s.Id).ToList();
List<int> chronostratigraphyTopBedrockIds = codelists.Where(c => c.Schema == "custom.chronostratigraphy_top_bedrock").Select(s => s.Id).ToList();
Expand Down Expand Up @@ -162,8 +161,7 @@ public static void SeedData(this BdmsContext context)
.RuleFor(o => o.QtDepthId, f => f.PickRandom(qtDepthIds).OrNull(f, .05f))
.RuleFor(o => o.QtDepth, _ => default!)
.RuleFor(o => o.TopBedrock, f => f.Random.Double(0, 1000).OrNull(f, .05f))
.RuleFor(o => o.QtTopBedrockId, f => f.PickRandom(qtTopBedrockIds).OrNull(f, .05f))
.RuleFor(o => o.QtTopBedrock, _ => default!)
.RuleFor(o => o.QtTopBedrock, f => f.Random.Double(0, 2).OrNull(f, .05f))
.RuleFor(o => o.HasGroundwater, f => f.Random.Bool().OrNull(f, .2f))
.RuleFor(o => o.Remarks, f => f.Rant.Review().OrNull(f, .05f))
.RuleFor(o => o.LithologyTopBedrockId, f => f.PickRandom(lithologyTopBedrockIds).OrNull(f, .05f))
Expand All @@ -174,8 +172,7 @@ public static void SeedData(this BdmsContext context)
.RuleFor(o => o.Chronostratigraphy, _ => default!)
.RuleFor(o => o.SpudDate, f => f.Date.Past().ToUniversalTime().OrNull(f, .05f))
.RuleFor(o => o.TopBedrockTvd, f => f.Random.Double(0, 1000).OrNull(f, .05f))
.RuleFor(o => o.QtTopBedrockTvdId, f => f.PickRandom(qtTopBedrockIds).OrNull(f, .05f))
.RuleFor(o => o.QtTopBedrockTvd, _ => default!)
.RuleFor(o => o.QtTopBedrockTvd, f => f.Random.Double(0, 2).OrNull(f, .05f))
.RuleFor(o => o.ReferenceElevation, f => f.Random.Double(0, 4500).OrNull(f, .05f))
.RuleFor(o => o.QtReferenceElevationId, f => f.PickRandom(qtElevationIds).OrNull(f, .05f))
.RuleFor(o => o.QtReferenceElevation, _ => default!)
Expand Down
4 changes: 2 additions & 2 deletions src/api/Controllers/UploadController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,15 @@ public CsvImportBoreholeMap()
Map(m => m.QtInclinationDirectionId).Optional();
Map(m => m.QtDepthId).Optional();
Map(m => m.TopBedrock).Optional();
Map(m => m.QtTopBedrockId).Optional();
Map(m => m.QtTopBedrock).Optional();
Map(m => m.HasGroundwater).Optional();
Map(m => m.Remarks).Optional();
Map(m => m.LithologyTopBedrockId).Optional();
Map(m => m.LithostratigraphyId).Optional();
Map(m => m.ChronostratigraphyId).Optional();
Map(m => m.SpudDate).Optional();
Map(m => m.TopBedrockTvd).Optional();
Map(m => m.QtTopBedrockTvdId).Optional();
Map(m => m.QtTopBedrockTvd).Optional();
Map(m => m.ReferenceElevation).Optional();
Map(m => m.QtReferenceElevationId).Optional();
Map(m => m.ReferenceElevationTypeId).Optional();
Expand Down
Loading

0 comments on commit 5b1696d

Please sign in to comment.