3

We are indexing geo-json polygons using the shape data type in Elastic Search. The polygons are provided to us from an external source. When indexing, some of the polygons fail with the following message.

"Unable to Tessellate shape [[12.775555, 61.54487] [12.797356, 61.53186] [12.795639, 61.549286] [12.832375, 61.54536] [12.775555, 61.54487] ]. Possible malformed shape detected."

We believe the issue is related to self-intersecting polygons. The polygons seem to be valid, according to e.g https://geojsonlint.com. Below is an example of a self-intersecting polygon:

{
        "type": "Polygon",
        "coordinates": [
          [
            [
              12.775554656982422,
              61.54486837329203
            ],
            [
              12.797355651855469,
              61.53186079051699
            ],
            [
              12.795639038085938,
              61.54928480379444
            ],
            [
              12.832374572753906,
              61.54535911881558
            ],
            [
              12.775554656982422,
              61.54486837329203
            ]
          ]
        ]
      }

This stack-overflow post seems to indicate that the correct way is to split the self-intersecting polygons into several polygons so that the above polygon would be split into 2 triangles. However the above post also uncovered a bug in Lucene, so we are a little confused about what to expect.

So, our question is, what is the suggested way to index self-intersecting polygons in Elasticsearch?

Thanks in advance!

Joel
  • 227
  • 3
  • 8

1 Answers1

2

what is the suggested way to index self-intersecting polygons in Elasticsearch?

You cannot index self-intersecting polygons. They need to be valid following OGC specification (http://portal.opengeospatial.org/files/?artifact_id=25355).

In addition, the polygon you shared makes me wonder if there is an issue in the way you are generating those. Before splitting such a polygon into two triangles, I would try to understand why such shapes are being generated?

Ignacio Vera
  • 101
  • 2
  • 1
    Thanks for the reply! Great that you provided a link to the OGC spec. The elastic documentation could be clearer that OGC is the definition to use. I added a clarification on the source of the polygons, they are provided to us by an external source. – Joel Nov 09 '20 at 13:32