Documentation
¶
Index ¶
- func AttributeCodeToString(code int) string
- func IsSupported(code int) bool
- func ObjectClassToInt(code string) (int, error)
- func ObjectClassToString(code int) (string, error)
- func ValidateCoordinate(lat, lon float64) error
- func ValidateFeature(feature *Feature) error
- func ValidateGeometry(geometry *Geometry) error
- type Chart
- func (c *Chart) ApplicationProfile() string
- func (c *Chart) Comment() string
- func (c *Chart) CompilationScale() int32
- func (c *Chart) CoordinateUnits() int
- func (c *Chart) DatasetName() string
- func (c *Chart) Edition() string
- func (c *Chart) ExchangePurpose() string
- func (c *Chart) HorizontalDatum() int
- func (c *Chart) IntendedUsage() int
- func (c *Chart) IssueDate() string
- func (c *Chart) ProducingAgency() int
- func (c *Chart) ProductSpecification() string
- func (c *Chart) S57Edition() string
- func (c *Chart) UpdateDate() string
- func (c *Chart) UpdateNumber() string
- type ErrInvalidCoordinate
- type ErrInvalidGeometry
- type ErrInvalidSpatialRecord
- type ErrMissingSpatialRecord
- type ErrUnknownObjectClass
- type Feature
- type Geometry
- type GeometryType
- type ParseOptions
- type Parser
- type UpdateInstruction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttributeCodeToString ¶
AttributeCodeToString converts S-57 numeric attribute code to string acronym S-57 Appendix A Chapter 2: Attribute Catalogue
func IsSupported ¶
IsSupported checks if an object class code is valid All object classes defined in S-57 standard are "supported" for parsing The question is whether we have rendering logic for them (deferred to later iterations)
func ObjectClassToInt ¶
ObjectClassToInt converts string code to numeric object class S-57 object classes are identified by numeric codes in the binary data
func ObjectClassToString ¶
ObjectClassToString converts S-57 numeric object class to string code The object class codes are read from the S-57 file's FRID records and mapped using the S-57 Object Catalogue S-57 Appendix A: Object Catalogue
func ValidateCoordinate ¶
ValidateCoordinate validates a single coordinate pair S-57 coordinates must be within valid geographic bounds
func ValidateFeature ¶
ValidateFeature validates a feature per S-57 rules
func ValidateGeometry ¶
ValidateGeometry validates geometry per S-57 spatial rules S-57 §7.3: Geometry validation rules
Types ¶
type Chart ¶
type Chart struct {
Features []Feature // Public - array of extracted features
// contains filtered or unexported fields
}
Chart represents a complete S-57 Electronic Navigational Chart. This is the top-level structure returned by the parser.
Reference: S-57 Part 3 §7 (31Main.pdf p3.31): Structure implementation showing how datasets are composed of metadata and feature records.
func (*Chart) ApplicationProfile ¶
ApplicationProfile returns human-readable application profile.
func (*Chart) CompilationScale ¶
CompilationScale returns the compilation scale from the DSPM record. S-57 §7.3.2.1 CSCL field: scale denominator (e.g., 50000 for 1:50,000).
func (*Chart) CoordinateUnits ¶
CoordinateUnits returns the coordinate units from the DSPM record. S-57 §7.3.2.1 COUN field: 1=lat/lon, 2=eastings/northings.
func (*Chart) DatasetName ¶
DatasetName returns the chart's dataset name (cell identifier).
func (*Chart) ExchangePurpose ¶
ExchangePurpose returns human-readable exchange purpose ("New" or "Revision").
func (*Chart) HorizontalDatum ¶
HorizontalDatum returns the horizontal datum code from the DSPM record. S-57 §7.3.2.1 HDAT field: 2=WGS-84 (most common).
func (*Chart) IntendedUsage ¶
IntendedUsage returns the intended usage (navigational purpose) code.
Values per S-57 specification:
1 = Overview, 2 = General, 3 = Coastal, 4 = Approach, 5 = Harbour, 6 = Berthing
func (*Chart) ProducingAgency ¶
ProducingAgency returns the producing agency code.
func (*Chart) ProductSpecification ¶
ProductSpecification returns human-readable product spec ("ENC" or "ODD").
func (*Chart) S57Edition ¶
S57Edition returns the S-57 standard edition used (e.g., "03.1").
func (*Chart) UpdateDate ¶
UpdateDate returns the update application date (YYYYMMDD).
func (*Chart) UpdateNumber ¶
UpdateNumber returns the chart's update number.
type ErrInvalidCoordinate ¶
type ErrInvalidCoordinate struct {
Lat, Lon float64
}
ErrInvalidCoordinate indicates coordinate out of valid bounds
func (*ErrInvalidCoordinate) Error ¶
func (e *ErrInvalidCoordinate) Error() string
type ErrInvalidGeometry ¶
type ErrInvalidGeometry struct {
Type GeometryType
Reason string
}
ErrInvalidGeometry indicates geometry violates S-57 rules
func (*ErrInvalidGeometry) Error ¶
func (e *ErrInvalidGeometry) Error() string
type ErrInvalidSpatialRecord ¶
ErrInvalidSpatialRecord indicates spatial record is not of expected type
func (*ErrInvalidSpatialRecord) Error ¶
func (e *ErrInvalidSpatialRecord) Error() string
type ErrMissingSpatialRecord ¶
ErrMissingSpatialRecord indicates FSPT pointer references non-existent spatial record
func (*ErrMissingSpatialRecord) Error ¶
func (e *ErrMissingSpatialRecord) Error() string
type ErrUnknownObjectClass ¶
type ErrUnknownObjectClass struct {
Code int
}
ErrUnknownObjectClass indicates unsupported S-57 object class
func (*ErrUnknownObjectClass) Error ¶
func (e *ErrUnknownObjectClass) Error() string
type Feature ¶
type Feature struct {
// ID is the unique feature identifier from the FRID record
ID int64
// ObjectClass is the S-57 object class code (e.g., "DEPCNT", "DEPARE", "BOYCAR")
ObjectClass string
// Geometry is the spatial representation of the feature
Geometry Geometry
// Attributes contains feature attributes as key-value pairs
// Common attributes: DRVAL1 (depth), COLOUR (color), OBJNAM (name)
Attributes map[string]interface{}
}
Feature represents a navigational object extracted from S-57 chart data S-57 §2.1: Feature objects contain geometric and attribute information
type Geometry ¶
type Geometry struct {
// Type is the geometry type (Point, LineString, or Polygon)
Type GeometryType
// Coordinates is an array of [longitude, latitude] pairs
// Per GeoJSON convention: [lon, lat]
Coordinates [][]float64
}
Geometry represents the spatial representation of a feature S-57 §7.3: Spatial record structure
type GeometryType ¶
type GeometryType int
GeometryType represents the type of geometry for a feature
const ( // GeometryTypePoint represents a single point location GeometryTypePoint GeometryType = iota // GeometryTypeLineString represents a line composed of connected points GeometryTypeLineString // GeometryTypePolygon represents a closed polygon area GeometryTypePolygon )
func (GeometryType) String ¶
func (g GeometryType) String() string
String returns the string representation of the geometry type
type ParseOptions ¶
type ParseOptions struct {
// SkipUnknownFeatures: if true, skip features with unknown object classes
// Default: false (return error on unknown types)
SkipUnknownFeatures bool
// ValidateGeometry: if true, validate all coordinates and geometry rules
// Default: true
ValidateGeometry bool
// ObjectClassFilter: if non-empty, only extract these object classes
// Empty means extract all supported types
ObjectClassFilter []string
// ApplyUpdates: if true, automatically discover and apply update files (.001, .002, etc.)
// Default: true
ApplyUpdates bool
// Fs is the filesystem to use for reading files
// If nil, the OS filesystem is used
Fs afero.Fs
}
ParseOptions configures parsing behavior
func DefaultParseOptions ¶
func DefaultParseOptions() ParseOptions
DefaultParseOptions returns parse options with defaults
type Parser ¶
type Parser interface {
// Parse reads an S-57 file and returns extracted chart
// Returns error if file cannot be read or parsed
Parse(filename string) (*Chart, error)
// ParseWithOptions parses with custom options
ParseWithOptions(filename string, opts ParseOptions) (*Chart, error)
// SupportedObjectClasses returns list of supported S-57 object classes
SupportedObjectClasses() []string
}
Parser parses S-57 ENC files and extracts features.
S-57 defines an "exchange set" as a collection of files for transferring hydrographic data. Each file contains records (metadata, features, spatial data) structured per ISO 8211. This parser reads the ISO 8211 structure and interprets it according to S-57 semantics.
References:
- S-57 Part 1 (31Main.pdf p1.1): Definition of "exchange set"
- S-57 Part 3 §7 (31Main.pdf p3.31): Complete record and field structure specification
func DefaultParser ¶
DefaultParser returns parser with default options
type UpdateInstruction ¶
type UpdateInstruction int
UpdateInstruction represents the RUIN (Record Update Instruction) field values S-57 Part 3 §8.4.2.2 and §8.4.3.2
const ( // UpdateInsert indicates a record should be inserted (RUIN = 1) UpdateInsert UpdateInstruction = 1 // UpdateDelete indicates a record should be deleted (RUIN = 2) UpdateDelete UpdateInstruction = 2 // UpdateModify indicates a record should be modified (RUIN = 3) UpdateModify UpdateInstruction = 3 )