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

Ground_Engine: Add method to retrieve specific StratumProperty based on type #3452

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions Ground_Engine/Compute/ConsolidateStrata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
/***************************************************/
/**** Public Methods ****/
/***************************************************/
[Description("A method that takes a Borehole, and consolidates the Strata sequentially by combining them based on a specific property.")]
[Description("A method that takes a Borehole, and consolidates the Strata sequentially by combining them based on a the property provided.")]
[Input("borehole", "The Borehole to consolidate the strata for.")]
[Input("propertyCompare", "The property of the Strata to consolidate such as ObservedGeology, InterpretedGeology or Legend.")]
[Input("propertyCompare", "The property of the Strata to consolidate (e.g. ObservedGeology, InterpretedGeology or Legend).")]
[Input("decimals", "The number of decimals to display the depth ranges.")]
[Output("b", "The consolidated Borehole.")]
public static Borehole ConsolidateStrata(Borehole borehole, string propertyCompare, int decimals)
public static Borehole ConsolidateStrata(Borehole borehole, string propertyCompare, int decimals = 2)
{
if (borehole.IsValid())
{
Expand Down Expand Up @@ -92,7 +92,7 @@
double bottom = stratum.Bottom;

// Properties to skip over
List<string> skipProp = new List<string>() { "Id", "Top", "Bottom", "Properties", "BHoM_Guid", "Name", "Fragments", "Tags", "CustomData" };

Check warning on line 95 in Ground_Engine/Compute/ConsolidateStrata.cs

View check run for this annotation

BHoMBot-CI / code-compliance

Ground_Engine/Compute/ConsolidateStrata.cs#L95

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
skipProp.Add(propName);

if (!initial)
Expand Down
8 changes: 0 additions & 8 deletions Ground_Engine/Query/ContaminantProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using BH.oM.Base;
using BH.oM.Base.Attributes;
using BH.oM.Data;
using BH.oM.Geometry;
using BH.oM.Ground;
using BH.oM.Quantities.Attributes;
using BH.Engine.Base;
using BH.Engine.Data;
using BH.Engine.Geometry;
using BH.oM.Data.Requests;


namespace BH.Engine.Ground
Expand Down
64 changes: 64 additions & 0 deletions Ground_Engine/Query/StratumProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2025, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using BH.oM.Base.Attributes;
using BH.oM.Ground;


namespace BH.Engine.Ground
{
public static partial class Query
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Returns the IStratumProperty matching the type provided..")]
[Input("stratum", "The IStratumProperty to retrieve the property from.")]
[Input("type", "The type that inherits IStratumProperty to search the Stratum for.")]
[Output("property", "The IStratumProperty found on the Stratum.")]
public static IStratumProperty StratumProperty(this Stratum stratum, Type type)
{
if (stratum.IsValid())
{
List<IStratumProperty> stratumProperties = stratum.Properties;

if (stratumProperties.Select(x => x.GetType()).Contains(type))
return (IStratumProperty)Base.Query.FilterByType(stratumProperties, type).First();
else
{
Base.Compute.RecordError($"The Stratum does not contain {type}.");
return null;
}
}
else
return null;
}

/***************************************************/

}
}