// Copyright (C) Stichting Deltares 2020. All rights reserved.
//
// This file is part of the Layer On Slope Tool.
//
// The Layer On Slope Tool is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
namespace Deltares.LayerOnSlopeTool.Data
{
///
/// Holds the possible point types.
///
public enum CharacteristicPointType
{
None,
SurfaceLevelOutside = 1, // Maaiveld buitenwaarts
BottomRiverChannel = 2, // Bodem geul
InsertRiverChannel = 3, // Insteek geul
DikeToeAtRiver = 5, // Teen dijk buitenwaarts
ShoulderTopOutside = 6, // Kruin buitenberm
ShoulderBaseOutside = 7, // Insteek buitenberm
DikeTopAtRiver = 8, // Kruin buitentalud
DikeLine = 9, // referentielijn
TrafficLoadOutside = 10, // Verkeersbelasting kant buitenwaarts
TrafficLoadInside = 11, // Verkeersbelasting kant binnenwaarts
DikeTopAtPolder = 12, // Kruin binnentalud
ShoulderBaseInside = 13, // Insteek binnenberm
ShoulderTopInside = 14, // Kruin binnenberm
DikeToeAtPolder = 15, // Teen dijk binnenwaarts
DitchDikeSide = 16, // Insteek sloot dijkzijde
BottomDitchDikeSide = 17, // Slootbodem dijkzijde
BottomDitchPolderSide = 18, // Slootbodem polderzijde
DitchPolderSide = 19, // Insteek sloot polderzijde
SurfaceLevelInside = 25, // Maaiveld binnenwaarts
}
///
/// Defines the surface line point
///
public class SurfaceLinePoint
{
///
/// Gets or sets the x coordinate.
///
///
/// The x coordinate.
///
public double XCoordinate { get; set; }
///
/// Gets or sets the z coordinate.
///
///
/// The z coordinate.
///
public double ZCoordinate { get; set; }
///
/// Gets or sets the type of the point.
///
///
/// The type of the point.
///
public CharacteristicPointType PointType { get; set; }
///
/// Determines whether the difference between the location of the given point and
/// this one are within the given precision.
///
/// The other.
/// The precision.
///
public bool LocationEquals(SurfaceLinePoint other, double precision = 0.001)
{
if (ReferenceEquals(other, null))
{
return false;
}
if (ReferenceEquals(other, this))
{
return true;
}
return AlmostEquals(XCoordinate,other.XCoordinate, precision) &&
AlmostEquals(ZCoordinate,other.ZCoordinate, precision);
}
private bool AlmostEquals(double double1, double double2, double precision)
{
if (double.IsNaN(double1) && double.IsNaN(double2))
{
return true;
}
if (double.IsNaN(double1) || double.IsNaN(double2))
{
return false;
}
return (Math.Abs(double1 - double2) <= precision);
}
}
}