When does geo_shape orientation matter?

I got right hand geo_shape index.
I have inserted following 2 geometries (one is right handed and other is left handed)
{
PRIMARY_GEOMETRY_JSON:{ "type" : "MultiPolygon" , "coordinates" : [ [ [ [ 55.8044 , 1.76417] , [ 49.90264 , 1.76417] , [ 49.90264 , -6.32764] , [ 55.8044 , -6.32764] , [ 55.8044 , 1.76417]]]]},
ASSET_DESC:"right 7046397"
}

{
PRIMARY_GEOMETRY_JSON:{ "type" : "MultiPolygon" , "coordinates" : [ [ [ [ 55.8044 , 1.76417] , [ 55.8044 , -6.32764] , [ 49.90264 , -6.32764] , [ 49.90264 , 1.76417] , [ 55.8044 , 1.76417]]]]},
ASSET_DESC:"left 7046397"
}

I did simple query for interaction with point inside of those.
{
"query": {
"geo_shape": {
"PRIMARY_GEOMETRY_JSON": {
"relation": "intersects",
"shape": {
"type": "point",
"coordinates": [53.00732849165797, -2.594776271930246]
}
}
}
}
}

And the result set set contains both objects.
If the vertex order mattered shouldn't I be getting only one document in the result set?

I don't believe orientation matters to ES. Maybe someone else can comment though.

I have played with it little bit more and it looks like the orientation matters for bigger shapes. The question is: is there some precise size when it starts to matter?

This is my test.
I have inserted into counterclockwise index following 2 objects (one is clock wise and other is counter clock wise)
Insert counter clock wise geom
{
PRIMARY_GEOMETRY_JSON:{ "type" : "MultiPolygon" , "coordinates" : [ [ [
[-117.59765624999936, 34.092592693445944],
[167.87109375000063, 23.648430344313333],
[160.83984375000063, 54.8284643512197],
[-119.00390624999936, 51.016437316796136],
[-117.59765624999936, 34.092592693445944]
]]]},
ASSET_DESC:"2 big geometry counter"
}
insert clock wise geometry
{
PRIMARY_GEOMETRY_JSON:{ "type" : "MultiPolygon" , "coordinates" : [ [ [
[-117.59765624999936, 34.092592693445944],
[-119.00390624999936, 51.016437316796136],
[160.83984375000063, 54.8284643512197],
[167.87109375000063, 23.648430344313333],
[-117.59765624999936, 34.092592693445944]
]]]},
ASSET_DESC:"2 big geometry clock"
}

Then I query for point inside of the polygon
{
"query": {
"geo_shape": {
"PRIMARY_GEOMETRY_JSON": {
"relation": "intersects",
"shape": {
"type": "point",
"coordinates": [-105.64453125000016, 42.032974332441405]
}
}
}
}
}
and of query inside of the poligon assuming that its counter clock wise.
{
"query": {
"geo_shape": {
"PRIMARY_GEOMETRY_JSON": {
"relation": "intersects",
"shape": {
"type": "point",
"coordinates": [-159.43359375, 40.78377015798676]
}
}
}
}
}
and I got right results.


The red polygon represents my big geometry. The blue polygon is a rendering by geojson lint tool (that tool does not interpret ordering correctly)

The latter use case is when orientation matters - to explicitly resolve polygon ambiguity. The reason geojson lint renders the blue poly across the dateline is because of the default OGC right-hand rule (also the ES default). The RHR interprets vertex ordering in ccw order. So when you specify -117, 167, 160 (or any permutation thereof) the RHR will "unwrap" (insert an edge between) -117 and 167 at the -180 dateline. If you intend to have a "large" poly (e.g., greater than 180 longitude in width), such as the red one you drew, you will need to override the orientation parameter to use the LHR (e.g., left, cw).

Does this help?

Yes it does, thanks:)

Is there a way to tell when exactly the orientation starts to matter? I mean how big the geometry needs to before it starts to matter?
In first example the orientation didn't seem to matter

Test geometry represented small blue polygon but if we were to take into account ordering, shouldn't it be in one case the blue polygon and in other case the red polygon? Elastic Search seemed to indexe both versions the same way - as the blue polygon

It might depend on whether the difference between your coords is > 180 deg. in longitude.

GIS systems usually define a polygon with coordinates in one direction and a whole within that polygon with coordinates in the opposite direction. I would expect ES does the same if it is complying with OGC standards.