@arl/leaflet-tracksymbol2
Version:
Leaflet track symbol
427 lines (410 loc) • 10.9 kB
TypeScript
import { LatLng } from 'leaflet';
import { LatLngBounds } from 'leaflet';
import { LatLngExpression } from 'leaflet';
import { Path } from 'leaflet';
import { PathOptions } from 'leaflet';
/** AIS message. */
export declare interface AISMessage {
/** MMSI number. */
userId?: number;
}
export declare class AISTrackSymbol extends TrackSymbol {
/** Default silhouette shape points. */
static DEFAULT_SILHOUETTE_SHAPE_POINTS: Points;
private readonly _leaderTime;
private readonly _minZoomLevel;
private readonly _size;
private _positionReport;
private _shipStaticData?;
/**
* AISTrackSymbol constructor.
*
* @param positionReport - Position report.
* @param options - Options.
*/
constructor(positionReport: PositionReport, options?: AISTrackSymbolOptions);
/**
* Get ETA from Date.
*
* @param date - Date.
* @returns ETA
*/
static etaFromDate(date: Date | null | undefined): ETA | undefined;
/**
* Sets the position report.
*
* @param positionReport - Position report.
* @returns this
*/
setPositionReport(positionReport: PositionReport): this;
/**
* Sets the ship static data.
*
* @param shipStaticData - Ship static data.
* @returns this
*/
setShipStaticData(shipStaticData?: ShipStaticData): this;
private static _getShapeOptions;
private static _getShapeSet;
private _getPopupContent;
}
/**
* AIS track symbol options.
*/
export declare interface AISTrackSymbolOptions extends TrackSymbolOptions {
/** The length of the leader (unit: s). */
leaderTime?: number;
/** Min zoom level for silhouette. */
minZoomLevel?: number;
/** Size (pixels). */
size?: number;
/** Ship static data. */
shipStaticData?: ShipStaticData;
}
/** Ship dimension. */
export declare interface Dimension {
/** To the bow (m). */
A: number;
/** To the stern (m). */
B: number;
/** To the port side (m). */
C: number;
/** To the starboard side (m). */
D: number;
}
/** ETA. */
export declare interface ETA {
/** Month. */
month: number;
/** Day. */
day: number;
/** Hour. */
hour: number;
/** Minute. */
minute: number;
}
/**
* Points.
*/
export declare type Points = [number, number][];
/** Position report. */
export declare interface PositionReport extends AISMessage {
/** Navigational status. */
navigationalStatus?: number;
/** Rate of turn. AIS encoded value. */
rateOfTurn?: number;
/** Speed over ground (knots), 102.3 = not available . */
sog?: number;
/** Position accuracy. */
positionAccuracy?: boolean;
/** Longitude. */
longitude: number;
/** Latitude. */
latitude: number;
/** Course over ground (degrees, 360 = not available, \> 360 not used). */
cog?: number;
/** True heading (degrees, 511 = not available) */
trueHeading?: number;
/** UTC second when the report was generated. 60 = not available, 61 = manual input mode, 62 = estimated / dead reckoning mode, 63 = inoperative) */
timestamp?: number;
/** Special manoeuvre indicator. */
specialManoeuvreIndicator?: number;
/** Receiver autonomous integrity monitoring flag. */
raim?: boolean;
}
/**
* Shape.
*/
export declare interface Shape {
/** Points. */
points: Points;
/** Center. */
center?: [number, number];
/** Length. */
length: number;
/** Breadth. */
breadth: number;
/** Units. */
units: Units;
}
/**
* Shape options.
*/
export declare interface ShapeOptions {
/** The length of the leader (unit: s). */
leaderTime?: number;
/** Shape set entries. */
shapeSetEntries?: ShapeSetEntry[];
/** Default shape set. */
defaultShapeSet?: ShapeSet;
}
/**
* Shape set.
*/
export declare interface ShapeSet {
/** 'withHeading' shape. */
withHeading: Shape;
/** 'withoutHeading' shape. */
withoutHeading: Shape;
}
/**
* Shape set entry.
*/
export declare interface ShapeSetEntry {
/** Shape set. */
shapeSet: ShapeSet;
/** Minimum zoom level. */
minZoomLevel: number;
}
/** Ship static data. */
export declare interface ShipStaticData extends AISMessage {
/** IMO number. */
imoNumber?: number;
/** Call sign. */
callSign?: string;
/** Name. */
name?: string;
/** Type of ship and cargo type. */
type?: number;
/** Overall dimension/reference for position. */
dimension?: Dimension;
/** Type of electronic position fixing device. */
fixType?: number;
/** ETA. */
eta?: ETA;
/** Maximum present static draught (m). */
maximumStaticDraught?: number;
/** Destination. */
destination?: string;
/** Data terminal equipment ready. */
dte?: boolean;
}
/**
* Track symbol.
*/
declare class TrackSymbol extends Path {
/** Default 'withHeading' shape points. */
static DEFAULT_HEADING_SHAPE_POINTS: Points;
/** Default 'withoutHeading' shape points. */
static DEFAULT_NOHEADING_SHAPE_POINTS: Points;
/** Default shape set. */
private static DEFAULT_SHAPE_SET;
/** Location. */
private _latLng;
/** Heading (radians, from north, clockwise. */
private _heading?;
/** Course (radians, from north, clockwise. */
private _course?;
/** Speed (m/s). */
private _speed?;
/** Shape options. */
private _shapeOptions;
/** Current shape points. */
private _currentShapePoints;
/** Current leader points. */
private _currentLeaderPoints;
/** Current bounds. */
private _currentBounds;
/** Current lat/lng bounds. */
private _currentLatLngBounds;
/**
* TrackSymbol constructor.
*
* @param latLng - Initial location.
* @param options - Options.
*/
constructor(latLng: LatLngExpression, options?: TrackSymbolOptions);
/**
* Project to layer.
*
* [Leaflet internal]
*/
protected _project(): void;
/**
* Update element.
*
* [Leaflet internal]
*/
protected _update(): void;
/**
* Set shape options.
*
* @param shapeOptions - Shape options.
*/
private _setShapeOptions;
/**
* Sets the location.
*
* @param latLng - Location.
* @returns this
*/
setLatLng(latLng: LatLngExpression): this;
/**
* Sets the heading.
*
* @param heading - Heading (unit: radians, from north, clockwise).
* @returns this
*/
setHeading(heading: number | undefined): this;
/**
* Sets the course over ground.
*
* @param course - Course over ground (unit: radians, from north, clockwise).
* @returns this
*/
setCourse(course: number | undefined): this;
/**
* Sets the speed.
*
* @param speed - Speed (unit: m/s).
* @returns this
*/
setSpeed(speed: number | undefined): this;
/**
* Sets the shape options.
*
* @param shapeOptions - Shape options.
* @returns this
*/
setShapeOptions(shapeOptions: ShapeOptions): this;
/**
* Returns the bounding box.
*
* @returns The bounding box.
*/
getBounds(): LatLngBounds | undefined;
/**
* Returns the location.
*
* @returns The location.
*/
getLatLng(): LatLng;
/**
* Returns the speed.
*
* @returns The speed (m/s).
*/
getSpeed(): number | undefined;
/**
* Returns the heading.
*
* @returns The heading (radians, from north, clockwise).
*/
getHeading(): number | undefined;
/**
* Returns the course.
*
* @returns The course (radians, from north, clockwise).
*/
getCourse(): number | undefined;
/**
* Creates a shape.
*
* @param points - Points.
* @param size - Size (units: pixels).
* @returns The new shape.
*/
static createShape(points: Points, size: number): Shape;
/**
* Creates a shape set.
*
* @param size - Size (units: pixels).
* @returns The new shape set.
*/
static createShapeSet(size: number): ShapeSet;
/**
* Get latitude size of y-distance.
*
* @param value - Y distance (m).
* @returns dLat
*/
private _getLatSizeOf;
/**
* Get longitude size of x-distance.
*
* @param value - X distance (m).
* @returns dLng
*/
private _getLngSizeOf;
/**
* Get view angle from model.
*
* @param modelAngle - Model angle (radians).
* @returns View angle from model (radians).
*/
private _getViewAngleFromModel;
/**
* Get leader shape points.
*
* @returns Points.
*/
private _getLeaderShapePoints;
/**
* Calculate relative lat/lng.
*
* @param latLng - LatLng.
* @param distance - Distance (meters).
* @param angle - Angle (radians).
* @returns Calculated LatLng.
*/
private _calcRelativeLatLng;
/**
* Convert LatLngs to map layer points.
*
* @param latLngs - LatLngs.
* @returns Points.
*/
private _latLngsToLayerPoints;
/**
* Gets the shape set.
*
* @returns The shape set.
*/
private _getShapeSet;
/**
* Gets the shape.
*
* @returns The shape.
*/
private _getShape;
/**
* Get transformed shape points.
*
* @returns Transformed points and units.
*/
private _getTransformedShapePoints;
/**
* Get projected shape points.
*
* @returns Points projected to map layer.
*/
private _getProjectedShapePoints;
/**
* Converts points to an SVG path string.
*
* @param points - Points.
* @param close - Close path.
* @returns SVG path string.
*/
private static _toSVGPath;
}
export { TrackSymbol }
export default TrackSymbol;
/**
* Track symbol options.
*/
export declare interface TrackSymbolOptions extends PathOptions {
/** Initial heading (units: radians from north, clockwise). */
heading?: number;
/** Initial course over ground (units: radians from north, clockwise). */
course?: number;
/** Initial speed (units: m/s). */
speed?: number;
/** Shape options. */
shapeOptions?: ShapeOptions;
}
/**
* Units.
*/
export declare type Units = "pixels" | "meters";
export { }