Class S57Chart
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
isolatedNodesIReadOnlyDictionary<S57RecordName, S57IsolatedNode>connectedNodesIReadOnlyDictionary<S57RecordName, S57ConnectedNode>edgesIReadOnlyDictionary<S57RecordName, S57Edge>facesIReadOnlyDictionary<S57RecordName, S57Face>pointFeaturesIReadOnlyList<S57PointFeature>lineFeaturesIReadOnlyList<S57LineFeature>areaFeaturesIReadOnlyList<S57AreaFeature>metaFeaturesIReadOnlyList<S57MetaFeature>identificationS57DataSetIdentificationparametersS57DataSetParameters
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
AreaFeatures
Gets all area features.
public IReadOnlyList<S57AreaFeature> AreaFeatures { get; }
Property Value
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
CompilationScale
Gets the compilation scale of the chart.
public int CompilationScale { get; }
Property Value
ConnectedNodes
Gets connected nodes indexed by their record name.
public IReadOnlyDictionary<S57RecordName, S57ConnectedNode> ConnectedNodes { get; }
Property Value
CoordinateMultiplicationFactor
Gets the coordinate multiplication factor for converting integer coordinates to decimal degrees.
public int CoordinateMultiplicationFactor { get; }
Property Value
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
Edges
Gets edges indexed by their record name.
public IReadOnlyDictionary<S57RecordName, S57Edge> Edges { get; }
Property Value
Faces
Gets faces indexed by their record name.
public IReadOnlyDictionary<S57RecordName, S57Face> Faces { get; }
Property Value
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
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
Identification
Gets the data set identification information.
public S57DataSetIdentification? Identification { get; }
Property Value
IsolatedNodes
Gets isolated nodes indexed by their record name.
public IReadOnlyDictionary<S57RecordName, S57IsolatedNode> IsolatedNodes { get; }
Property Value
LineFeatures
Gets all line features.
public IReadOnlyList<S57LineFeature> LineFeatures { get; }
Property Value
MetaFeatures
Gets all meta features (features without geometry).
public IReadOnlyList<S57MetaFeature> MetaFeatures { get; }
Property Value
Parameters
Gets the data set parameters (coordinate systems, scales, etc.).
public S57DataSetParameters? Parameters { get; }
Property Value
PointFeatures
Gets all point features.
public IReadOnlyList<S57PointFeature> PointFeatures { get; }
Property Value
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
SoundingMultiplicationFactor
Gets the sounding multiplication factor for converting integer soundings to real values.
public int SoundingMultiplicationFactor { get; }
Property Value
Methods
FromDocument(S57Document)
Creates a strongly-typed chart from an S-57 document.
public static S57Chart FromDocument(S57Document document)
Parameters
documentS57DocumentThe 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
pathstringThe 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
pathstringThe path to the S-57 file.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
FromStream(Stream)
Loads a chart from a stream.
public static S57Chart FromStream(Stream stream)
Parameters
streamStreamThe 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
streamStreamThe stream containing S-57 data.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
GetColocatedPointFeatures(S57RecordName)
Gets all point features that reference the specified spatial record (co-located features).
public IReadOnlyList<S57PointFeature> GetColocatedPointFeatures(S57RecordName spatialName)
Parameters
spatialNameS57RecordNameThe 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
nameS57RecordNameThe record name.
Returns
- S57ConnectedNode
The connected node, or
nullif not found.
GetEdge(S57RecordName)
Gets an edge by its record name.
public S57Edge? GetEdge(S57RecordName name)
Parameters
nameS57RecordNameThe record name.
Returns
- S57Edge
The edge, or
nullif not found.
GetFace(S57RecordName)
Gets a face by its record name.
public S57Face? GetFace(S57RecordName name)
Parameters
nameS57RecordNameThe record name.
Returns
- S57Face
The face, or
nullif 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
longNameS57LongNameThe long name (LNAM) to find.
Returns
- S57TypedFeature
The feature, or
nullif 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
nameS57RecordNameThe record name.
Returns
- S57IsolatedNode
The isolated node, or
nullif not found.
GetReferencingFeatures(S57LongName)
Gets the features whose feature pointers refer to the specified feature.
public IReadOnlyList<S57TypedFeature> GetReferencingFeatures(S57LongName longName)
Parameters
longNameS57LongNameThe 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
coordinateS57Coordinate2DThe coordinate to convert.
Returns
ToDecimalDegrees(int)
Converts an integer coordinate to decimal degrees.
public double ToDecimalDegrees(int coordinate)
Parameters
coordinateintThe 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
soundingS57SoundingThe sounding to convert.