morningman commented on issue #1023:
URL: https://github.com/apache/doris-website/issues/1023#issuecomment-6826409888
已在实际运行的 Doris 4.1.5 上执行原帖 SQL,并核对该版本实现。这个例子的正确结果是 `0`,不是 `1`。
验证环境:独立 Linux/arm64 容器,`SELECT @@version_comment` 和 `SHOW FRONTENDS` / `SHOW
BACKENDS` 均显示 `doris-4.1.5-release-917b20be838`,FE、BE 均正常。`SELECT VERSION()` 为
MySQL 协议兼容值 `5.7.99`。
原 SQL 实测:
```sql
SELECT ST_Contains(
ST_Polygon('POLYGON ((136.5173755265431
41.80266208058963,136.5188060447714 31.015290003114895,75.6260650782613
31.016120223420476,75.62577778481297 41.80408059113187,136.5173755265431
41.80266208058963))'),
ST_GeometryFromText('LINESTRING(121.22987634491871
31.023080519150707,121.22741910198357 31.022786576236115)')
);
```
```text
0
```
Doris 将这些坐标解释为经纬度,使用 S2
球面几何计算包含关系,边是球面上的大圆弧。不能把这个多边形当成经纬度平面上的矩形,再只比较经纬度最小值和最大值。其南侧两个顶点的纬度虽然都约为
31.015°,连接它们的球面边在中间向北弯曲,原线段位于这条边以南。
同一实际环境的对照结果:原线段的两个端点分别用 `ST_Point` 检查,均为 `0`;保持两个端点的经度不变,仅将纬度都改为 `35`
后,线段包含结果为 `1`。两种几何输入也都能正常解析,并非解析失败返回 NULL。
对应实现:[坐标转换为 S2
经纬度](https://github.com/apache/doris/blob/917b20be838/be/src/exprs/function/geo/geo_types.cpp#L81)、[GeoPolygon::contains](https://github.com/apache/doris/blob/917b20be838/be/src/exprs/function/geo/geo_types.cpp#L1037);球面边的含义可参考
[S2 官方说明](https://s2geometry.io/devguide/s2cell_hierarchy.html)。
原帖未提供 Doris 版本,因此不推断历史环境的具体版本。当前实测和对应实现均表明此例的 `0` 符合球面几何语义,关闭此
issue。如有其他输入在球面语义下仍不正确,请附 Doris 完整版本及可运行 SQL 另开 issue。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]