1
1
import type { GeoPermissibleObjects , GeoStreamWrapper } from "d3" ;
2
2
import type { InsetOptions } from "./inset.js" ;
3
3
4
+ /**
5
+ * The built-in projection implementations; one of:
6
+ *
7
+ * - *albers-usa* - a U.S.-centric composite projection with insets for Alaska and Hawaii
8
+ * - *albers* - a U.S.-centric *conic-equal-area* projection
9
+ * - *azimuthal-equal-area* - the azimuthal equal-area projection
10
+ * - *azimuthal-equidistant* - the azimuthal equidistant projection
11
+ * - *conic-conformal* - the conic conformal projection
12
+ * - *conic-equal-area* - the conic equal-area projection
13
+ * - *conic-equidistant* - the conic equidistant projection
14
+ * - *equal-earth* - the Equal Earth projection Šavrič et al., 2018
15
+ * - *equirectangular* - the equirectangular (plate carrée) projection
16
+ * - *gnomonic* - the gnomonic projection
17
+ * - *identity* - the identity projection
18
+ * - *reflect-y* - the identity projection, but flipping *y*
19
+ * - *mercator* - the spherical Mercator projection
20
+ * - *orthographic* - the orthographic projection
21
+ * - *stereographic* - the stereographic projection
22
+ * - *transverse-mercator* - the transverse spherical Mercator projection
23
+ */
4
24
export type ProjectionName =
5
25
| "albers-usa"
6
26
| "albers"
@@ -19,14 +39,76 @@ export type ProjectionName =
19
39
| "stereographic"
20
40
| "transverse-mercator" ;
21
41
42
+ /** An instantiated projection, implementing a stream method. */
22
43
export type ProjectionImplementation = GeoStreamWrapper ;
23
44
45
+ /** A function returning an instantiated projection. */
24
46
export type ProjectionFactory = ( options : any ) => ProjectionImplementation ;
25
47
48
+ /** Options for projection. */
26
49
export interface ProjectionOptions extends InsetOptions {
50
+ /**
51
+ * The desired projection; one of:
52
+ *
53
+ * - a named built-in projection such as *albers-usa*
54
+ * - a function that returns a projection implementation
55
+ * - null, for no projection
56
+ *
57
+ * When specified as a name, the projection is scaled and translated to fit
58
+ * the **domain** to the plot’s frame (minus insets). If a function, it
59
+ * receives a configuration object ({width, height, ...options}) and must
60
+ * return an object that implements the *projection*.stream method.
61
+ *
62
+ * For example, to use the [Bertin 1953 projection][1]:
63
+ *
64
+ * ```js
65
+ * {type: ({width, height, domain}) => d3.geoBertin1953().fitSize([width, height], domain)}
66
+ * ```
67
+ *
68
+ * [1]: https://observablehq.com/@d3/geo-bertin-1953
69
+ */
27
70
type ?: ProjectionName | ProjectionFactory | null ;
71
+
72
+ /**
73
+ * A GeoJSON object to fit to the plot’s frame (minus insets); defaults to a
74
+ * Sphere for spherical projections (outline of the the whole globe).
75
+ */
28
76
domain ?: GeoPermissibleObjects ;
77
+
78
+ /**
79
+ * A rotation of the sphere before projection; defaults to [0, 0, 0].
80
+ * Specified as Euler angles λ (yaw, or reference longitude), φ (pitch, or
81
+ * reference latitude), and optionally γ (roll), in degrees.
82
+ */
29
83
rotate ?: [ x : number , y : number , z ?: number ] ;
84
+
85
+ /**
86
+ * The [standard parallels][1]. For conic projections only.
87
+ *
88
+ * [1]: https://github.com/d3/d3-geo/blob/main/README.md#conic_parallels
89
+ */
30
90
parallels ?: [ y1 : number , y2 : number ] ;
91
+
92
+ /**
93
+ * The projection’s [sampling threshold][1].
94
+ *
95
+ * [1]: https://github.com/d3/d3-geo/blob/main/README.md#projection_precision
96
+ */
97
+ precision ?: number ;
98
+
99
+ /**
100
+ * The projection’s clipping method; one of:
101
+ *
102
+ * - *frame* or true (default) - clip to the plot’s frame (including margins but not insets)
103
+ * - a number - clip to a circle of the given radius in degrees centered around the origin
104
+ * - null or false - do not clip
105
+ *
106
+ * Some projections (such as [*armadillo*][1] and [*berghaus*][2]) require
107
+ * spherical clipping: in that case set the marks’ **clip** option to
108
+ * *sphere*.
109
+ *
110
+ * [1]: https://observablehq.com/@d3/armadillo
111
+ * [2]: https://observablehq.com/@d3/berghaus-star
112
+ */
31
113
clip ?: boolean | number | "frame" | null ;
32
114
}
0 commit comments