/// <summary> /// Creates a collection of Lithologic Subintervals of a specific resolution. /// </summary> public void GenerateSubintervals() { //Cases: where start and end are the same //One Subinterval //Case: where start is less than end //If end-start is less than resolution: one subinterval //if end-start is greater than resoltuion: end-start/resolution rounded up to nearest int is the number of subintervals //Case: Accidentlly reversing End and Start Offset int subintervalCount = (int)Math.Ceiling((decimal)((EndOffset - StartOffset) / _resolution)); if (subintervalCount == 0) { LithologicSubinterval subinterval = new LithologicSubinterval(0, this); LithologicSubintervals.Add(subinterval); } else { for (int currentSubintervalID = 1; currentSubintervalID <= subintervalCount; currentSubintervalID++) { LithologicSubinterval subinterval = new LithologicSubinterval(currentSubintervalID, this); //Problem here is that you possibly create an extra longer interval because of the rounding error with the resolution and interval start-end distance. //I'll leave it in because the measurement is based off the Description Interval--which is correct. The subinterval offsets are not output to file. subinterval.StartOffset = StartOffset + _resolution * (currentSubintervalID - 1); subinterval.EndOffset = StartOffset + _resolution * currentSubintervalID; //need to determine how subintervals will be uniquely named LithologicSubintervals.Add(subinterval); } } }
/// <summary> /// Returns the Lithologic Subinterval for an offset within the bounds of this Lithologic Description. /// </summary> public LithologicSubinterval GetSubinterval(Interval interval) { return(LithologicSubintervals.FirstOrDefault(z => z.Contains(interval))); }