docs: improve typing

This commit is contained in:
Pieter Vander Vennet 2023-03-11 02:35:11 +01:00
parent 750a0620e9
commit e9797fbd39

View file

@ -234,10 +234,11 @@ export class GeoOperations {
}) })
} }
static bbox(feature: any) { static bbox(feature: any): Feature<LineString, {}> {
const [lon, lat, lon0, lat0] = turf.bbox(feature) const [lon, lat, lon0, lat0] = turf.bbox(feature)
return { return {
type: "Feature", type: "Feature",
properties: {},
geometry: { geometry: {
type: "LineString", type: "LineString",
coordinates: [ coordinates: [
@ -652,7 +653,7 @@ export class GeoOperations {
public static clipWith(toSplit: Feature, boundary: Feature<Polygon>): Feature[] { public static clipWith(toSplit: Feature, boundary: Feature<Polygon>): Feature[] {
if (toSplit.geometry.type === "Point") { if (toSplit.geometry.type === "Point") {
const p = <Feature<Point>>toSplit const p = <Feature<Point>>toSplit
if (GeoOperations.inside(p.geometry.coordinates, boundary)) { if (GeoOperations.inside(<[number, number]>p.geometry.coordinates, boundary)) {
return [p] return [p]
} else { } else {
return [] return []
@ -687,7 +688,7 @@ export class GeoOperations {
x: number, x: number,
y: number, y: number,
coordinates: [number, number][][] coordinates: [number, number][][]
) { ): boolean {
const inside = GeoOperations.pointWithinRing( const inside = GeoOperations.pointWithinRing(
x, x,
y, y,