Table of Contents

Class S57Chart

Namespace
EncDotNet.S57.Charts
Assembly
EncDotNet.S57.dll

Represents a strongly-typed S-57 Electronic Navigational Chart (ENC).

public sealed record S57Chart : IEquatable<S57Chart>
Inheritance
S57Chart
Implements
Inherited Members

Remarks

This class provides a higher-level, strongly-typed view of an S-57 chart document. It transforms the generic S57Document model into specialized types for each kind of spatial and feature record.

Use FromDocument(S57Document) to create an instance from an S57Document, or use FromFile(string) to load directly from a file.

Constructors

S57Chart(IReadOnlyDictionary<S57RecordName, S57IsolatedNode>?, IReadOnlyDictionary<S57RecordName, S57ConnectedNode>?, IReadOnlyDictionary<S57RecordName, S57Edge>?, IReadOnlyDictionary<S57RecordName, S57Face>?, IReadOnlyList<S57PointFeature>?, IReadOnlyList<S57LineFeature>?, IReadOnlyList<S57AreaFeature>?, IReadOnlyList<S57MetaFeature>?, S57DataSetIdentification?, S57DataSetParameters?)

Initializes a new instance of the S57Chart class with explicit spatial and feature data.

public S57Chart(IReadOnlyDictionary<S57RecordName, S57IsolatedNode>? isolatedNodes = null, IReadOnlyDictionary<S57RecordName, S57ConnectedNode>? connectedNodes = null, IReadOnlyDictionary<S57RecordName, S57Edge>? edges = null, IReadOnlyDictionary<S57RecordName, S57Face>? faces = null, IReadOnlyList<S57PointFeature>? pointFeatures = null, IReadOnlyList<S57LineFeature>? lineFeatures = null, IReadOnlyList<S57AreaFeature>? areaFeatures = null, IReadOnlyList<S57MetaFeature>? metaFeatures = null, S57DataSetIdentification? identification = null, S57DataSetParameters? parameters = null)

Parameters

isolatedNodes IReadOnlyDictionary<S57RecordName, S57IsolatedNode>
connectedNodes IReadOnlyDictionary<S57RecordName, S57ConnectedNode>
edges IReadOnlyDictionary<S57RecordName, S57Edge>
faces IReadOnlyDictionary<S57RecordName, S57Face>
pointFeatures IReadOnlyList<S57PointFeature>
lineFeatures IReadOnlyList<S57LineFeature>
areaFeatures IReadOnlyList<S57AreaFeature>
metaFeatures IReadOnlyList<S57MetaFeature>
identification S57DataSetIdentification
parameters S57DataSetParameters

Remarks

This constructor is intended primarily for testing scenarios where chart data needs to be constructed without parsing an S-57 document.

Properties

AllFeatures

Gets all features indexed by their record name.

public IReadOnlyDictionary<S57RecordName, S57TypedFeature> AllFeatures { get; }

Property Value

IReadOnlyDictionary<S57RecordName, S57TypedFeature>

AreaFeatures

Gets all area features.

public IReadOnlyList<S57AreaFeature> AreaFeatures { get; }

Property Value

IReadOnlyList<S57AreaFeature>

ColocatedPointFeatures

Gets the spatial co-location index: maps a spatial record name to all point features that reference it via FSPT (feature-to-spatial pointers).

public IReadOnlyDictionary<S57RecordName, IReadOnlyList<S57PointFeature>> ColocatedPointFeatures { get; }

Property Value

IReadOnlyDictionary<S57RecordName, IReadOnlyList<S57PointFeature>>

CompilationScale

Gets the compilation scale of the chart.

public int CompilationScale { get; }

Property Value

int

ConnectedNodes

Gets connected nodes indexed by their record name.

public IReadOnlyDictionary<S57RecordName, S57ConnectedNode> ConnectedNodes { get; }

Property Value

IReadOnlyDictionary<S57RecordName, S57ConnectedNode>

CoordinateMultiplicationFactor

Gets the coordinate multiplication factor for converting integer coordinates to decimal degrees.

public int CoordinateMultiplicationFactor { get; }

Property Value

int

CoverageAreas

Gets the M_COVR area features with CATCOV=1 (coverage available). These define the geographic areas where this chart provides data coverage.

public IReadOnlyList<S57AreaFeature> CoverageAreas { get; }

Property Value

IReadOnlyList<S57AreaFeature>

Edges

Gets edges indexed by their record name.

public IReadOnlyDictionary<S57RecordName, S57Edge> Edges { get; }

Property Value

IReadOnlyDictionary<S57RecordName, S57Edge>

Faces

Gets faces indexed by their record name.

public IReadOnlyDictionary<S57RecordName, S57Face> Faces { get; }

Property Value

IReadOnlyDictionary<S57RecordName, S57Face>

FeaturesByLongName

Gets the features that have a long name (LNAM), indexed by it. Feature pointers (RelatedFeatures) refer to features by long name.

public IReadOnlyDictionary<S57LongName, S57TypedFeature> FeaturesByLongName { get; }

Property Value

IReadOnlyDictionary<S57LongName, S57TypedFeature>

FeaturesByObjectCode

Gets all features grouped by object code. Each entry contains the point, line, area, and meta features that share that object code.

public IReadOnlyDictionary<S57ObjectCode, S57ObjectCodeFeatures> FeaturesByObjectCode { get; }

Property Value

IReadOnlyDictionary<S57ObjectCode, S57ObjectCodeFeatures>

Identification

Gets the data set identification information.

public S57DataSetIdentification? Identification { get; }

Property Value

S57DataSetIdentification

IsolatedNodes

Gets isolated nodes indexed by their record name.

public IReadOnlyDictionary<S57RecordName, S57IsolatedNode> IsolatedNodes { get; }

Property Value

IReadOnlyDictionary<S57RecordName, S57IsolatedNode>

LineFeatures

Gets all line features.

public IReadOnlyList<S57LineFeature> LineFeatures { get; }

Property Value

IReadOnlyList<S57LineFeature>

MetaFeatures

Gets all meta features (features without geometry).

public IReadOnlyList<S57MetaFeature> MetaFeatures { get; }

Property Value

IReadOnlyList<S57MetaFeature>

Parameters

Gets the data set parameters (coordinate systems, scales, etc.).

public S57DataSetParameters? Parameters { get; }

Property Value

S57DataSetParameters

PointFeatures

Gets all point features.

public IReadOnlyList<S57PointFeature> PointFeatures { get; }

Property Value

IReadOnlyList<S57PointFeature>

ReferencingFeatures

Gets the reverse feature-pointer index: maps a feature's long name to all features that reference it via FFPT (feature-to-feature pointers).

public IReadOnlyDictionary<S57LongName, IReadOnlyList<S57TypedFeature>> ReferencingFeatures { get; }

Property Value

IReadOnlyDictionary<S57LongName, IReadOnlyList<S57TypedFeature>>

SoundingMultiplicationFactor

Gets the sounding multiplication factor for converting integer soundings to real values.

public int SoundingMultiplicationFactor { get; }

Property Value

int

Methods

FromDocument(S57Document)

Creates a strongly-typed chart from an S-57 document.

public static S57Chart FromDocument(S57Document document)

Parameters

document S57Document

The source S-57 document.

Returns

S57Chart

A strongly-typed chart model.

FromFile(string)

Loads a chart from an S-57 file.

public static S57Chart FromFile(string path)

Parameters

path string

The path to the S-57 file.

Returns

S57Chart

A strongly-typed chart model.

FromFileAsync(string, CancellationToken)

Asynchronously loads a chart from an S-57 file.

public static Task<S57Chart> FromFileAsync(string path, CancellationToken cancellationToken = default)

Parameters

path string

The path to the S-57 file.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<S57Chart>

A task that represents the asynchronous load operation.

FromStream(Stream)

Loads a chart from a stream.

public static S57Chart FromStream(Stream stream)

Parameters

stream Stream

The stream containing S-57 data.

Returns

S57Chart

A strongly-typed chart model.

FromStreamAsync(Stream, CancellationToken)

Asynchronously loads a chart from a stream.

public static Task<S57Chart> FromStreamAsync(Stream stream, CancellationToken cancellationToken = default)

Parameters

stream Stream

The stream containing S-57 data.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<S57Chart>

A task that represents the asynchronous load operation.

GetColocatedPointFeatures(S57RecordName)

Gets all point features that reference the specified spatial record (co-located features).

public IReadOnlyList<S57PointFeature> GetColocatedPointFeatures(S57RecordName spatialName)

Parameters

spatialName S57RecordName

The record name of the spatial record.

Returns

IReadOnlyList<S57PointFeature>

All point features at the same spatial node, or an empty array if none.

GetConnectedNode(S57RecordName)

Gets a connected node by its record name.

public S57ConnectedNode? GetConnectedNode(S57RecordName name)

Parameters

name S57RecordName

The record name.

Returns

S57ConnectedNode

The connected node, or null if not found.

GetEdge(S57RecordName)

Gets an edge by its record name.

public S57Edge? GetEdge(S57RecordName name)

Parameters

name S57RecordName

The record name.

Returns

S57Edge

The edge, or null if not found.

GetFace(S57RecordName)

Gets a face by its record name.

public S57Face? GetFace(S57RecordName name)

Parameters

name S57RecordName

The record name.

Returns

S57Face

The face, or null if not found.

GetFeature(S57LongName)

Gets the feature with the specified long name, such as the target of a feature pointer.

public S57TypedFeature? GetFeature(S57LongName longName)

Parameters

longName S57LongName

The long name (LNAM) to find.

Returns

S57TypedFeature

The feature, or null if the chart has none with that long name.

Examples

foreach (var pointer in feature.RelatedFeatures)
{
    S57TypedFeature? related = chart.GetFeature(pointer.Name);
}

GetIsolatedNode(S57RecordName)

Gets an isolated node by its record name.

public S57IsolatedNode? GetIsolatedNode(S57RecordName name)

Parameters

name S57RecordName

The record name.

Returns

S57IsolatedNode

The isolated node, or null if not found.

GetReferencingFeatures(S57LongName)

Gets the features whose feature pointers refer to the specified feature.

public IReadOnlyList<S57TypedFeature> GetReferencingFeatures(S57LongName longName)

Parameters

longName S57LongName

The long name (LNAM) of the referenced feature.

Returns

IReadOnlyList<S57TypedFeature>

The referencing features, or an empty list if there are none.

ToDecimalDegrees(S57Coordinate2D)

Converts a 2D coordinate to decimal degrees.

public (double Longitude, double Latitude) ToDecimalDegrees(S57Coordinate2D coordinate)

Parameters

coordinate S57Coordinate2D

The coordinate to convert.

Returns

(double X, double Y)

A tuple of (Longitude, Latitude) in decimal degrees.

ToDecimalDegrees(int)

Converts an integer coordinate to decimal degrees.

public double ToDecimalDegrees(int coordinate)

Parameters

coordinate int

The integer coordinate.

Returns

double

The coordinate in decimal degrees.

ToDecimalValues(S57Sounding)

Converts a sounding to decimal degrees and depth.

public (double Longitude, double Latitude, double Depth) ToDecimalValues(S57Sounding sounding)

Parameters

sounding S57Sounding

The sounding to convert.

Returns

(double Distance, double Lat, double Lon)

A tuple of (Longitude, Latitude, Depth).