//----------------------------------------------------------------------- // // Copyright (c) 2010 Deltares. All rights reserved. // // B.S.T.I.M. The // tom.the@deltares.nl // 05-10-2010 // Data definition for surfaceline export to csv //----------------------------------------------------------------------- using System.Globalization; using System.Text; using Deltares.Dam.Data.CsvImporters; using Deltares.Geometry; using Deltares.Geotechnics; using Deltares.Geotechnics.SurfaceLines; namespace Deltares.Dam.Data { public class CsvExportSurfaceLine { SurfaceLine2 surfaceLine; CsvExportSurfaceLineIdentifiers csvExportSurfaceLineIdentifiers; public CsvExportSurfaceLine(CsvExportSurfaceLineIdentifiers csvExportSurfaceLineIdentifiers, SurfaceLine2 surfaceLine) { this.surfaceLine = surfaceLine; this.csvExportSurfaceLineIdentifiers = csvExportSurfaceLineIdentifiers; } // The following 5 properties are identifiers and should be the first columns. // Use negative identifers to add them as the first columns [CsvExportColumn(SurfaceLineCsvColumnNames.LocationColumnName, -4)] public string LocationId { get { return (csvExportSurfaceLineIdentifiers == null) ? "" : csvExportSurfaceLineIdentifiers.LocationId; } } [CsvExportColumn(CsvExportSurfaceLineIdentifiers.CsvHeaderSoilProfileId, -3)] public string SoilProfileId { get { return (csvExportSurfaceLineIdentifiers == null) ? "" : csvExportSurfaceLineIdentifiers.SoilProfileId; } } [CsvExportColumn(CsvExportSurfaceLineIdentifiers.CsvHeaderScenario, -2)] public string Scenario { get { return (csvExportSurfaceLineIdentifiers == null) ? "" : csvExportSurfaceLineIdentifiers.Scenario; } } [CsvExportColumn(CsvExportSurfaceLineIdentifiers.CsvHeaderCalculationMechanism, -1)] public string CalculationMechanism { get { return (csvExportSurfaceLineIdentifiers == null) ? "" : csvExportSurfaceLineIdentifiers.CalculationMechanism; } } [CsvExportColumn(CsvExportSurfaceLineIdentifiers.CsvHeaderCalculationModel, 0)] public string CalculationModel { get { return (csvExportSurfaceLineIdentifiers == null) ? "" : csvExportSurfaceLineIdentifiers.CalculationModel; } } // The following properties are the real surfaceline data [CsvExportColumn("X1;Y1;Z1;.....;Xn;Yn;Zn;(Profiel)", 6)] public string SurfaceLines { get { StringBuilder sb = new StringBuilder(); foreach (GeometryPoint point in surfaceLine.Geometry.Points) { sb.Append(point.X.ToString(CultureInfo.InvariantCulture)); sb.Append(";"); sb.Append(point.Y.ToString(CultureInfo.InvariantCulture)); sb.Append(";"); sb.Append(point.Z.ToString(CultureInfo.InvariantCulture)); sb.Append(";"); } return sb.ToString(); } } } }