Table of Contents

Class LineEvents

Namespace
SpatialNET
Assembly
SpatialNET.Extensions.dll

Interval arithmetic on the events of a route (ADR 0033): which events hold at the same time (Intersect), the route cut at every boundary of two tables (Union), what one table has that the other has not (Difference), neighbours with the same value joined (Dissolve), and cutting to a range (Clip) or to a point (At). The operations compute with the M values only: no geometry, no factory. Draw an event with SpatialNET.LinearReferencing.LocateBetween(SpatialNET.IPolyline2D,System.Double,System.Double,SpatialNET.IGeometryFactory) on the calibrated route.

public static class LineEvents

Inheritance

Inherited Members

Remarks

Ranges are closed, but only a range with length counts: an event with From == To is ignored, and an operation never returns a piece without length (as Substring in ADR 0017). Events are not touched by the order of the input; results are sorted by From, then To. The operations work on one route: group a table by route yourself before calling them.

The methods are static and not extension methods so that they do not collide with Enumerable.Union, Intersect and the like.

Methods

At<T>(IEnumerable<LineEvent<T>>, double)

The events that hold at an M value. The ranges are closed, so at the boundary of two neighbouring events both are returned.

public static IReadOnlyList<LineEvent<T>> At<T>(IEnumerable<LineEvent<T>> events, double m)

Parameters

events IEnumerable<LineEvent<T>>

The events.

m double

The M value, for example of a bridge.

Returns

IReadOnlyList<LineEvent<T>>

The events whose range contains m, sorted.

Type Parameters

T

The values.

Exceptions

ArgumentNullException

events is null.

ArgumentOutOfRangeException

An event has a From or To that is NaN or infinite, or m is.

Clip<T>(IEnumerable<LineEvent<T>>, double, double)

The events cut to the range between two M values; an event outside it is dropped.

public static IReadOnlyList<LineEvent<T>> Clip<T>(IEnumerable<LineEvent<T>> events, double from, double to)

Parameters

events IEnumerable<LineEvent<T>>

The events.

from double

One end of the range.

to double

The other end; if it is lower than from they are swapped.

Returns

IReadOnlyList<LineEvent<T>>

The events inside the range, sorted.

Type Parameters

T

The values.

Exceptions

ArgumentNullException

events is null.

ArgumentOutOfRangeException

An event has a From or To that is NaN or infinite, or from or to is.

Difference<TA, TB>(IEnumerable<LineEvent<TA>>, IEnumerable<LineEvent<TB>>)

The parts of the events of a that no event of b covers, with the values of a. An event of a that another event of b splits gives two pieces.

public static IReadOnlyList<LineEvent<TA>> Difference<TA, TB>(IEnumerable<LineEvent<TA>> a, IEnumerable<LineEvent<TB>> b)

Parameters

a IEnumerable<LineEvent<TA>>

The events to take from.

b IEnumerable<LineEvent<TB>>

The events whose ranges are taken away.

Returns

IReadOnlyList<LineEvent<TA>>

The pieces, sorted.

Type Parameters

TA

The values of the first table.

TB

The values of the second table; not used.

Remarks

Only the range of the events of b counts, not their values; they may overlap each other.

Exceptions

ArgumentNullException

An argument is null.

ArgumentOutOfRangeException

An event has a From or To that is NaN or infinite.

Dissolve<T>(IEnumerable<LineEvent<T>>, IEqualityComparer<T>?)

Joins events that touch or overlap and have the same value into one event. Events with different values are left as they are, even where they overlap. Use it after SpatialNET.LineEvents.Union``3(System.Collections.Generic.IEnumerable{SpatialNET.LineEvent{``0}},System.Collections.Generic.IEnumerable{SpatialNET.LineEvent{``1}},System.Func{``0,``1,``2},System.Func{``0,``2},System.Func{``1,``2}) or SpatialNET.LineEvents.Intersect``3(System.Collections.Generic.IEnumerable{SpatialNET.LineEvent{``0}},System.Collections.Generic.IEnumerable{SpatialNET.LineEvent{``1}},System.Func{``0,``1,``2}), which cut at every boundary.

public static IReadOnlyList<LineEvent<T>> Dissolve<T>(IEnumerable<LineEvent<T>> events, IEqualityComparer<T>? comparer = null)

Parameters

events IEnumerable<LineEvent<T>>

The events.

comparer IEqualityComparer<T>?

Tells whether two values are the same; null = the default comparer of T.

Returns

IReadOnlyList<LineEvent<T>>

The events, sorted.

Type Parameters

T

The values.

Exceptions

ArgumentNullException

events is null.

ArgumentOutOfRangeException

An event has a From or To that is NaN or infinite.

Intersect<TA, TB, TResult>(IEnumerable<LineEvent<TA>>, IEnumerable<LineEvent<TB>>, Func<TA, TB, TResult>)

The pieces where an event of a and an event of b hold at the same time, one per pair, with the value that combine makes of the two values. Where only one table has an event, nothing is returned.

public static IReadOnlyList<LineEvent<TResult>> Intersect<TA, TB, TResult>(IEnumerable<LineEvent<TA>> a, IEnumerable<LineEvent<TB>> b, Func<TA, TB, TResult> combine)

Parameters

a IEnumerable<LineEvent<TA>>

The first table.

b IEnumerable<LineEvent<TB>>

The second table.

combine Func<TA, TB, TResult>

Makes the value of a piece from the two values.

Returns

IReadOnlyList<LineEvent<TResult>>

The pieces, sorted.

Type Parameters

TA

The values of the first table.

TB

The values of the second table.

TResult

The values of the result.

Remarks

Events of one table may overlap; every overlapping pair gives a piece.

Exceptions

ArgumentNullException

An argument is null.

ArgumentOutOfRangeException

An event has a From or To that is NaN or infinite.

Union<TA, TB, TResult>(IEnumerable<LineEvent<TA>>, IEnumerable<LineEvent<TB>>, Func<TA, TB, TResult>, Func<TA, TResult>, Func<TB, TResult>)

The route cut at every boundary of either table: each piece that has an event in at least one table, with the value of both where both have one, of onlyA or onlyB where only one has. Pieces that neither table covers are not returned. Neighbouring pieces with equal values are not joined; use SpatialNET.LineEvents.Dissolve``1(System.Collections.Generic.IEnumerable{SpatialNET.LineEvent{``0}},System.Collections.Generic.IEqualityComparer{``0}).

public static IReadOnlyList<LineEvent<TResult>> Union<TA, TB, TResult>(IEnumerable<LineEvent<TA>> a, IEnumerable<LineEvent<TB>> b, Func<TA, TB, TResult> both, Func<TA, TResult> onlyA, Func<TB, TResult> onlyB)

Parameters

a IEnumerable<LineEvent<TA>>

The first table.

b IEnumerable<LineEvent<TB>>

The second table.

both Func<TA, TB, TResult>

The value of a piece covered by both tables.

onlyA Func<TA, TResult>

The value of a piece covered only by a.

onlyB Func<TB, TResult>

The value of a piece covered only by b.

Returns

IReadOnlyList<LineEvent<TResult>>

The pieces, sorted.

Type Parameters

TA

The values of the first table.

TB

The values of the second table.

TResult

The values of the result.

Remarks

The events of one table must not overlap (touching is fine), since otherwise a piece would have two values from the same table.

Exceptions

ArgumentNullException

An argument is null.

ArgumentOutOfRangeException

An event has a From or To that is NaN or infinite.

ArgumentException

Events of one table overlap.