How to fix / handle self intersecting polygon

I have an issue indexing a polygon. The polygon is coming from WKT in MS SQL. The outer ring crosses over itself and creates a small hole. MS SQL says this is valid and it can be converted into valid GeoJson. When I try to insert it into ElasticSearch, it deems that the self intersecting point is invalid.

Any help on how to fix this or how to get Elastic Search to handle it? The fallback is to slightly buffer the point in SQL server before indexing it for these instances, but that is a hack that we would like to avoid.

GeoJson:
{
"type":"Polygon",
"coordinates":[
[
[
-105.02236770125617,
39.845033552540315
],
[
-105.02235808313915,
39.8453106585459
],
[
-105.021898350984,
39.845345565733865
],
[
-105.02201372759393,
39.846168206370209
],
[
-105.02212931903193,
39.846170184950211
],
[
-105.02291486661201,
39.845767757817633
],
[
-105.02282867464496,
39.845608459160317
],
[
-105.02277135425491,
39.845502516798589
],
[
-105.02267159436907,
39.84530612274169
],
[
-105.02264900894218,
39.845259572326796
],
[
-105.02299106846411,
39.845124166411928
],
[
-105.02280320220005,
39.845037010476418
],
[
-105.02236770125617,
39.845033552540315
]
],
[
[
-105.0228346043621,
39.845619417104082
],
[
-105.02285236718095,
39.8457397815228
],
[
-105.02279978006698,
39.845744567525742
],
[
-105.02274719650715,
39.845749353519295
],
[
-105.02269460937812,
39.845754139475289
],
[
-105.02264202224282,
39.845758925407615
],
[
-105.02258943509986,
39.845763711316756
],
[
-105.02253684796817,
39.845768494457118
],
[
-105.02248426437318,
39.8457732803335
],
[
-105.02243167720815,
39.845778066172109
],
[
-105.02241327266007,
39.845657907719932
],
[
-105.02246585973485,
39.845653121889249
],
[
-105.02251844680309,
39.845648336035254
],
[
-105.02257103384493,
39.845643552902771
],
[
-105.02262361733808,
39.845638766987491
],
[
-105.02267620438485,
39.84563398106301
],
[
-105.02272879142394,
39.845629195115151
],
[
-105.022781378456,
39.845624409143745
],
[
-105.0228346043621,
39.845619417104082
]
]
]
}

1 Like