Chore: improve typings and docs

This commit is contained in:
Pieter Vander Vennet 2025-04-18 00:25:25 +02:00
parent 4bd61c30a3
commit 45435703f9

View file

@ -10,12 +10,12 @@ import {
MultiPolygon, MultiPolygon,
Point, Point,
Polygon, Polygon,
Position, Position
} from "geojson" } from "geojson"
import { Tiles } from "../Models/TileRange" import { Tiles } from "../Models/TileRange"
import { Utils } from "../Utils" import { Utils } from "../Utils"
;("use strict") ("use strict")
export class GeoOperations { export class GeoOperations {
private static readonly _earthRadius: number = 6378137 private static readonly _earthRadius: number = 6378137
@ -1051,6 +1051,8 @@ export class GeoOperations {
} }
/** /**
* Converts various types of possible bearings into degrees, with 0 being north, 90 being east.
*
* GeoOperations.parseBearing("N") // => 0 * GeoOperations.parseBearing("N") // => 0
* GeoOperations.parseBearing("E") // => 90 * GeoOperations.parseBearing("E") // => 90
* GeoOperations.parseBearing("NE") // => 45 * GeoOperations.parseBearing("NE") // => 45
@ -1064,7 +1066,7 @@ export class GeoOperations {
* GeoOperations.parseBearing(-270) // => 90 * GeoOperations.parseBearing(-270) // => 90
* *
*/ */
public static parseBearing(str: string | number) { public static parseBearing(str: string | number): number {
let n: number let n: number
if (typeof str === "string") { if (typeof str === "string") {
str = str.trim() str = str.trim()