Skip to content

Commit f8e5598

Browse files
authored
[DOCS] Clarify orientation usage for WKT and GeoJSON polygons (#84025) (#84132)
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 #84009. (cherry picked from commit 6ad3f8b)
1 parent 1f1afdb commit f8e5598

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

@@ -98,7 +98,7 @@ greater false positives. Note: This parameter is only relevant for `term` and
9898

9999
|`orientation`
100100
a|Optional. Default <<polygon-orientation,orientation>> for the field's
101-
polygons.
101+
WKT polygons.
102102

103103
This parameter sets and returns only a `RIGHT` (counterclockwise) or `LEFT`
104104
(clockwise) value. However, you can specify either value in multiple ways.
@@ -147,7 +147,7 @@ and reject the whole document.
147147
[[geoshape-indexing-approach]]
148148
[discrete]
149149
==== Indexing approach
150-
GeoShape types are indexed by decomposing the shape into a triangular mesh and
150+
Geoshape types are indexed by decomposing the shape into a triangular mesh and
151151
indexing each triangle as a 7 dimension point in a BKD tree. This provides
152152
near perfect spatial resolution (down to 1e-7 decimal degree precision) since all
153153
spatial relations are computed using an encoded vector representation of the
@@ -332,7 +332,7 @@ API. The following is an example of a point in GeoJSON.
332332
POST /example/_doc
333333
{
334334
"location" : {
335-
"type" : "point",
335+
"type" : "Point",
336336
"coordinates" : [-77.03653, 38.897676]
337337
}
338338
}
@@ -352,23 +352,23 @@ POST /example/_doc
352352
[[geo-linestring]]
353353
===== http://geojson.org/geojson-spec.html#id3[LineString]
354354

355-
A `linestring` defined by an array of two or more positions. By
356-
specifying only two points, the `linestring` will represent a straight
355+
A linestring defined by an array of two or more positions. By
356+
specifying only two points, the linestring will represent a straight
357357
line. Specifying more than two points creates an arbitrary path. The
358-
following is an example of a LineString in GeoJSON.
358+
following is an example of a linestring in GeoJSON.
359359

360360
[source,console]
361361
--------------------------------------------------
362362
POST /example/_doc
363363
{
364364
"location" : {
365-
"type" : "linestring",
365+
"type" : "LineString",
366366
"coordinates" : [[-77.03653, 38.897676], [-77.009051, 38.889939]]
367367
}
368368
}
369369
--------------------------------------------------
370370

371-
The following is an example of a LineString in WKT:
371+
The following is an example of a linestring in WKT:
372372

373373
[source,console]
374374
--------------------------------------------------
@@ -378,7 +378,7 @@ POST /example/_doc
378378
}
379379
--------------------------------------------------
380380

381-
The above `linestring` would draw a straight line starting at the White
381+
The above linestring would draw a straight line starting at the White
382382
House to the US Capitol Building.
383383

384384
[discrete]
@@ -387,22 +387,22 @@ House to the US Capitol Building.
387387

388388
A polygon is defined by a list of a list of points. The first and last
389389
points in each (outer) list must be the same (the polygon must be
390-
closed). The following is an example of a Polygon in GeoJSON.
390+
closed). The following is an example of a polygon in GeoJSON.
391391

392392
[source,console]
393393
--------------------------------------------------
394394
POST /example/_doc
395395
{
396396
"location" : {
397-
"type" : "polygon",
397+
"type" : "Polygon",
398398
"coordinates" : [
399399
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
400400
]
401401
}
402402
}
403403
--------------------------------------------------
404404

405-
The following is an example of a Polygon in WKT:
405+
The following is an example of a polygon in WKT:
406406

407407
[source,console]
408408
--------------------------------------------------
@@ -421,7 +421,7 @@ of a polygon with a hole:
421421
POST /example/_doc
422422
{
423423
"location" : {
424-
"type" : "polygon",
424+
"type" : "Polygon",
425425
"coordinates" : [
426426
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ],
427427
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
@@ -430,7 +430,7 @@ POST /example/_doc
430430
}
431431
--------------------------------------------------
432432

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

435435
[source,console]
436436
--------------------------------------------------
@@ -445,22 +445,29 @@ POST /example/_doc
445445
===== Polygon orientation
446446

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

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

455-
For example, the following indexing request specifies a document-level
456-
`orientation` of `LEFT`.
455+
GeoJSON polygons use a default orientation of `RIGHT`, regardless of
456+
`orientation` mapping parameter's value. This is because the
457+
https://tools.ietf.org/html/rfc7946#section-3.1.6[GeoJSON specification]
458+
mandates that an outer polygon use a counterclockwise orientation and interior
459+
shapes use a clockwise orientation.
460+
461+
You can override the default orientation for GeoJSON polygons using the
462+
document-level `orientation` parameter. For example, the following indexing
463+
request specifies a document-level `orientation` of `LEFT`.
457464

458465
[source,console]
459466
----
460467
POST /example/_doc
461468
{
462469
"location" : {
463-
"type" : "polygon",
470+
"type" : "Polygon",
464471
"orientation" : "LEFT",
465472
"coordinates" : [
466473
[ [-177.0, 10.0], [176.0, 15.0], [172.0, 0.0], [176.0, -15.0], [-177.0, -10.0], [-177.0, 10.0] ]
@@ -470,15 +477,15 @@ POST /example/_doc
470477
----
471478

472479
{es} only uses a polygon’s orientation to determine if it crosses the
473-
international dateline (+/-180° longitude). If the difference between a
474-
polygon’s minimum longitude and the maximum longitude is less than 180°, the
475-
polygon doesn't cross the dateline and its orientation has no effect.
480+
international dateline. If the difference between a polygon’s minimum longitude
481+
and the maximum longitude is less than 180°, the polygon doesn't cross the
482+
dateline and its orientation has no effect.
476483

477484
If the difference between a polygon’s minimum longitude and the maximum
478485
longitude is 180° or greater, {es} checks whether the polygon's document-level
479-
`orientation` differs from the default in the `orientation` mapping parameter.
480-
If the orientation differs, {es} considers the polygon to cross the
481-
international dateline and splits the polygon at the dateline.
486+
`orientation` differs from the default orientation. If the orientation differs,
487+
{es} considers the polygon to cross the international dateline and splits the
488+
polygon at the dateline.
482489

483490
[discrete]
484491
[[geo-multipoint]]
@@ -491,7 +498,7 @@ The following is an example of a list of GeoJSON points:
491498
POST /example/_doc
492499
{
493500
"location" : {
494-
"type" : "multipoint",
501+
"type" : "MultiPoint",
495502
"coordinates" : [
496503
[102.0, 2.0], [103.0, 2.0]
497504
]
@@ -520,7 +527,7 @@ The following is an example of a list of GeoJSON linestrings:
520527
POST /example/_doc
521528
{
522529
"location" : {
523-
"type" : "multilinestring",
530+
"type" : "MultiLineString",
524531
"coordinates" : [
525532
[ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0] ],
526533
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0] ],
@@ -551,7 +558,7 @@ The following is an example of a list of GeoJSON polygons (second polygon contai
551558
POST /example/_doc
552559
{
553560
"location" : {
554-
"type" : "multipolygon",
561+
"type" : "MultiPolygon",
555562
"coordinates" : [
556563
[ [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]] ],
557564
[ [[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
@@ -582,14 +589,14 @@ The following is an example of a collection of GeoJSON geometry objects:
582589
POST /example/_doc
583590
{
584591
"location" : {
585-
"type": "geometrycollection",
592+
"type": "GeometryCollection",
586593
"geometries": [
587594
{
588-
"type": "point",
595+
"type": "Point",
589596
"coordinates": [100.0, 0.0]
590597
},
591598
{
592-
"type": "linestring",
599+
"type": "LineString",
593600
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
594601
}
595602
]

0 commit comments

Comments
 (0)