-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.d.ts
332 lines (320 loc) · 11.1 KB
/
types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
// This file was generated by "jsdoc -t node_modules/@otris/jsdoc-tsd ." command and edited manually to fix errors. Don't regenerate this file, unless there're API changes.
/**
* This library converts geokeys to Proj4 string and contains following functions:
*
* 1. {@link module:geokeysToProj4.toProj4} Does actual conversion
* 1. {@link module:geokeysToProj4.convertCoordinates} Converts coordinates to use with proj4
*
* In general, you want to:
* 1. Read geokeys.
* 1. Pass them to `geokeysToProj4.toProj4()` (let's call returned object `projObj`).
* 1. Pass `projObj.proj4` (which is Proj4 string) to proj4js.
* 1. Convert pixel coordinates to CRS coordinates (let's call them `crsX` and `crsY`).
* 1. Convert CRS coordinates to usable units *(in most cases, meters, but GeoTIFF allows speed, angular speed, and scale)*: `geokeysToProj4(crsX, crsY, projObj.coordinatesConversionParameters)`.
* 1. The returned object contains X, Y, Z coordinates. which are ready to be projected with proj4js. So project them. Of course, you can alter this workflow to use this library with any other (presumably, server-side) software.
*/
declare module "geokeysToProj4";
/**
* Geokeys. If you're working with `geotiff` library, this is result of `image.getGeoKeys()`.
*/
export interface GeoKeys {
/**
* See GeoTIFF docs for more information
*/
GeographicTypeGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogGeodeticDatumGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogPrimeMeridianGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogLinearUnitsGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogLinearUnitSizeGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogAngularUnitsGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogAngularUnitSizeGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogEllipsoidGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogSemiMajorAxisGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogSemiMinorAxisGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogInvFlatteningGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
GeogPrimeMeridianLongGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjectedCSTypeGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjectionGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjCoordTransGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjLinearUnitsGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjLinearUnitSizeGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjStdParallel1GeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjStdParallel2GeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjNatOriginLongGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjNatOriginLatGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjFalseEastingGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjFalseNorthingGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjFalseOriginLongGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjFalseOriginLatGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjFalseOriginEastingGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjFalseOriginNorthingGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjCenterLongGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjCenterLatGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjCenterEastingGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjCenterNorthingGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjScaleAtNatOriginGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjScaleAtCenterGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjAzimuthAngleGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
ProjStraightVertPoleLongGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
VerticalGeoKey: number;
/**
* See GeoTIFF docs for more information
*/
VerticalUnitsGeoKey: number;
/**
* Datum to WGS transformation parameters, unofficial key
*/
GeogTOWGS84GeoKey: number[];
}
/**
* Errors that have occurred during conversion.
*
* Apart from listed properties, there's properties that named after geokeys with `NotSupported` suffix, i.e. `ProjFalseOriginLongGeoKeyNotSupported`. Values are EPSG codes assigned to those keys. These errors mean that the specified EPSG code is either not supported by this library, or it's new and hasn't been added yet. If it's the latter, please, create an issue at https://github.com/matafokka/geotiff-geokeys-to-proj4
*
* If an error has not occurred, it won't be present in this object.
*
* How to process these errors:
*
* 1. If it's your program's user's GeoTIFF, show an error message.
* 1. If it's your GeoTIFF, fix it in a GIS.
* 1. If you're sure that file is fine or want to discuss it, please, create an issue at https://github.com/matafokka/geotiff-geokeys-to-proj4
*/
export interface ConversionErrors {
/**
* `true` when both `GeographicTypeGeoKey` and `ProjectedCSTypeGeoKey` geokeys are set. In this case, `GeographicTypeGeoKey` is used. The cause of this error is broken geokeys.
*/
bothGCSAndPCSAreSet: boolean;
/**
* Specified CRS can't be represented as Proj4 string or it's new and hasn't been added to this library. Value is EPSG code of specified CRS.
*/
CRSNotSupported: number;
/**
* Geokey `GeogLinearUnitsGeoKey` is set to user-defined, but user hasn't specified `GeogLinearUnitSizeGeoKey`. In this case, every other key using this one assumed to be using meters. The cause of this error is broken geokeys.
*/
GeogLinearUnitSizeGeoKeyNotDefined: number;
/**
* Geokey `GeogAngularUnitsGeoKey` is set to user-defined, but user hasn't specified `GeogAngularUnitSizeGeoKey`. In this case, every other key using this one assumed to be using degrees. The cause of this error is broken geokeys.
*/
GeogAngularUnitSizeGeoKeyNotDefined: number;
/**
* Geokey `ProjLinearUnitsGeoKey` is set to user-defined, but user hasn't specified `ProjLinearUnitSizeGeoKey`. In this case, every other key using this one assumed to be using meters. The cause of this error is broken geokeys.
*/
ProjLinearUnitSizeGeoKeyNotDefined: number;
/**
* Conversion specified in `ProjectionGeoKey` is not supported by this library. Value is EPSG conversion code.
*/
conversionNotSupported: number;
/**
* Transformation specified in `ProjCoordTransGeoKey` is not supported by this library. Value is projection code. See http://geotiff.maptools.org/spec/geotiff6.html#6.3.3.3 for more information.
*/
coordinateTransformationNotSupported: number;
/**
* Vertical CS specified in `VerticalCSTypeGeoKey` is not supported by this library. Value is EPSG CS code.
*/
verticalCsNotSupported: number;
/**
* Vertical CS specified in `VerticalUnitsGeoKey` is not supported by this library. Value is EPSG uom code.
*/
verticalCsUnitsNotSupported: number;
/**
* Vertical datums are not supported by this library. If vertical CRS is user-defined, and `VerticalDatumGeoKey` is set, this error will be reported. Value is EPSG datum code.
*/
verticalDatumsNotSupported: number;
}
/**
* Returned projection parameters
*/
export interface ProjectionParameters {
/**
* Proj4 string
*/
proj4: string;
/**
* If true, coordinates should be converted by using {@link module:geokeysToProj4.convertCoordinates} before passing to proj4js
*/
shouldConvertCoordinates: boolean;
/**
* Parameters to pass to {@link module:geokeysToProj4.convertCoordinates}
*/
coordinatesConversionParameters: CoordinateConversionParameters;
/**
* Multiply X coordinate by this parameter to convert it to standard unit
*/
"coordinatesConversionParameters.x": number;
/**
* Multiply Y coordinate by this parameter to convert it to standard unit
*/
"coordinatesConversionParameters.y": number;
/**
* Coordinates units after conversion. EPSG defines speed, angular speed and scale as linear units, and GeoTIFF relies on EPSG. So there's a chance that coordinates will represent something's different from distance (in case of PCS). Note: GCS will always use degrees; if PCS uses angles, radians will be used.
*/
coordinatesUnits: "metre" | "metre per second" | "second" | "radian" | "radian per second" | "scale" | "scale per second" | "degree";
/**
* If `true`, geographic (either 2D or 3D) CRS is used.
*/
isGCS: boolean;
/**
* Errors that have occurred while processing geokeys. If no error has occurred, there will be an empty object.
*/
errors: ConversionErrors;
}
/**
* Represents a point. X and Y coordinates are not necessarily cartesian coordinates (might be lon/lat, depends on CRS) and not in this order (if axes has been swapped by GeoTIFF).
*/
export interface Point {
/**
* X coordinate (coordinate of a first axis of CRS) of a point
*/
x: number;
/**
* Y coordinate (coordinate of a second axis of CRS) of a point
*/
y: number;
/**
* Z coordinate (coordinate of a third axis of CRS) of a point, i.e. transformed pixel value. Always points up.
*/
z: number;
}
/**
* Parameters to pass to {@link module:geokeysToProj4.convertCoordinates} or to convert coordinates manually
*/
export interface CoordinateConversionParameters {
/**
* Multiply X coordinate by this parameter to convert it to standard units (meters or degrees)
*/
x: number,
/**
* Multiply Y coordinate by this parameter to convert it to standard units (meters or degrees)
*/
y: number,
/**
* Multiply Z coordinate (pixel value) by this parameter to convert it to standard units (meters)
*/
z: number,
}
/**
* Converts GeoTIFFs geokeys to Proj4 string
*
* @param geoKeys {GeoKeys} Object where keys are geokeys (named exactly as in GeoTIFF specification) and values are, well, their values.
*/
export function toProj4(geoKeys: GeoKeys): ProjectionParameters;
/**
* Converts given coordinates to standard ones (i.e. meters or degrees).
*
* Basically, a short way to multiply `x, y, z` by `parameters.x`, `parameters.y` and `parameters.z` respectively.
*
* It does NOT accept image coordinates! Convert image coordinates to projection coordinates first (by multiplying image coordinates by `image.getResolution()` and adding coordinates of a top left corner) and then pass converted coordinates to this function.
*
* @param x {number} X coordinate
* @param y {number} Y coordinate
* @param z {number} Pixel value, i.e. Z coordinate
* @param parameters {Object} getProjectionParameters().coordinatesConversionParameters
* @return {module:geokeysToProj4.Point} Converted coordinates
*/
export function convertCoordinates(x: number, y: number, z: number, parameters: Object): Point;
export default { toProj4, convertCoordinates };