Elasticsearch ingest circle processor problem

85 Views Asked by At

I'm trying to insert a location that is using a circle processor to generate the circle points. Location [30, 10] in the document is generated with the circle points properly. docs: Circle processor | Elasticsearch Guide [8.5] | Elastic

PUT _ingest/pipeline/polygonize_circles
{
  "description": "translate circle to polygon",
  "processors": [
    {
      "circle": {
        "field": "circle",
        "error_distance": 1,
        "shape_type": "geo_shape"
      }
    }
  ]
}


PUT circles
{
  "mappings": {
    "properties": {
      "circle": {
        "type": "geo_shape"
      }
    }
  }
}
 

PUT circles/_doc/2?pipeline=polygonize_circles
{
  "circle": {
    "type": "circle",
    "radius": "40m",
    "coordinates": [35.539917, -78.472000]
  }
}

GET circles/_doc/2

But if I use another location. The generated coordinate looks like an oval with the wrong radius.

my location [35.54171753710938, -78.472]

created coordinates:
"circle": {
            "coordinates": [
              [
                [
                  35.54171753710938,
                  -78.472
                ],
                [
                  35.54112406581135,
                  -78.47173430472324
                ],
                [
                  35.540630197847186,
                  -78.47167003953963
                ],
                [
                  35.540375564960186,
                  -78.47165140797998
                ],
                [
                  35.54021828908823,
                  -78.47164529506406
                ],
                [
                  35.54010640465818,
                  -78.47164274491611
                ],
                [
                  35.54001650261309,
                  -78.47164162397662
                ],
                [
                  35.53993651647515,
                  -78.47164003979641
                ],
                [
                  35.539858062238046,
                  -78.47164049555624
                ],
                [
                  35.53977439153409,
                  -78.47164207973975
                ],
                [
                  35.5396750942597,
                  -78.47164321572573
                ],
                [
                  35.5395458932956,
                  -78.47164846905713
                ],
                [
                  35.539348254773515,
                  -78.47165779735127
                ],
                [
                  35.53899878746994,
                  -78.47169061817682
                ],
                [
                  35.53833938849573,
                  -78.47182842440924
                ],
                [
                  35.53833938849573,
                  -78.47217157559075
                ],
                [
                  35.53899878746994,
                  -78.47230938182317
                ],
                [
                  35.539348254773515,
                  -78.47234220264872
                ],
                [
                  35.5395458932956,
                  -78.47235153094286
                ],
                [
                  35.5396750942597,
                  -78.47235678427425
                ],
                [
                  35.53977439153409,
                  -78.47235792026024
                ],
                [
                  35.539858062238046,
                  -78.47235950444374
                ],
                [
                  35.53993651647515,
                  -78.47235996020358
                ],
                [
                  35.54001650261309,
                  -78.47235837602337
                ],
                [
                  35.54010640465818,
                  -78.47235725508388
                ],
                [
                  35.54021828908823,
                  -78.47235470493592
                ],
                [
                  35.540375564960186,
                  -78.47234859202001
                ],
                [
                  35.540630197847186,
                  -78.47232996046036
                ],
                [
                  35.54112406581135,
                  -78.47226569527675
                ],
                [
                  35.54171753710938,
                  -78.472
                ]
              ]
            ],
            "type": "Polygon"
          }

coordinates mapping on google maps

Is it an issue or It's working as expected? Because the coordinates are not a circle so it's impacting the search result.

1

There are 1 best solutions below

2
Val On

You need to specify your coordinate array using longitude first and then latitude, I think you did the opposite and your circle is in the middle of Antartica.

If you do it like this:

PUT circles/_doc/2?pipeline=polygonize_circles
{
  "circle": {
    "type": "circle",
    "radius": "40m",
    "coordinates": [-78.472000, 35.539917]
  }
}

Then your circle doesn't look oval anymore:

Circle

From the official doc:

In GeoJSON and WKT, and therefore Elasticsearch, the correct coordinate order is longitude, latitude (X, Y) within coordinate arrays. This differs from many Geospatial APIs (e.g., Google Maps) that generally use the colloquial latitude, longitude (Y, X).