forked from elastic/elasticsearch-specification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeo.ts
153 lines (132 loc) · 3.54 KB
/
Geo.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
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { double } from './Numeric'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
export class DistanceParsed {
precision: double
unit: DistanceUnit
}
export type Distance = string
export enum DistanceUnit {
/** @codegen_name inches */
in = 0,
/** @codegen_name feet */
ft = 1,
/** @codegen_name yards */
yd = 2,
/** @codegen_name miles */
mi = 3,
/** @codegen_name nautic_miles */
nmi = 4,
/** @codegen_name kilometers */
km = 5,
/** @codegen_name meters */
m = 6,
/** @codegen_name centimeters */
cm = 7,
/** @codegen_name millimeters */
mm = 8
}
export enum GeoDistanceType {
arc = 0,
plane = 1
}
/** A GeoJson shape, that can also use Elasticsearch's `envelope` extension. */
export type GeoShape = UserDefinedValue
/** A GeoJson GeoLine. */
export class GeoLine {
/** Always `"LineString"` */
type: string
/** Array of `[lon, lat]` coordinates */
coordinates: Array<Array<double>>
}
export enum GeoShapeRelation {
intersects = 0,
disjoint = 1,
within = 2,
contains = 3
}
export type GeoTilePrecision = number
/**
* A precision that can be expressed as a geohash length between 1 and 12, or a distance measure like "1km", "10m".
* @codegen_names geohash_length, distance
*/
export type GeoHashPrecision = number | string
export type GeoHash = string
/** A map tile reference, represented as `{zoom}/{x}/{y}` */
export type GeoTile = string
/** A map hex cell (H3) reference */
export type GeoHexCell = string
export class LatLon {
lat: double
lon: double
}
/**
* A latitude/longitude as a 2 dimensional point. It can be represented in various ways:
* - as a `{lat, long}` object
* - as a geo hash value
* - as a `[lon, lat]` array
* - as a string in `"<lat>, <lon>"` or WKT point formats
*
* @codegen_names latlon, geohash, coords, text
*/
// ES: GeoUtils.parseGeoPoint()
export type GeoLocation =
| LatLonGeoLocation
| GeoHashLocation
| double[]
| string
export class LatLonGeoLocation {
lat: double
lon: double
}
export class GeoHashLocation {
geohash: GeoHash
}
/**
* A geo bounding box. It can be represented in various ways:
* - as 4 top/bottom/left/right coordinates
* - as 2 top_left / bottom_right points
* - as 2 top_right / bottom_left points
* - as a WKT bounding box
*
* @codegen_names coords, tlbr, trbl, wkt
*/
export type GeoBounds =
| CoordsGeoBounds
| TopLeftBottomRightGeoBounds
| TopRightBottomLeftGeoBounds
| WktGeoBounds
export class WktGeoBounds {
wkt: string
}
export class CoordsGeoBounds {
top: double
bottom: double
left: double
right: double
}
export class TopLeftBottomRightGeoBounds {
top_left: GeoLocation
bottom_right: GeoLocation
}
export class TopRightBottomLeftGeoBounds {
top_right: GeoLocation
bottom_left: GeoLocation
}