Skip to content

Commit d4203b0

Browse files
jrodewigprobakowski
authored andcommitted
[DOCS] Clarify orientation usage for WKT and GeoJSON polygons (elastic#84025)
Clarifies that the `orientation` mapping parameter only applies to WKT polygons. GeoJSON polygons use a default orientation of `RIGHT`, regardless of the mapping parameter. Also notes that the document-level `orientation` parameter overrides the default orientation for both WKT and GeoJSON polygons. Closes elastic#84009.
1 parent 31ead1f commit d4203b0

File tree

1 file changed

+42
-35
lines changed

1 file changed

+42
-35
lines changed

docs/reference/mapping/types/geo-shape.asciidoc

Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
++++
66

77
The `geo_shape` data type facilitates the indexing of and searching
8-
with arbitrary geo shapes such as rectangles and polygons. It should be
8+
with arbitrary geoshapes such as rectangles and polygons. It should be
99
used when either the data being indexed or the queries being executed
1010
contain shapes other than just points.
1111

@@ -26,7 +26,7 @@ type.
2626

2727
|`orientation`
2828
a|Optional. Default <<polygon-orientation,orientation>> for the field's
29-
polygons.
29+
WKT polygons.
3030

3131
This parameter sets and returns only a `RIGHT` (counterclockwise) or `LEFT`
3232
(clockwise) value. However, you can specify either value in multiple ways.
@@ -66,7 +66,7 @@ and reject the whole document.
6666
[[geoshape-indexing-approach]]
6767
[discrete]
6868
==== Indexing approach
69-
GeoShape types are indexed by decomposing the shape into a triangular mesh and
69+
Geoshape types are indexed by decomposing the shape into a triangular mesh and
7070
indexing each triangle as a 7 dimension point in a BKD tree. This provides
7171
near perfect spatial resolution (down to 1e-7 decimal degree precision) since all
7272
spatial relations are computed using an encoded vector representation of the
@@ -144,7 +144,7 @@ API. The following is an example of a point in GeoJSON.
144144
POST /example/_doc
145145
{
146146
"location" : {
147-
"type" : "point",
147+
"type" : "Point",
148148
"coordinates" : [-77.03653, 38.897676]
149149
}
150150
}
@@ -164,23 +164,23 @@ POST /example/_doc
164164
[[geo-linestring]]
165165
===== http://geojson.org/geojson-spec.html#id3[LineString]
166166

167-
A `linestring` defined by an array of two or more positions. By
168-
specifying only two points, the `linestring` will represent a straight
167+
A linestring defined by an array of two or more positions. By
168+
specifying only two points, the linestring will represent a straight
169169
line. Specifying more than two points creates an arbitrary path. The
170-
following is an example of a LineString in GeoJSON.
170+
following is an example of a linestring in GeoJSON.
171171

172172
[source,console]
173173
--------------------------------------------------
174174
POST /example/_doc
175175
{
176176
"location" : {
177-
"type" : "linestring",
177+
"type" : "LineString",
178178
"coordinates" : [[-77.03653, 38.897676], [-77.009051, 38.889939]]
179179
}
180180
}
181181
--------------------------------------------------
182182

183-
The following is an example of a LineString in WKT:
183+
The following is an example of a linestring in WKT:
184184

185185
[source,console]
186186
--------------------------------------------------
@@ -190,7 +190,7 @@ POST /example/_doc
190190
}
191191
--------------------------------------------------
192192

193-
The above `linestring` would draw a straight line starting at the White
193+
The above linestring would draw a straight line starting at the White
194194
House to the US Capitol Building.
195195

196196
[discrete]
@@ -199,22 +199,22 @@ House to the US Capitol Building.
199199

200200
A polygon is defined by a list of a list of points. The first and last
201201
points in each (outer) list must be the same (the polygon must be
202-
closed). The following is an example of a Polygon in GeoJSON.
202+
closed). The following is an example of a polygon in GeoJSON.
203203

204204
[source,console]
205205
--------------------------------------------------
206206
POST /example/_doc
207207
{
208208
"location" : {
209-
"type" : "polygon",
209+
"type" : "Polygon",
210210
"coordinates" : [
211211
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
212212
]
213213
}
214214
}
215215
--------------------------------------------------
216216

217-
The following is an example of a Polygon in WKT:
217+
The following is an example of a polygon in WKT:
218218

219219
[source,console]
220220
--------------------------------------------------
@@ -233,7 +233,7 @@ of a polygon with a hole:
233233
POST /example/_doc
234234
{
235235
"location" : {
236-
"type" : "polygon",
236+
"type" : "Polygon",
237237
"coordinates" : [
238238
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
239239
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
@@ -242,7 +242,7 @@ POST /example/_doc
242242
}
243243
--------------------------------------------------
244244

245-
The following is an example of a Polygon with a hole in WKT:
245+
The following is an example of a polygon with a hole in WKT:
246246

247247
[source,console]
248248
--------------------------------------------------
@@ -257,22 +257,29 @@ POST /example/_doc
257257
===== Polygon orientation
258258

259259
A polygon's orientation indicates the order of its vertices: `RIGHT`
260-
(counterclockwise) or `LEFT` (clockwise).
260+
(counterclockwise) or `LEFT` (clockwise). {es} uses a polygon’s orientation to
261+
determine if it crosses the international dateline (+/-180° longitude).
261262

262-
You can set a default orientation for a `geo_shape` field using the
263-
<<geo-shape-mapping-options,`orientation` mapping parameter>>. You can override
264-
this default for specific polygons using the document-level `orientation`
265-
parameter.
263+
You can set a default orientation for WKT polygons using the
264+
<<geo-shape-mapping-options,`orientation` mapping parameter>>. This is because
265+
the WKT specification doesn't specify or enforce a default orientation.
266266

267-
For example, the following indexing request specifies a document-level
268-
`orientation` of `LEFT`.
267+
GeoJSON polygons use a default orientation of `RIGHT`, regardless of
268+
`orientation` mapping parameter's value. This is because the
269+
https://tools.ietf.org/html/rfc7946#section-3.1.6[GeoJSON specification]
270+
mandates that an outer polygon use a counterclockwise orientation and interior
271+
shapes use a clockwise orientation.
272+
273+
You can override the default orientation for GeoJSON polygons using the
274+
document-level `orientation` parameter. For example, the following indexing
275+
request specifies a document-level `orientation` of `LEFT`.
269276

270277
[source,console]
271278
----
272279
POST /example/_doc
273280
{
274281
"location" : {
275-
"type" : "polygon",
282+
"type" : "Polygon",
276283
"orientation" : "LEFT",
277284
"coordinates" : [
278285
[ [-177.0, 10.0], [176.0, 15.0], [172.0, 0.0], [176.0, -15.0], [-177.0, -10.0], [-177.0, 10.0] ]
@@ -282,15 +289,15 @@ POST /example/_doc
282289
----
283290

284291
{es} only uses a polygon’s orientation to determine if it crosses the
285-
international dateline (+/-180° longitude). If the difference between a
286-
polygon’s minimum longitude and the maximum longitude is less than 180°, the
287-
polygon doesn't cross the dateline and its orientation has no effect.
292+
international dateline. If the difference between a polygon’s minimum longitude
293+
and the maximum longitude is less than 180°, the polygon doesn't cross the
294+
dateline and its orientation has no effect.
288295

289296
If the difference between a polygon’s minimum longitude and the maximum
290297
longitude is 180° or greater, {es} checks whether the polygon's document-level
291-
`orientation` differs from the default in the `orientation` mapping parameter.
292-
If the orientation differs, {es} considers the polygon to cross the
293-
international dateline and splits the polygon at the dateline.
298+
`orientation` differs from the default orientation. If the orientation differs,
299+
{es} considers the polygon to cross the international dateline and splits the
300+
polygon at the dateline.
294301

295302
[discrete]
296303
[[geo-multipoint]]
@@ -303,7 +310,7 @@ The following is an example of a list of GeoJSON points:
303310
POST /example/_doc
304311
{
305312
"location" : {
306-
"type" : "multipoint",
313+
"type" : "MultiPoint",
307314
"coordinates" : [
308315
[102.0, 2.0], [103.0, 2.0]
309316
]
@@ -332,7 +339,7 @@ The following is an example of a list of GeoJSON linestrings:
332339
POST /example/_doc
333340
{
334341
"location" : {
335-
"type" : "multilinestring",
342+
"type" : "MultiLineString",
336343
"coordinates" : [
337344
[ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0] ],
338345
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0] ],
@@ -363,7 +370,7 @@ The following is an example of a list of GeoJSON polygons (second polygon contai
363370
POST /example/_doc
364371
{
365372
"location" : {
366-
"type" : "multipolygon",
373+
"type" : "MultiPolygon",
367374
"coordinates" : [
368375
[ [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]] ],
369376
[ [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
@@ -394,14 +401,14 @@ The following is an example of a collection of GeoJSON geometry objects:
394401
POST /example/_doc
395402
{
396403
"location" : {
397-
"type": "geometrycollection",
404+
"type": "GeometryCollection",
398405
"geometries": [
399406
{
400-
"type": "point",
407+
"type": "Point",
401408
"coordinates": [100.0, 0.0]
402409
},
403410
{
404-
"type": "linestring",
411+
"type": "LineString",
405412
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
406413
}
407414
]

0 commit comments

Comments
 (0)