Index: packages/repositories.config
===================================================================
diff -u -re5c186677d0ef8697eb04ea571b7c4ef8268183c -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- packages/repositories.config (.../repositories.config) (revision e5c186677d0ef8697eb04ea571b7c4ef8268183c)
+++ packages/repositories.config (.../repositories.config) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -15,7 +15,6 @@
-
Index: src/Plugins/Wti/Wti.Data/PipingSoilLayer.cs
===================================================================
diff -u -r356ac6ef31864aa207c8af9470df3349f8e4d1f1 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.Data/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 356ac6ef31864aa207c8af9470df3349f8e4d1f1)
+++ src/Plugins/Wti/Wti.Data/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -4,7 +4,11 @@
{
public class PipingSoilLayer
{
- public HashSet OuterLoop { get; set; }
- public HashSet InnerLoop { get; set; }
+ public PipingSoilLayer(double top)
+ {
+ Top = top;
+ }
+
+ public double Top { get; private set; }
}
}
\ No newline at end of file
Index: src/Plugins/Wti/Wti.Data/PipingSoilProfile.cs
===================================================================
diff -u -r356ac6ef31864aa207c8af9470df3349f8e4d1f1 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.Data/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 356ac6ef31864aa207c8af9470df3349f8e4d1f1)
+++ src/Plugins/Wti/Wti.Data/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -1,31 +1,59 @@
-using System.Collections;
+using System;
+using System.Collections;
using System.Collections.Generic;
+using System.Linq;
+using Wti.Data.Properties;
namespace Wti.Data
{
///
/// This class represents a soil profile, which was imported for use in a piping calculation.
///
- public class PipingSoilProfile : IEnumerable
+ public class PipingSoilProfile
{
- public PipingSoilProfile(string name, IEnumerable layers)
+ private IEnumerable layers;
+
+ ///
+ /// Creates a new instance of , with the given , and .
+ /// A new collection is created for and used in the .
+ ///
+ /// The name of the profile.
+ /// The bottom level of the profile.
+ /// The collection of layers that should be part of the profile.
+ public PipingSoilProfile(string name, double bottom, IEnumerable layers)
{
+ if (layers == null || layers.Count() == 0)
+ {
+ throw new ArgumentException(String.Format(Resources.Error_CannotConstructPipingSoilProfileWithoutLayers, name));
+ }
Name = name;
+ Bottom = bottom;
Layers = layers;
}
+ ///
+ /// Gets the bottom level of the .
+ ///
+ public double Bottom { get; private set; }
+
+ ///
+ /// Gets the name of .
+ ///
public string Name { get; private set; }
- public IEnumerator GetEnumerator()
+ ///
+ /// Gets a of the for the .
+ ///
+ public IEnumerable Layers
{
- return Layers.GetEnumerator();
+ get
+ {
+ return layers;
+ }
+ private set
+ {
+ layers = value.ToArray();
+ }
}
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
-
- public IEnumerable Layers { get; private set; }
}
}
\ No newline at end of file
Index: src/Plugins/Wti/Wti.Data/Properties/Resources.Designer.cs
===================================================================
diff -u
--- src/Plugins/Wti/Wti.Data/Properties/Resources.Designer.cs (revision 0)
+++ src/Plugins/Wti/Wti.Data/Properties/Resources.Designer.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,72 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.34209
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Wti.Data.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Wti.Data.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Geen lagen gevonden voor het profiel '{0}'..
+ ///
+ internal static string Error_CannotConstructPipingSoilProfileWithoutLayers {
+ get {
+ return ResourceManager.GetString("Error_CannotConstructPipingSoilProfileWithoutLayers", resourceCulture);
+ }
+ }
+ }
+}
Index: src/Plugins/Wti/Wti.Data/Properties/Resources.resx
===================================================================
diff -u
--- src/Plugins/Wti/Wti.Data/Properties/Resources.resx (revision 0)
+++ src/Plugins/Wti/Wti.Data/Properties/Resources.resx (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Geen lagen gevonden voor het profiel '{0}'.
+
+
\ No newline at end of file
Index: src/Plugins/Wti/Wti.Data/Wti.Data.csproj
===================================================================
diff -u -re5c186677d0ef8697eb04ea571b7c4ef8268183c -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.Data/Wti.Data.csproj (.../Wti.Data.csproj) (revision e5c186677d0ef8697eb04ea571b7c4ef8268183c)
+++ src/Plugins/Wti/Wti.Data/Wti.Data.csproj (.../Wti.Data.csproj) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -51,6 +51,11 @@
+
+ True
+ True
+ Resources.resx
+
@@ -68,6 +73,12 @@
False
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
Index: src/Plugins/Wti/Wti.IO/Builders/SoilLayer2D.cs
===================================================================
diff -u
--- src/Plugins/Wti/Wti.IO/Builders/SoilLayer2D.cs (revision 0)
+++ src/Plugins/Wti/Wti.IO/Builders/SoilLayer2D.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Wti.Data;
+
+namespace Wti.IO.Builders
+{
+ public class SoilLayer2D
+ {
+ public HashSet OuterLoop { get; set; }
+ public HashSet InnerLoop { get; set; }
+
+ internal IEnumerable AsPipingSoilLayers(double atX, out double bottom)
+ {
+ bottom = Double.MaxValue;
+ var result = new Collection();
+ if (OuterLoop != null)
+ {
+ for (int i = 0; i <= OuterLoop.Count; i++)
+ {
+ var current = i;
+ var next = (i+i) %OuterLoop.Count;
+
+ }
+ }
+ return result;
+ }
+ }
+}
\ No newline at end of file
Index: src/Plugins/Wti/Wti.IO/Builders/SoilProfileBuilder.cs
===================================================================
diff -u
--- src/Plugins/Wti/Wti.IO/Builders/SoilProfileBuilder.cs (revision 0)
+++ src/Plugins/Wti/Wti.IO/Builders/SoilProfileBuilder.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Wti.Data;
+using Wti.IO.Properties;
+
+namespace Wti.IO.Builders
+{
+ ///
+ /// Constructs a 1d Soil Profile based on definitions of .
+ ///
+ public class SoilProfileBuilder
+ {
+ private readonly ICollection layers = new Collection();
+
+ public SoilProfileBuilder(string profileName, double atX)
+ {
+ if (double.IsNaN(atX))
+ {
+ throw new ArgumentException(Resources.Error_SoilProfileBuilderCantDetermineIntersectAtDoubleNaN);
+ }
+ ProfileName = profileName;
+ AtX = atX;
+ Bottom = double.MaxValue;
+ }
+
+ public void Add(SoilLayer2D soilLayer)
+ {
+ double bottom;
+ foreach(PipingSoilLayer layer in soilLayer.AsPipingSoilLayers(AtX, out bottom))
+ {
+ layers.Add(layer);
+ }
+ Bottom = Math.Min(Bottom, bottom);
+ }
+
+ private double Bottom { get; set; }
+
+ public PipingSoilProfile Build()
+ {
+ return new PipingSoilProfile(ProfileName, 0.0, layers);
+ }
+
+ private double AtX { get; set; }
+
+ private string ProfileName { get; set; }
+ }
+}
\ No newline at end of file
Index: src/Plugins/Wti/Wti.IO/Calculation/Math2D.cs
===================================================================
diff -u
--- src/Plugins/Wti/Wti.IO/Calculation/Math2D.cs (revision 0)
+++ src/Plugins/Wti/Wti.IO/Calculation/Math2D.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,114 @@
+using System;
+
+namespace Wti.IO.Calculation
+{
+ public class Math2D
+ {
+ private const double epsilonForComparisons = 1e-8;
+
+ ///
+ /// Determines whether two line segments intersect with each other. If the lines are parallel, no intersection point is returned.
+ ///
+ /// X coordinates of the first segment. Should have matching y coordinates in .
+ /// Y coordinates of the first segment. Should have matching x coordinates in .
+ /// X coordinates of the second segment. Should have matching y coordinates in .
+ /// Y coordinates of the second segment. Should have matching x coordinates in .
+ ///
+ public static double[] LineSegmentIntersectionWithLineSegment(double[] segmentX, double[] segmentY, double[] otherX, double[] otherY)
+ {
+ var numberOfPoints = 2;
+ if (segmentX.Length != numberOfPoints || segmentY.Length != numberOfPoints || otherX.Length != numberOfPoints || otherY.Length != numberOfPoints)
+ {
+ throw new ArgumentException("Collections of segments' x and y coordinates need to have length of 2");
+ }
+ var extraPolatedIntersectionPoint = LineIntersectionWithLine(segmentX, segmentY, otherX, otherY);
+
+ if (extraPolatedIntersectionPoint.Length == 2)
+ {
+ var onFirstSegment = IsBetween(new[]
+ {
+ segmentX[0],
+ segmentX[1],
+ extraPolatedIntersectionPoint[0]
+ }, new[]
+ {
+ segmentY[0],
+ segmentY[1],
+ extraPolatedIntersectionPoint[1]
+ });
+ var onSecondSegment = IsBetween(new[]
+ {
+ otherX[0],
+ otherX[1],
+ extraPolatedIntersectionPoint[0]
+ }, new[]
+ {
+ otherY[0],
+ otherY[1],
+ extraPolatedIntersectionPoint[1]
+ });
+ if (onFirstSegment && onSecondSegment)
+ {
+ return extraPolatedIntersectionPoint;
+ }
+ }
+ return new double[0];
+ }
+
+ /// Taken from: https://www.topcoder.com/community/data-science/data-science-tutorials/geometry-concepts-line-intersection-and-its-applications/ .
+ private static double[] LineIntersectionWithLine(double[] lineX, double[] lineY, double[] otherLineX, double[] otherLineY)
+ {
+ var numberOfPoints = 2;
+ if (lineX.Length != numberOfPoints || lineY.Length != numberOfPoints || otherLineX.Length != numberOfPoints || otherLineY.Length != numberOfPoints)
+ {
+ throw new ArgumentException("Collections of lines' x and y coordinates need to have length of 2");
+ }
+
+ var aLine = lineY[1] - lineY[0];
+ var bLine = lineX[0] - lineX[1];
+ var cLine = aLine*lineX[0] + bLine*lineY[0];
+
+ var aOtherLine = otherLineY[1] - otherLineY[0];
+ var bOtherLine = otherLineX[0] - otherLineX[1];
+ var cOtherLine = aOtherLine * otherLineX[0] + bOtherLine * otherLineY[0];
+
+ var determinant = aLine*bOtherLine - aOtherLine*bLine;
+ if (Math.Abs(determinant) < epsilonForComparisons)
+ {
+ return new double[0];
+ }
+
+ return new[]
+ {
+ (bOtherLine*cLine - bLine*cOtherLine)/determinant,
+ (aLine*cOtherLine - aOtherLine*cLine)/determinant
+ };
+ }
+
+ ///
+ /// Checks whether point [2],[2] lies between [0],[0]
+ /// and [1],[1].
+ ///
+ /// X-coordinates of the 3 points.
+ /// Y-coordinates of the 3 points.
+ /// True if point [2],[2] lies between [0],[0]
+ /// and [1],[1]. False otherwise.
+ private static bool IsBetween(double[] x, double[] y)
+ {
+ var crossProduct = (y[2] - y[0])*(x[1] - x[0]) - (x[2] - x[0])*(y[1] - y[0]);
+ if (Math.Abs(crossProduct) > epsilonForComparisons)
+ {
+ return false;
+ }
+
+ var dotProduct = (x[2] - x[0])*(x[1] - x[0]) + (y[2] - y[0])*(y[1] - y[0]);
+ if (dotProduct < 0)
+ {
+ return false;
+ }
+
+ var squaredLengthSegment = (x[1] - x[0])*(x[1] - x[0]) + (y[1] - y[0])*(y[1] - y[0]);
+ return dotProduct <= squaredLengthSegment;
+ }
+ }
+}
\ No newline at end of file
Index: src/Plugins/Wti/Wti.IO/PipingSoilLayer2DReader.cs
===================================================================
diff -u
--- src/Plugins/Wti/Wti.IO/PipingSoilLayer2DReader.cs (revision 0)
+++ src/Plugins/Wti/Wti.IO/PipingSoilLayer2DReader.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,173 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+using Wti.Data;
+using Wti.IO.Builders;
+
+namespace Wti.IO
+{
+ ///
+ /// This class is responsible for reading an array of bytes and interpret this as a XML document, which contains information about
+ /// the geometry of a .
+ ///
+ internal class PipingSoilLayer2DReader
+ {
+ private const string outerLoopElementName = "OuterLoop";
+ private const string innerLoopElementName = "InnerLoop";
+ private const string endPointElementName = "EndPoint";
+ private const string headPointElementName = "HeadPoint";
+ private const string xElementName = "X";
+ private const string yElementName = "Y";
+ private const string zElementName = "Z";
+
+ private readonly XmlTextReader xmlTextReader;
+
+ ///
+ /// Constructs a new , which uses the as the source of the
+ /// geometry for a .
+ ///
+ /// An array of which contains the information of a
+ /// in an XML document.
+ /// Thrown when is null.
+ internal PipingSoilLayer2DReader(byte[] geometry)
+ {
+ xmlTextReader = new XmlTextReader(new MemoryStream(geometry));
+ }
+
+ ///
+ /// Reads the XML document and from this obtains the required information and constructs a based
+ /// on this information.
+ ///
+ /// A new with information taken from the XML document.
+ /// When reading from the XML document of the failed.
+ internal SoilLayer2D Read()
+ {
+ var pipingSoilLayer = new SoilLayer2D();
+
+ while (xmlTextReader.Read())
+ {
+ HashSet outerLoop;
+ HashSet innerLoop;
+ if (TryParseLoop(outerLoopElementName, out outerLoop))
+ {
+ pipingSoilLayer.OuterLoop = outerLoop;
+ }
+ if (TryParseLoop(innerLoopElementName, out innerLoop))
+ {
+ pipingSoilLayer.InnerLoop = innerLoop;
+ }
+ }
+
+ return pipingSoilLayer;
+ }
+
+ ///
+ /// Tries to parse the element with the given , which the reader should be currently pointing at, as a loop.
+ ///
+ /// The name of the element which the reader should be currently pointing at.
+ /// The result of parsing the element as a loop. null if the current element's name does not match .
+ /// True if the reader currently points to an element with name . False otherwise.
+ private bool TryParseLoop(String elementName, out HashSet loop)
+ {
+ loop = null;
+
+ if (IsElementWithName(elementName))
+ {
+ loop = new HashSet();
+
+ if (!IsEmptyElement())
+ {
+ while (xmlTextReader.Read() && !IsEndElementWithName(elementName))
+ {
+ Point3D parsedPoint;
+ if (TryParsePoint(out parsedPoint))
+ {
+ loop.Add(parsedPoint);
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Finds out whether the element which the reader is currently pointing at is empty.
+ ///
+ /// True if the element is empty. False otherwise.
+ private bool IsEmptyElement()
+ {
+ return xmlTextReader.IsEmptyElement;
+ }
+
+ ///
+ /// Tries to parse the element which the reader is currently pointing at as a point.
+ ///
+ /// The result of parsing the element as a point. null if current element is not a head or end point.
+ /// True if the reader currently points to an element with name or . False otherwise.
+ private bool TryParsePoint(out Point3D point)
+ {
+ point = null;
+
+ if (IsElementWithName(headPointElementName) || IsElementWithName(endPointElementName))
+ {
+ var pointValues = ReadChildValues();
+ point = new Point3D
+ {
+ X = double.Parse(pointValues[xElementName], CultureInfo.InvariantCulture),
+ Y = double.Parse(pointValues[yElementName], CultureInfo.InvariantCulture),
+ Z = double.Parse(pointValues[zElementName], CultureInfo.InvariantCulture)
+ };
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// Reads the name and values for the children of the current element and puts them in a name indexed dictionary.
+ ///
+ /// A . For each entry, key is equal to child element name and value is equal to the value of the child element's text node.
+ private Dictionary ReadChildValues()
+ {
+ string elementName = xmlTextReader.Name;
+ var nodeSibblings = new Dictionary();
+
+ while (xmlTextReader.Read() && !IsEndElementWithName(elementName))
+ {
+ if (xmlTextReader.NodeType == XmlNodeType.Element)
+ {
+ nodeSibblings[xmlTextReader.Name] = xmlTextReader.ReadString();
+ }
+ }
+
+ return nodeSibblings;
+ }
+
+ ///
+ /// Checks whether the element the reader is currently pointing at is of type and has a name equal to .
+ ///
+ /// The name which the element should have.
+ /// True if the current element has type and its name is equal to .
+ private bool IsElementWithName(string name)
+ {
+ var isElement = xmlTextReader.NodeType == XmlNodeType.Element;
+ var isPoint = xmlTextReader.Name == name;
+
+ return isElement && isPoint;
+ }
+ ///
+ /// Checks whether the element the reader is currently pointing at is of type and has a name equal to .
+ ///
+ /// The name which the end element should have.
+ /// True if the current element has type and its name is equal to .
+ private bool IsEndElementWithName(string name)
+ {
+ var isElement = xmlTextReader.NodeType == XmlNodeType.EndElement;
+ var isPoint = xmlTextReader.Name == name;
+
+ return isElement && isPoint;
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 65260b1c152bf584ac4d6bdb68f6e4d115c513a0 refers to a dead (removed) revision in file `src/Plugins/Wti/Wti.IO/PipingSoilLayerReader.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: src/Plugins/Wti/Wti.IO/PipingSoilProfileReader.cs
===================================================================
diff -u -r148b1b06bb80e4ad65a7b8a722910db6eaef0098 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.IO/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 148b1b06bb80e4ad65a7b8a722910db6eaef0098)
+++ src/Plugins/Wti/Wti.IO/PipingSoilProfileReader.cs (.../PipingSoilProfileReader.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -7,6 +7,7 @@
using System.Linq;
using System.Xml;
using Wti.Data;
+using Wti.IO.Builders;
using Wti.IO.Exceptions;
using Wti.IO.Properties;
@@ -21,6 +22,8 @@
private const int pipingMechanismId = 4;
private const int profileNameIndex = 0;
private const int profileLayerGeometryIndex = 1;
+ private const int intersectionXIndex = 3;
+
private SQLiteConnection connection;
private SQLiteDataReader dataReader;
@@ -52,22 +55,23 @@
/// Thrown when parsing the geometry of a soil layer failed.
public IEnumerable Read()
{
- var pipingSoilProfiles = new Dictionary>();
+ var pipingSoilProfiles = new Dictionary();
CreateDataReader();
while (dataReader.Read())
{
var profileName = (string) dataReader[profileNameIndex];
+ var intersectionX = (double) dataReader[intersectionXIndex];
if (!pipingSoilProfiles.ContainsKey(profileName))
{
- pipingSoilProfiles.Add(profileName, new Collection());
+ pipingSoilProfiles.Add(profileName, new SoilProfileBuilder(profileName, intersectionX));
}
pipingSoilProfiles[profileName].Add(ReadPipingSoilLayer());
}
- return pipingSoilProfiles.Select(keyValue => new PipingSoilProfile(keyValue.Key, keyValue.Value));
+ return pipingSoilProfiles.Select(keyValue => keyValue.Value.Build());
}
public void Dispose()
@@ -101,11 +105,11 @@
}
}
- private PipingSoilLayer ReadPipingSoilLayer()
+ private SoilLayer2D ReadPipingSoilLayer()
{
var columnValue = dataReader[profileLayerGeometryIndex];
var geometry = (byte[]) columnValue;
- return new PipingSoilLayerReader(geometry).Read();
+ return new PipingSoilLayer2DReader(geometry).Read();
}
///
@@ -117,8 +121,9 @@
var query = new SQLiteCommand(connection)
{
CommandText = string.Format(
- "SELECT p.SP2D_Name, l.GeometrySurface, mat.MA_Name " +
+ "SELECT p.SP2D_Name, l.GeometrySurface, mat.MA_Name, mpl.X " +
"FROM MechanismPointLocation as m " +
+ "JOIN MechanismPointLocation as mpl ON m.ME_ID = mpl.ME_ID " +
"JOIN SoilProfile2D as p ON m.SP2D_ID = p.SP2D_ID " +
"JOIN SoilLayer2D as l ON l.SP2D_ID = p.SP2D_ID " +
"JOIN Materials as mat ON mat.MA_ID = l.MA_ID " +
Index: src/Plugins/Wti/Wti.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -raa2e48b57a92d8f3703cb27e92bb538bfc5b6ff9 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision aa2e48b57a92d8f3703cb27e92bb538bfc5b6ff9)
+++ src/Plugins/Wti/Wti.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18444
+// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -61,6 +61,15 @@
}
///
+ /// Looks up a localized string similar to .
+ ///
+ public static string Error_CoordinateCollectionSizesDoNotMatch {
+ get {
+ return ResourceManager.GetString("Error_CoordinateCollectionSizesDoNotMatch", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Het bestandspad '{0}' verwijst naar een map die niet bestaat..
///
public static string Error_Directory_in_path_0_missing {
@@ -151,6 +160,15 @@
}
///
+ /// Looks up a localized string similar to Geen geldige X waarde gevonden om intersectie te maken uit 2D profiel '{0}'..
+ ///
+ public static string Error_SoilProfileBuilderCantDetermineIntersectAtDoubleNaN {
+ get {
+ return ResourceManager.GetString("Error_SoilProfileBuilderCantDetermineIntersectAtDoubleNaN", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Kon geen ondergrond profielen verkrijgen van de database '{0}'..
///
public static string Error_SoilProfileReadFromDatabase {
Index: src/Plugins/Wti/Wti.IO/Properties/Resources.resx
===================================================================
diff -u -raa2e48b57a92d8f3703cb27e92bb538bfc5b6ff9 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.IO/Properties/Resources.resx (.../Resources.resx) (revision aa2e48b57a92d8f3703cb27e92bb538bfc5b6ff9)
+++ src/Plugins/Wti/Wti.IO/Properties/Resources.resx (.../Resources.resx) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -150,6 +150,9 @@
Kon geen ondergrond profielen verkrijgen van de database '{0}'.
+
+ Geen geldige X waarde gevonden om intersectie te maken uit 2D profiel '{0}'.
+
Het bestand '{0}' heeft op regel {1} een waarde dat geen getal is.
Index: src/Plugins/Wti/Wti.IO/Wti.IO.csproj
===================================================================
diff -u -r91ec76d4b8a0fcf5962f442021c43f1ffa70743e -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- src/Plugins/Wti/Wti.IO/Wti.IO.csproj (.../Wti.IO.csproj) (revision 91ec76d4b8a0fcf5962f442021c43f1ffa70743e)
+++ src/Plugins/Wti/Wti.IO/Wti.IO.csproj (.../Wti.IO.csproj) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -50,10 +50,13 @@
Properties\GlobalAssembly.cs
+
+
+
-
+
Index: test/Plugins/Wti/Wti.Calculation.TestUtil/TestPipingSoilProfile.cs
===================================================================
diff -u -r356ac6ef31864aa207c8af9470df3349f8e4d1f1 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- test/Plugins/Wti/Wti.Calculation.TestUtil/TestPipingSoilProfile.cs (.../TestPipingSoilProfile.cs) (revision 356ac6ef31864aa207c8af9470df3349f8e4d1f1)
+++ test/Plugins/Wti/Wti.Calculation.TestUtil/TestPipingSoilProfile.cs (.../TestPipingSoilProfile.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -1,9 +1,10 @@
-using Wti.Data;
+using System.Collections.ObjectModel;
+using Wti.Data;
namespace Wti.Calculation.Test.Piping.Stub
{
public class TestPipingSoilProfile : PipingSoilProfile
{
- public TestPipingSoilProfile() : base("", null) {}
+ public TestPipingSoilProfile() : base("", 0.0, new Collection {new PipingSoilLayer(0.0)}) { }
}
}
\ No newline at end of file
Index: test/Plugins/Wti/Wti.Data.Test/PipingSoilLayerTest.cs
===================================================================
diff -u
--- test/Plugins/Wti/Wti.Data.Test/PipingSoilLayerTest.cs (revision 0)
+++ test/Plugins/Wti/Wti.Data.Test/PipingSoilLayerTest.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,22 @@
+using System;
+using NUnit.Framework;
+
+namespace Wti.Data.Test
+{
+ public class PipingSoilLayerTest
+ {
+ [Test]
+ public void Constructor_WithTop_ReturnsNewInstanceWithTopSet()
+ {
+ // Setup
+ var top = new Random(22).NextDouble();
+
+ // Call
+ var layer = new PipingSoilLayer(top);
+
+ // Assert
+ Assert.NotNull(layer);
+ Assert.AreEqual(top, layer.Top);
+ }
+ }
+}
\ No newline at end of file
Index: test/Plugins/Wti/Wti.Data.Test/Wti.Data.Test.csproj
===================================================================
diff -u -r2ff69dfc67c77d80c1ed2f4f1f9bc0172e28e518 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- test/Plugins/Wti/Wti.Data.Test/Wti.Data.Test.csproj (.../Wti.Data.Test.csproj) (revision 2ff69dfc67c77d80c1ed2f4f1f9bc0172e28e518)
+++ test/Plugins/Wti/Wti.Data.Test/Wti.Data.Test.csproj (.../Wti.Data.Test.csproj) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -15,7 +15,7 @@
true
bin\Debug\
- 4
+ 4
DEBUG;TRACE
full
x86
@@ -24,7 +24,7 @@
bin\Release\
- 4
+ 4
TRACE
true
pdbonly
@@ -51,6 +51,8 @@
+
+
Index: test/Plugins/Wti/Wti.IO.Test/Calculation/Math2DTest.cs
===================================================================
diff -u
--- test/Plugins/Wti/Wti.IO.Test/Calculation/Math2DTest.cs (revision 0)
+++ test/Plugins/Wti/Wti.IO.Test/Calculation/Math2DTest.cs (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -0,0 +1,194 @@
+using NUnit.Framework;
+using Wti.IO.Calculation;
+
+namespace Wti.IO.Test.Calculation
+{
+ public class Math2DTest
+ {
+ private static readonly double[][] IntersectingSegments =
+ {
+ // \/
+ // /\
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 1.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.5,
+ 0.5
+ },
+ // __
+ // /
+ // /
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 1.0,
+ 0.0,
+ 1.0,
+ 1.0,
+ 1.0,
+ 1.0,
+ 1.0
+ },
+ //
+ // /
+ // /__
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 1.0,
+ 0.0,
+ 0.0
+ }
+ };
+
+ private static readonly double[][] ParallelSegments =
+ {
+ // __
+ // __
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.0,
+ 1.0,
+ 1.0,
+ 1.0
+ },
+ // ____ (connected in single point)
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 2.0,
+ 0.0
+ },
+ // __ (overlap)
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.5,
+ 0.0,
+ 1.5,
+ 0.0
+ }
+ };
+
+ private static readonly double[][] NonIntersectingSegments =
+ {
+ // |
+ // ___
+ new[]
+ {
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0,
+ 0.5,
+ 1.0,
+ 0.5,
+ 0.5
+ }
+ };
+
+ [Test]
+ [TestCaseSource("IntersectingSegments")]
+ public void LineSegmentIntersectionWithLineSegment_DifferentLineSegmentsWithIntersections_ReturnsPoint(double[] coordinates)
+ {
+ // Setup
+ var segments = ToSegmentCoordinatesCollections(coordinates);
+
+ // Call
+ var result = Math2D.LineSegmentIntersectionWithLineSegment(segments[0], segments[1], segments[2], segments[3]);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ coordinates[8],
+ coordinates[9]
+ }, result);
+ }
+
+ [Test]
+ [TestCaseSource("ParallelSegments")]
+ public void LineSegmentIntersectionWithLineSegment_DifferentParallelLineSegments_ReturnsNoPoint(double[] coordinates)
+ {
+ // Setup
+ var segments = ToSegmentCoordinatesCollections(coordinates);
+
+ // Call
+ var result = Math2D.LineSegmentIntersectionWithLineSegment(segments[0], segments[1], segments[2], segments[3]);
+
+ // Assert
+ Assert.AreEqual(0, result.Length);
+ }
+
+ [Test]
+ [TestCaseSource("NonIntersectingSegments")]
+ public void LineSegmentIntersectionWithLineSegment_DifferentLineSegmentsWithNoIntersection_ReturnsNoPoint(double[] coordinates)
+ {
+ // Setup
+ var segments = ToSegmentCoordinatesCollections(coordinates);
+
+ // Call
+ var result = Math2D.LineSegmentIntersectionWithLineSegment(segments[0], segments[1], segments[2], segments[3]);
+
+ // Assert
+ Assert.AreEqual(0, result.Length);
+ }
+
+ private double[][] ToSegmentCoordinatesCollections(double[] coordinates)
+ {
+ double[] segmentX =
+ {
+ coordinates[0],
+ coordinates[2]
+ };
+ double[] segmentY =
+ {
+ coordinates[1],
+ coordinates[3]
+ };
+ double[] otherSegmentX =
+ {
+ coordinates[4],
+ coordinates[6]
+ };
+ double[] otherSegmentY =
+ {
+ coordinates[5],
+ coordinates[7]
+ };
+ return new[]
+ {
+ segmentX,
+ segmentY,
+ otherSegmentX,
+ otherSegmentY
+ };
+ }
+ }
+}
\ No newline at end of file
Index: test/Plugins/Wti/Wti.IO.Test/PipingSoilLayerReaderTest.cs
===================================================================
diff -u -r148b1b06bb80e4ad65a7b8a722910db6eaef0098 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- test/Plugins/Wti/Wti.IO.Test/PipingSoilLayerReaderTest.cs (.../PipingSoilLayerReaderTest.cs) (revision 148b1b06bb80e4ad65a7b8a722910db6eaef0098)
+++ test/Plugins/Wti/Wti.IO.Test/PipingSoilLayerReaderTest.cs (.../PipingSoilLayerReaderTest.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -13,7 +13,7 @@
public void Constructor_AnyByteArray_ReturnsNewInstance(int size)
{
// Call
- var result = new PipingSoilLayerReader(new byte[size]);
+ var result = new PipingSoilLayer2DReader(new byte[size]);
// Assert
Assert.NotNull(result);
@@ -24,7 +24,7 @@
{
// Setup
var xmlDoc = GetBytes("test");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
TestDelegate test = () => reader.Read();
@@ -38,7 +38,7 @@
{
// Setup
var xmlDoc = GetBytes("");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -54,7 +54,7 @@
{
// Setup
var xmlDoc = GetBytes("");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -70,7 +70,7 @@
{
// Setup
var xmlDoc = GetBytes("");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -86,7 +86,7 @@
{
// Setup
var xmlDoc = GetBytes("");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -115,7 +115,7 @@
{
// Setup
var xmlDoc = GetBytes("00.11.1");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -130,7 +130,7 @@
{
// Setup
var xmlDoc = GetBytes("00.11.1");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -145,7 +145,7 @@
{
// Setup
var xmlDoc = GetBytes("00.11.110.11.1");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
@@ -160,7 +160,7 @@
{
// Setup
var xmlDoc = GetBytes("00.11.110.11.1");
- var reader = new PipingSoilLayerReader(xmlDoc);
+ var reader = new PipingSoilLayer2DReader(xmlDoc);
// Call
var result = reader.Read();
Index: test/Plugins/Wti/Wti.IO.Test/PipingSoilProfileReaderTest.cs
===================================================================
diff -u -r148b1b06bb80e4ad65a7b8a722910db6eaef0098 -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- test/Plugins/Wti/Wti.IO.Test/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 148b1b06bb80e4ad65a7b8a722910db6eaef0098)
+++ test/Plugins/Wti/Wti.IO.Test/PipingSoilProfileReaderTest.cs (.../PipingSoilProfileReaderTest.cs) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -72,92 +72,5 @@
var exception = Assert.Throws(test);
Assert.AreEqual(String.Format(Resources.Error_SoilProfileReadFromDatabase, dbName), exception.Message);
}
-
- [Test]
- [SetCulture("nl-NL")]
- public void ReadSoilProfiles_NLCompleteDatabase_Returns2ProfilesWithLayersAndGeometries()
- {
- ReadSoilProfiles_CompleteDatabase_Returns2ProfilesWithLayersAndGeometries();
- }
-
- [Test]
- [SetCulture("en-US")]
- public void ReadSoilProfiles_ENCompleteDatabase_Returns2ProfilesWithLayersAndGeometries()
- {
- ReadSoilProfiles_CompleteDatabase_Returns2ProfilesWithLayersAndGeometries();
- }
-
- private void ReadSoilProfiles_CompleteDatabase_Returns2ProfilesWithLayersAndGeometries()
- {
- // Setup
- var testFile = "complete.soil";
- var pipingSoilProfilesReader = new PipingSoilProfileReader(Path.Combine(testDataPath, testFile));
-
- var firstProfileFirstLayerOuterLoop = new HashSet
- {
- new Point3D
- {
- X = 0, Y = 0, Z = -10
- },
- new Point3D
- {
- X = 0, Y = 0, Z = -3.5
- },
- new Point3D
- {
- X = 70.208, Y = 0, Z = -3.5
- },
- new Point3D
- {
- X = 73.91, Y = 0, Z = -3.5
- },
- new Point3D
- {
- X = 80.78, Y = 0, Z = -3.5
- },
- new Point3D
- {
- X = 80.78, Y = 0, Z = -10
- },
- };
-
- var secondProfileSecondLayerOuterLoop = new HashSet
- {
- new Point3D
- {
- X = 87.516, Y = 0, Z = -1.5
- },
- new Point3D
- {
- X = 87.567000000000007, Y = 0, Z = -0.70000000000000007
- },
- new Point3D
- {
- X = 101.4, Y = 0, Z = -0.70000000000000007
- },
- new Point3D
- {
- X = 101.4, Y = 0, Z = -1.5
- },
- };
-
- // Call
- IEnumerable result = pipingSoilProfilesReader.Read().ToArray();
-
- // Assert
- Assert.AreEqual(2, result.Count());
- var firstProfile = result.SingleOrDefault(psp => psp.Name == "10Y_005_STBI");
- Assert.NotNull(firstProfile);
- Assert.AreEqual(13, firstProfile.Count());
-
- CollectionAssert.AreEqual(firstProfileFirstLayerOuterLoop, firstProfile.Layers.ToArray()[0].OuterLoop);
- Assert.IsNull(firstProfile.Layers.ToArray()[0].InnerLoop);
-
- var secondProfile = result.SingleOrDefault(psp => psp.Name == "10Y_041_STBI");
- Assert.NotNull(secondProfile);
- Assert.AreEqual(14, secondProfile.Count());
- CollectionAssert.AreEqual(secondProfileSecondLayerOuterLoop, secondProfile.Layers.ToArray()[1].OuterLoop);
- Assert.IsNull(secondProfile.Layers.ToArray()[1].InnerLoop);
- }
}
}
\ No newline at end of file
Index: test/Plugins/Wti/Wti.IO.Test/Wti.IO.Test.csproj
===================================================================
diff -u -r91ec76d4b8a0fcf5962f442021c43f1ffa70743e -r65260b1c152bf584ac4d6bdb68f6e4d115c513a0
--- test/Plugins/Wti/Wti.IO.Test/Wti.IO.Test.csproj (.../Wti.IO.Test.csproj) (revision 91ec76d4b8a0fcf5962f442021c43f1ffa70743e)
+++ test/Plugins/Wti/Wti.IO.Test/Wti.IO.Test.csproj (.../Wti.IO.Test.csproj) (revision 65260b1c152bf584ac4d6bdb68f6e4d115c513a0)
@@ -45,6 +45,9 @@
+
+
+