Azure 搜索:geo.intersects 返回不正确的结果?
Azure Search: geo.intersects returning incorrect results?
我正在为 Azure 搜索使用以下查询:
$filter=geo.intersects(坐标,地理'POLYGON((1.136 44.733, 1.316 44.733, 1.316 44.553, 1.136 44.553, 1.136 44.733))')
这应该 return 此多边形内的所有点,这是法国西南部的一个小区域。不幸的是,Azure 搜索 returns 结果来自多边形之外。
我认为不正确的结果示例(已更正,请参阅评论):
- lon=5.299151,lat=44.695285,
- lon=0.397723,lat=44.668628,
多边形中的点按顺时针输入(在相关问题中提到),但结果仍然不正确。
对修复查询有什么建议吗?
我正在使用以下代码来提供索引:
public class几何
{
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; }
}
TL;DR 定义多边形时按逆时针顺序放置点。
更细致的答案是:
Azure 搜索使用 OData,它使用 Well-known text format to define geometric objects. As per the WKT spec 多边形点逆时针顺序排列,如果你想包括从顶部看到的多边形内的区域。由于我们正在处理非欧几里德几何,因此考虑起来会很棘手。
The [polygon] defines the “top” of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter clockwise direction.
要解决您的问题,请尝试按逆时针顺序排列您的点数
$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))')
我正在为 Azure 搜索使用以下查询:
$filter=geo.intersects(坐标,地理'POLYGON((1.136 44.733, 1.316 44.733, 1.316 44.553, 1.136 44.553, 1.136 44.733))')
这应该 return 此多边形内的所有点,这是法国西南部的一个小区域。不幸的是,Azure 搜索 returns 结果来自多边形之外。
我认为不正确的结果示例(已更正,请参阅评论):
- lon=5.299151,lat=44.695285,
- lon=0.397723,lat=44.668628,
多边形中的点按顺时针输入(在相关问题中提到),但结果仍然不正确。
对修复查询有什么建议吗?
我正在使用以下代码来提供索引:
public class几何
{
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; }
}
TL;DR 定义多边形时按逆时针顺序放置点。
更细致的答案是:
Azure 搜索使用 OData,它使用 Well-known text format to define geometric objects. As per the WKT spec 多边形点逆时针顺序排列,如果你想包括从顶部看到的多边形内的区域。由于我们正在处理非欧几里德几何,因此考虑起来会很棘手。
The [polygon] defines the “top” of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter clockwise direction.
要解决您的问题,请尝试按逆时针顺序排列您的点数
$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))')