nautical-charts
![GitHub](https://img.shields.io/github/license/philliphoff/nautical-charts)
A pure JavaScript library for reading nautical chart files. In particular, for reading BSB-formatted (.bsb
and .kap
) files.
Installation
$ npm install nautical-charts --save
API Reference
Classes
- MemoryStream
A readable stream for an in-memory byte array.
Functions
- parseChart(stream) ⇒
Parses a BSB chart from a readable (e.g. file) stream.
- parseMetadata(textSegment) ⇒
Parses the text segment of a BSB chart and returns well-known metadata, if present.
- writeRasterSegment(rasterSegment, palette, buffer, bufferWidth)
Writes the RLE encoded raster data of a BSB chart to a bitmap.
MemoryStream
A readable stream for an in-memory byte array.
Kind: global class
new MemoryStream(contents, options)
The constructor for the MemoryStream
Param | Description |
---|
contents | The array from which to read. |
options | An optional set of readable stream options. |
parseChart(stream) ⇒
Parses a BSB chart from a readable (e.g. file) stream.
Kind: global function
Returns: A BSB chart.
Param | Description |
---|
stream | The stream from which to read the chart data. |
parseMetadata(textSegment) ⇒
Parses the text segment of a BSB chart and returns well-known metadata, if present.
Kind: global function
Returns: The metadata parsed from the chart.
Param | Description |
---|
textSegment | The text entries of the chart. |
writeRasterSegment(rasterSegment, palette, buffer, bufferWidth)
Writes the RLE encoded raster data of a BSB chart to a bitmap.
Kind: global function
Param | Description |
---|
rasterSegment | The rows of raster data for the chart. |
palette | The palette from which to obtain pixel values. |
buffer | The bitmap buffer in which to write the chart raster data. |
bufferWidth | The width of the bitmap buffer. |
License
MIT (see LICENSE.md)