You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
4.6 KiB
C#
126 lines
4.6 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace Unplugged.Segy
|
|
{
|
|
class SegyFile : ISegyFile
|
|
{
|
|
public IFileHeader Header { get; set; }
|
|
public IList<ITrace> Traces { get; set; }
|
|
|
|
public ISurveyLine StartInline { get; set; } = null;
|
|
public ISurveyLine StartCrossline { get; set; } = null;
|
|
public ValueRange FindRange()
|
|
{
|
|
var min = float.MaxValue;
|
|
var max = float.MinValue;
|
|
foreach (var trace in Traces)
|
|
foreach (var value in trace.Values)
|
|
{
|
|
if (value < min) min = value;
|
|
if (value > max) max = value;
|
|
}
|
|
return new ValueRange { Min = min, Max = max, Delta = max - min };
|
|
}
|
|
public void GetLineRange(ref int inlineMin, ref int inlineMax
|
|
, ref int crosslineMin, ref int crosslineMax
|
|
, ref int delay, ISegyOptions options = null)
|
|
{
|
|
if (options != null)
|
|
{
|
|
int nTraceCount = Traces.Count;
|
|
for (int i = 0; i < nTraceCount; i++)
|
|
{
|
|
Traces[i].Header.InlineNumber = Traces[i].Header.GetValue(
|
|
options.TraceHeaderLocationForInlineNumber, 4,
|
|
options.IsLittleEndian.Value);
|
|
Traces[i].Header.CrosslineNumber = Traces[i].Header.GetValue(
|
|
options.TraceHeaderLocationForCrosslineNumber, 4,
|
|
options.IsLittleEndian.Value);
|
|
}
|
|
}
|
|
inlineMin = int.MaxValue;
|
|
inlineMax = int.MinValue;
|
|
crosslineMin = int.MaxValue;
|
|
crosslineMax = int.MinValue;
|
|
foreach (ITrace trace in Traces)
|
|
{
|
|
if (trace.Header.InlineNumber < inlineMin)
|
|
{
|
|
inlineMin = trace.Header.InlineNumber;
|
|
}
|
|
if(trace.Header.InlineNumber > inlineMax)
|
|
{
|
|
inlineMax = trace.Header.InlineNumber;
|
|
}
|
|
if (trace.Header.CrosslineNumber < crosslineMin)
|
|
{
|
|
crosslineMin = trace.Header.CrosslineNumber;
|
|
}
|
|
if (trace.Header.CrosslineNumber > crosslineMax)
|
|
{
|
|
crosslineMax = trace.Header.CrosslineNumber;
|
|
}
|
|
}
|
|
|
|
delay = Traces[0].Header.Delay;
|
|
}
|
|
|
|
public void GetCoordinateRange(ref double xStart, ref double yStart, ref double xEnd, ref double yEnd)
|
|
{
|
|
int nTraceCount = Traces.Count;
|
|
xStart = Traces[0].Header.X;
|
|
yStart = Traces[0].Header.Y;
|
|
xEnd = Traces[nTraceCount - 1].Header.X;
|
|
yEnd = Traces[nTraceCount - 1].Header.Y;
|
|
}
|
|
public void ParseStartSurverLine(ref ISurveyLine startInline, ref ISurveyLine startCrossline)
|
|
{
|
|
int nTraceCount = Traces.Count;
|
|
List<int> lstInline = new List<int>();
|
|
List<int> lstCrossline = new List<int>();
|
|
int nInline = 0;// Traces[0].Header.InlineNumber;
|
|
int nCrossLine = 0;// Traces[0].Header.CrosslineNumber;
|
|
int i = 0;
|
|
for (i = 0; i < nTraceCount; i++)
|
|
{
|
|
nInline = Traces[i].Header.InlineNumber;
|
|
nCrossLine = Traces[i].Header.CrosslineNumber;
|
|
if (!lstInline.Contains(nInline))
|
|
{
|
|
lstInline.Add(nInline);
|
|
}
|
|
if (!lstCrossline.Contains(nCrossLine))
|
|
{
|
|
lstCrossline.Add(nCrossLine);
|
|
}
|
|
if (lstInline.Count > 1 && lstCrossline.Count > 1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
if (lstInline.Count == 2)
|
|
{
|
|
startInline.StartX = Traces[0].Header.X;
|
|
startInline.StartY = Traces[0].Header.Y;
|
|
|
|
startInline.EndX = Traces[i - 1].Header.X;
|
|
startInline.EndY = Traces[i - 1].Header.Y;
|
|
|
|
startInline.LineNo = lstInline[0];
|
|
startCrossline.LineNo = lstCrossline[0];
|
|
}
|
|
else if(lstCrossline.Count == 2)
|
|
{
|
|
startCrossline.StartX = Traces[0].Header.X;
|
|
startCrossline.StartY = Traces[0].Header.Y;
|
|
|
|
startCrossline.EndX = Traces[i - 1].Header.X;
|
|
startCrossline.EndY = Traces[i - 1].Header.Y;
|
|
|
|
startInline.LineNo = lstInline[0];
|
|
startCrossline.LineNo = lstCrossline[0];
|
|
}
|
|
}
|
|
}
|
|
}
|