generated from neoncitylights/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add type definitions for d3-geo-polygon
Fixes #22
- Loading branch information
1 parent
ed5693d
commit a3a1a2b
Showing
5 changed files
with
253 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Samantha | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Types for `d3-geo-polygon` | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT) | ||
[![Static Badge](https://img.shields.io/badge/Tracking%20issue-%2332-%23b99aff?style=flat-square&logo=github)](https://github.com/wandering-app/types-ohq-d3/issues/32) | ||
[![npm](https://img.shields.io/npm/v/@wandering-app/types-d3-geo-polygon?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@wandering-app/types-d3-geo-polygon) | ||
|
||
This package provides TypeScript type definitions for `d3-geo-polygon`. As these types stabilize, we intend to eventually upstream these types into DefinitelyTyped as `@types/d3-geo-polygon`. | ||
|
||
## Install | ||
> **Warning**: | ||
> This package has not been published to the NPM registry yet. Stay tuned! | ||
``` | ||
npm install @wandering-app/types-d3-geo-polygon --save-dev | ||
``` | ||
|
||
## License | ||
This library is licensed under the MIT license ([`LICENSE-MIT`](./LICENSE) or http://opensource.org/licenses/MIT). | ||
|
||
### Contribution | ||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the MIT license, shall be licensed as above, without any additional terms or conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { GeoProjection, GeoRawProjection, geoAzimuthalEqualAreaRaw } from 'd3-geo'; | ||
import { MultiPolygon, Polygon } from 'geojson'; | ||
|
||
// base APIs | ||
declare module 'd3-geo-polygon' { | ||
export type Point2 = [number, number]; | ||
export type Point3 = [number, number, number]; | ||
|
||
export function geoClipPolygon(polygon: Polygon|MultiPolygon); | ||
|
||
export type SphericalArc = [Point2, Point2]; | ||
export function geoIntersectArcs(a: SphericalArc, b: SphericalArc): Point2|undefined; | ||
} | ||
|
||
// type definitions for polyhedral projections | ||
declare module 'd3-geo-polygon' { | ||
export type PolyhedralFaceProjection = { | ||
face: Point2[], | ||
site: Point2, | ||
id: number, | ||
contains: GeoPolyhedralFaceFn, | ||
direction: number, | ||
project: GeoProjection, | ||
children: PolyhedralFaceProjection[], | ||
}; | ||
export type GeoPolyhedralFaceFn = (lambda: number, phi: number) => PolyhedralFaceProjection; | ||
export function geoPolyhedral(tree: PolyhedralFaceProjection, edges: PolyhedralFaceProjection): GeoProjection; | ||
|
||
export type Octahedron = Point2[][]; | ||
export type GeoForwardFn = (lambda: number, phi: number) => Point2; | ||
|
||
// Polyhedral butterfly projections | ||
export function geoPolyhedralButterfly(face: PolyhedralFaceProjection); | ||
|
||
// Polyhedral collignon projections | ||
export function geoPolyhedralCollignon(face: PolyhedralFaceProjection): GeoProjection; | ||
|
||
// Polyhedral waterman projections | ||
export function geoPolyhedralWaterman(face: PolyhedralFaceProjection): GeoProjection; | ||
|
||
// Polyhedral Voroni projections | ||
export type GeoVoroniProjection = GeoProjection & { | ||
parents: (_: any) => GeoVoroniProjection, | ||
polygons: (_: any) => GeoVoroniProjection, | ||
faceProjection: (_: any) => GeoVoroniProjection, | ||
faceFind: (_: any) => GeoVoroniProjection, | ||
}; | ||
export function geoPolyhedralVoroni(face: PolyhedralFaceProjection): GeoVoroniProjection; | ||
|
||
// Dodecahedral projections (uses Voroni) | ||
export function geoDodecahedral(): GeoVoroniProjection; | ||
|
||
// Cox | ||
export function geoCox(): GeoProjection; | ||
export function geoCoxRaw(lambda: number, phi: number): Point2; | ||
|
||
// Tetrahedral lee | ||
export function geoTetrahedralLee(): GeoProjection; | ||
export function geoLeeRaw(): GeoProjection; | ||
|
||
// Gray Fuller | ||
export type GeoGrayFullerProjection = GeoPolyhedralFaceFn & { | ||
invert: (x: number, y: number) => GeoRawProjection, | ||
}; | ||
export function geoGrayFullerRaw(): GeoGrayFullerProjection; | ||
|
||
// Airocean | ||
export function geoAirocean(): GeoProjection; | ||
|
||
// Icosahedral (uses Voroni) | ||
export function getIcosahedral(): GeoVoroniProjection; | ||
|
||
// Imago | ||
export type GeoImagoProjection = GeoProjection & { | ||
shift: (number) => GeoProjection|number, | ||
k: (number) => GeoProjection|number, | ||
}; | ||
export type GeoImagoBlockProjection = GeoProjection & { | ||
k: (number) => GeoProjection|number, | ||
}; | ||
export type GeoImagoRawProjection = GeoForwardFn & { | ||
invert: (x: number, y: number) => Point2, | ||
}; | ||
|
||
export function geoImago(): GeoImagoProjection; | ||
export function geoImagoBlock(): GeoImagoBlockProjection; | ||
export function geoImagoRaw(k: number): GeoImagoRawProjection; | ||
|
||
// Cubic (uses Voroni) | ||
export function geoCubic(): GeoVoroniProjection; | ||
|
||
// Cahill-Keyes | ||
export function geoCahillKeyes(): GeoProjection; | ||
export function geoCahillKeyesRaw(): GeoProjection; | ||
|
||
// Complex logs | ||
// export type GeoComplexLogProjection = GeoProjection & { | ||
// planarProjectionRaw: (_: any) => GeoRawProjection, | ||
// cutoffLatitude: (_: any) => number, | ||
// }; | ||
export type GeoComplexLogRawProjection = GeoForwardFn & { | ||
invert: (x: number, y: number) => Point2, | ||
}; | ||
|
||
export function geoComplexLog(): GeoProjection; | ||
export function geoComplexLogRaw(planarProjection = geoAzimuthalEqualAreaRaw, cutoffLatitude: number): GeoProjection; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@wandering-app/types-d3-geo-polygon", | ||
"version": "0.0.0", | ||
"description": "Experimental TypeScript declaration types for d3-geo-polygon", | ||
"license": "MIT", | ||
"author": { | ||
"name": "Samantha Nguyen", | ||
"email": "contact@samanthanguyen.me" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"types", | ||
"observablehq" | ||
], | ||
"type": "module", | ||
"main": "index.d.ts", | ||
"types": "index.d.ts", | ||
"homepage": "https://github.com/wandering-app/types-ohq-d3/tree/main/packages/d3-geo-polygon", | ||
"bugs": { | ||
"url": "https://github.com/wandering-app/types-ohq-d3/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wandering-app/types-ohq-d3.git", | ||
"directory": "packages/d3-geo-polygon" | ||
}, | ||
"devDependencies": { | ||
"@types/d3-geo": "^3.0.3", | ||
"@types/geojson": "^7946.0.10", | ||
"d3-geo": "^3.1.0" | ||
} | ||
} |