Azure搜索:geo.intersects返回不正确的结果?

时间:2016-09-09 20:02:02

标签: azure-search

我正在使用以下Azure搜索查询:

$ filter = geo.intersects(coordinate,geography'POLYGON((1.136 44.733,1.316 44.733,1.316 44.553,1.136 44.553,1.136 44.733))')

这应返回此多边形内的所有点,这是法国西南部的一个小区域。不幸的是,Azure Search会返回多边形外部的结果。

对我来说似乎不正确的结果示例(更正,请参阅注释):

  • lon = 5.299151,lat = 44.695285,
  • lon = 0.397723,lat = 44.668628,

多边形中的点是顺时针输入的(在相关问题中已提到),但结果仍然不正确。

有关修复查询的任何建议吗?

我正在使用以下代码提供索引:

公共类Geometry

{
    public Geometry(Coordinate c)
    {
        List<double> GeoList = new List<double>();         
        GeoList.Add((double)c.Longitude);
        GeoList.Add((double)c.Latitude);
        type = "Point";
        coordinates = GeoList;
    }

    public string type { get; set; }
    public IList<double> coordinates { get; set; }
}

1 个答案:

答案 0 :(得分:1)

TL; DR定义多边形时按逆时针顺序放置点。

更细微的答案是:

Azure搜索使用OData,它使用Well-known text格式来定义几何对象。如果要从顶部看到包含多边形内的区域,则per the WKT spec多边形点按逆时针顺序排列。由于我们处理的是非欧几何几何,所以要考虑这一点很棘手。

  

[polygon]定义表面的“顶部”,该表面是外部边界以逆时针方向穿过边界的表面的一侧。

要解决您的问题,请尝试按逆时针顺序放置点数

$filter=geo.intersects(coordinate,geography'POLYGON((1.136 44.733, 1.136 44.553, 1.316 44.553, 1.316 44.733, 1.136 44.733))')