gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
70 lines • 3.32 kB
TypeScript
import type { IntersectionOfSegmentsRobust, MValue, Properties, VectorFeatures, VectorMultiPolygon, VectorMultiPolygonGeometry, VectorPoint } from '../../../index.js';
/** A segment in a polygon */
export interface Segment {
id: number;
polyIndex: number;
ringIndex: number;
from: number;
to: number;
}
/** An intersection of two segments */
export interface Intersection<D extends MValue = Properties> {
segment1: Segment;
segment2: Segment;
point: VectorPoint<D>;
u: number;
t: number;
}
/** Local Intersection to a [polyIndex][ringIndex] */
export interface RingIntersection<D extends MValue = Properties> {
from: number;
to: number;
point: VectorPoint<D>;
t: number;
tVec: VectorPoint<D>;
tAngle: number;
}
/** Intersection Lookup for mapped by polyIndex and ringIndex */
export declare class RingIntersectionLookup<D extends MValue = Properties> {
/** [polyIndex][ringIndex] -> Intersections */
store: Map<number, Map<number, RingIntersection<D>[]>>;
get(polyIndex: number, ringIndex: number): RingIntersection<D>[];
set(polyIndex: number, ringIndex: number, int: RingIntersection<D>): void;
}
/**
* Find the intersection of a collection of polygons
* @param polygons - the collection of polygons
* @param includeSelfIntersections - if true, include self intersections
* @returns - found intersections
*/
export declare function polygonsIntersections<M = Record<string, unknown>, D extends MValue = Properties, P extends Properties = Properties>(polygons: VectorMultiPolygon<D> | VectorMultiPolygonGeometry<D> | VectorFeatures<M, D, P, VectorMultiPolygonGeometry<D>>, includeSelfIntersections?: boolean): Intersection<D>[];
/**
* Run through the vectorPolygons and Builds the ring intersection lookup
* @param vectorPolygons - the collection of polygons
* @param segmentFilter - the function to filter the segments, default ignores self intersections
* @returns - the ring intersection lookup for all rings in the multipolygon collection
*/
export declare function polygonsIntersectionsLookup<D extends MValue = Properties>(vectorPolygons: VectorMultiPolygon<D>, segmentFilter?: (seg1: Segment) => {
(seg2: Segment): boolean;
}): RingIntersectionLookup<D>;
/**
* Build all segments
* @param vectorPolygons - the collection of polygons
* @returns - the collection of segments
*/
export declare function buildPolygonSegments<D extends MValue = Properties>(vectorPolygons: VectorMultiPolygon<D>): Segment[];
/**
* Find the intersection of two segments if it exists
* @param vectorPolygons - the collection of polygons
* @param segment1 - the first segment
* @param segment2 - the second segment
* @returns - the intersection if it exists. Undefined otherwise.
*/
export declare function findPolygonIntersections<D extends MValue = Properties>(vectorPolygons: VectorMultiPolygon<D>, segment1: Segment, segment2: Segment): IntersectionOfSegmentsRobust<D> | undefined;
/**
* Given a ring's of intersections, clean them up
* @param intersections - a collection of intersections to clean up
* @returns - the cleaned up intersections
*/
export declare function cleanIntersections<D extends MValue = Properties>(intersections: RingIntersection<D>[]): RingIntersection<D>[];
//# sourceMappingURL=intersections.d.ts.map