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

Zero length string now handled for the Depth property #555

Merged
merged 10 commits into from
Nov 24, 2022
Merged
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
66 changes: 66 additions & 0 deletions XML_Engine/Query/Depth.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2022, 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;
using System.Collections.Generic;
using System.Linq;
using BH.oM.Environment.Elements;
using BH.Engine.Environment;

using System.ComponentModel;
using BH.oM.Base.Attributes;
using BH.oM.XML.Bluebeam;
using System.Text;
using System.Threading.Tasks;

using BH.oM.Adapters.XML;
using BH.oM.Adapters.XML.Enums;

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

[Description("Returns the 'depth' property of a markup object as a double. If the value cannot be converted to a double (if the value is null or blank for example) then an error will be provided and -1 will be returned.")]
[Input("markup", "A markup object which contains the 'depth' property.")]
[Output("depth", "The depth value as a double, or -1 if the value could not be converted to a double.")]
public static double Depth(this Markup markup)
{
if (markup == null)
return -1;

try
{
return System.Convert.ToDouble(markup.XMLDepth);
}
catch (Exception e)
{
BH.Engine.Base.Compute.RecordError($"Could not convert XMLDepth value {markup.XMLDepth} to numerical depth.");
return -1;
}
}
}
}

6 changes: 6 additions & 0 deletions XML_Engine/XML_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Dimensional_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Dimensional_oM.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -107,6 +112,7 @@
<Compile Include="Query\CleanName.cs" />
<Compile Include="Query\ExposedToSun.cs" />
<Compile Include="Query\ExternalElements.cs" />
<Compile Include="Query\Depth.cs" />
<Compile Include="Query\IsExternal.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions XML_oM/Bluebeam/Markup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public class Markup : BluebeamObject
public virtual string Label { get; set; }

[XmlElement("Depth")]
public virtual double Depth { get; set; }

public virtual string XMLDepth { get; set; }
[XmlElement("Layer")]
public virtual string Layer { get; set; }
}
Expand Down