mfogel / polygon-clipping

Apply boolean polygon clipping operations (union, intersection, difference, xor) to your Polygons & MultiPolygons.
MIT License
546 stars 63 forks source link

Typescript bindings #76

Closed bgschiller closed 5 years ago

bgschiller commented 5 years ago

I'm using this library in a project, and wanted to have TS bindings. Would you be interested in a PR for them? The code is small (it's entirety is below), but I understand that it is a maintenance burden—once you provide the bindings people will expect them to remain up-to-date.

declare module 'polygon-clipping' {
  export type Pair = [number, number];
  export type Ring = Pair[];
  export type Polygon = Ring[];
  export type MultiPolygon = Polygon[];
  type Geom = Polygon | MultiPolygon;
  export function intersection(geom: Geom, ...geoms: Geom[]): MultiPolygon;
  export function xor(geom: Geom, ...geoms: Geom[]): MultiPolygon;
  export function union(geom: Geom, ...geoms: Geom[]): MultiPolygon;
  export function difference(subjectGeom: Geom, ...clipGeoms: Geom[]): MultiPolygon;
}
mfogel commented 5 years ago

Yes, I certainly would be interested in a PR! I'd view this project's public API as stable.

mfogel commented 5 years ago

Addressed in #77. Thanks for the PR @bgschiller , I plan to release a new minor version to npm this week with this update.

ralexrdz commented 7 months ago

I think instead of writing our own types,we should be using geojson types

https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/geojson