无法创建有效的geo_shape [英] Failed to create valid geo_shape

查看:212
本文介绍了无法创建有效的geo_shape的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在ES 6.6.1上创建geo_shape时遇到奇怪的错误.

I'm getting a weird error while trying to create a geo_shape on ES 6.6.1.

说我的索引具有以下映射:

Say my index has the following mapping:

PUT index
{
    "mappings" : {
      "doc" : {
        "properties" : {
          "parcel" : {
            "type" : "geo_shape"
          }
        }
      }
    }
}

然后我尝试索引以下形状:

Then I try to index the following shape:

PUT index/doc/1
{
  "parcel": {
    "type": "Polygon",
    "coordinates": [
      [
        [
          -116.96938484446626,
          32.657287303780286
        ],
        [
          -116.96965590466098,
          32.65769347876227
        ],
        [
          -116.96968135808686,
          32.6576270315712
        ],
        [
          -116.9696296695897,
          32.65755262998358
        ],
        [
          -116.96958127691761,
          32.65749789091981
        ],
        [
          -116.96957440818564,
          32.65748867799296
        ],
        [
          -116.96956934986578,
          32.657478661509074
        ],
        [
          -116.96956622948879,
          32.657468094004884
        ],
        [
          -116.96956512572433,
          32.65745724190901
        ],
        [
          -116.96956606714967,
          32.657446269236075
        ],
        [
          -116.96956906760627,
          32.6574355644998
        ],
        [
          -116.9695740501034,
          32.65742540237828
        ],
        [
          -116.969580886792,
          32.657416043627286
        ],
        [
          -116.96958940224481,
          32.65740772838791
        ],
        [
          -116.96959937795938,
          32.65740067002504
        ],
        [
          -116.96961055796365,
          32.65739504965278
        ],
        [
          -116.96962265538367,
          32.65739101148703
        ],
        [
          -116.96963941117102,
          32.65738669475593
        ],
        [
          -116.96968929311828,
          32.657380266168204
        ],
        [
          -116.96971421919122,
          32.65737107267142
        ],
        [
          -116.96974025096051,
          32.657364424338446
        ],
        [
          -116.96976702669309,
          32.65736041355325
        ],
        [
          -116.96979610325567,
          32.657360133811345
        ],
        [
          -116.96979604847199,
          32.65738964993994
        ],
        [
          -116.96980892900375,
          32.657405741211996
        ],
        [
          -116.96982254848434,
          32.65743912428268
        ],
        [
          -116.96982440712573,
          32.65757530006893
        ],
        [
          -116.96980091875615,
          32.65757556917019
        ],
        [
          -116.96980231781737,
          32.657671757416445
        ],
        [
          -116.9697584569099,
          32.65767190361854
        ],
        [
          -116.96974569627933,
          32.657672831284636
        ],
        [
          -116.96973324810837,
          32.65767538023773
        ],
        [
          -116.96972139855602,
          32.65767949188214
        ],
        [
          -116.96971042002004,
          32.65768507169981
        ],
        [
          -116.96965590466098,
          32.65769347876227
        ],
        [
          -116.96990213306911,
          32.65867026497289
        ],
        [
          -116.97006251074156,
          32.65857074329798
        ],
        [
          -116.97005268730561,
          32.65855941927579
        ],
        [
          -116.97003450060356,
          32.6585345821853
        ],
        [
          -116.97002111542614,
          32.658507649697114
        ],
        [
          -116.97001285932787,
          32.65847928089662
        ],
        [
          -116.9700099343441,
          32.65845017001777
        ],
        [
          -116.97001097289177,
          32.65835570181368
        ],
        [
          -116.97000715900516,
          32.65831706419927
        ],
        [
          -116.9699964004178,
          32.65827937538843
        ],
        [
          -116.96997895057578,
          32.65824352320803
        ],
        [
          -116.96996360978483,
          32.658217810190656
        ],
        [
          -116.96995412719613,
          32.65819832535261
        ],
        [
          -116.96994828258882,
          32.65817784218089
        ],
        [
          -116.96994621374785,
          32.658156843568825
        ],
        [
          -116.96994749057211,
          32.658138590985246
        ],
        [
          -116.96995162570506,
          32.65812064419561
        ],
        [
          -116.96996504123173,
          32.65808733706838
        ],
        [
          -116.9699691677423,
          32.65807079841303
        ],
        [
          -116.9699708627772,
          32.65805395631389
        ],
        [
          -116.96997245721279,
          32.657996138448745
        ],
        [
          -116.96997395540546,
          32.65798353768613
        ],
        [
          -116.96997771710345,
          32.65797127964815
        ],
        [
          -116.96998365356143,
          32.65795965352442
        ],
        [
          -116.96999162472632,
          32.65794893359554
        ],
        [
          -116.97000144254328,
          32.65793937276407
        ],
        [
          -116.97001287539223,
          32.65793119658679
        ],
        [
          -116.97002565355174,
          32.65792459795438
        ],
        [
          -116.97003947556234,
          32.657919732540094
        ],
        [
          -116.97007491381149,
          32.65790988387757
        ],
        [
          -116.97013168236613,
          32.65789034801523
        ],
        [
          -116.97018474056775,
          32.657864400922804
        ],
        [
          -116.97024731836858,
          32.657828722926105
        ],
        [
          -116.97020373733335,
          32.65777402469739
        ],
        [
          -116.97024107997201,
          32.65774911106885
        ],
        [
          -116.97027361924266,
          32.65771977010137
        ],
        [
          -116.97030062916816,
          32.6576866564197
        ],
        [
          -116.97032150713939,
          32.65765050882081
        ],
        [
          -116.97033578735719,
          32.657612133789556
        ],
        [
          -116.97034315122659,
          32.65757238750681
        ],
        [
          -116.97034343446302,
          32.657532156744935
        ],
        [
          -116.97033663075669,
          32.657492339084676
        ],
        [
          -116.97032289191274,
          32.65745382288943
        ],
        [
          -116.97030252446456,
          32.65741746748388
        ],
        [
          -116.97027598283205,
          32.65738408398364
        ],
        [
          -116.9702452280353,
          32.65735551282378
        ],
        [
          -116.9702099567526,
          32.6573309585366
        ],
        [
          -116.97017089494474,
          32.65731092650107
        ],
        [
          -116.97012884658778,
          32.657295829018686
        ],
        [
          -116.97008467712605,
          32.65728597682711
        ],
        [
          -116.9700392956597,
          32.65728157270474
        ],
        [
          -116.96999363623335,
          32.657282707297725
        ],
        [
          -116.9698516329254,
          32.657294901661395
        ],
        [
          -116.96980576339504,
          32.657297534863744
        ],
        [
          -116.96975978838934,
          32.657297573600744
        ],
        [
          -116.96938484446626,
          32.657287303780286
        ]
      ]
    ]
  }
}

我收到以下错误,这对我来说没有意义,因为我要发送的多边形明显有4个以上的多边形点并且已关闭.

And I'm getting the following error, which doesn't make sense to me since the polygon I'm sending clearly has more than 4 polygon points and is closed.

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse field [parcel] of type [geo_shape]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse field [parcel] of type [geo_shape]",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "at least 4 polygon points required"
    }
  },
  "status": 400
}

http://geojson.io 上绘制相同的多边形会产生以下有效的多边形:

Drawing the same polygon on http://geojson.io yields the following valid polygon:

如果有人知道此错误的原因,我将不胜感激.

I'd appreciate if someone has an idea of what could be the reason of this error.

推荐答案

问题与

The problem was related to the fact that the shape is self-intersecting (kudos goes to David Turner). Other self-intersecting shapes also exhibit the same issue.

GeoJSON规范中没有阻止多边形自相交的东西,但ES却不喜欢.

There's nothing in the GeoJSON spec preventing polygons from self-intersecting, yet ES doesn't like it.

将该多边形拆分为具有轮廓形状和孔形状的MultiPolygon可解决此问题.

Splitting that Polygon into a MultiPolygon with an outline shape and a hole shape fixes the issue.

这篇关于无法创建有效的geo_shape的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆