S2polygon.getCentroid seems wrong in some case?
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- java
调研方向
从提供的 S2Loop/S2Polygon 复现和 S2Polygon.getCentroid 调用开始,然后确认纬度/经度值如何变成 S2Point 实例。将返回的点与多边形的坐标和 contains 结果进行比较;完成标准是确定导致所报告的外部点的原因究竟是质心计算还是输入解释,并使用回归测试覆盖该问题。
由索引模型根据 Issue 内容生成。
描述
I encountered a problem where the centroid seems wrong, i.e., the centroid is outside the polygon even when the polygon itself is a convex.
The code below plots a hexagon but the centroid seems to be way off, did I do anything wrong, thanks a lot for help?
double[] coordinates = new double[]{
47.167511,-122.1521,
47.167568,-122.151952,
47.167684,-122.151952,
47.167746,-122.1521,
47.167691,-122.152248,
47.16757,-122.152248,
47.167511,-122.1521,
};
List<S2Point> s2Points = new ArrayList<>();
for (int i = 0; i < coordinates.length /2; i++) {
double lat = coordinates[2 * i];
double lng = coordinates[2 * i + 1];
System.out.println(lat + "," + lng + ",");
S2LatLng s2LatLng = S2LatLng.fromDegrees(lat, lng);
s2Points.add(s2LatLng.toPoint());
}
S2Loop s2Loop = new S2Loop(s2Points);
s2Loop.normalize();
S2Polygon s2Polygon = new S2Polygon(s2Loop);
S2Point s2PolygonCentroid = s2Polygon.getCentroid();
System.out.println("Center: " + s2PolygonCentroid.toDegreesString() + " in_polygon " + s2Polygon
.contains(s2PolygonCentroid));
Output:
Center: (47.167557150782145, -122.15163675765044) in_polygon false
Kml file:
layer <Style id="style-polygon-normal"> ff000000 1.2000000476837158 4d000000 1 1 <![CDATA[<h3>$[name]</h3>]]> </Style> <Style id="style-polygon-highlight"> ff000000 1.7999999523162842 4d000000 1 1 <![CDATA[<h3>$[name]</h3>]]> </Style> normal #style-polygon-normal highlight #style-polygon-highlight <Style id="style-s2cell-normal"> ff000000 1.2000000476837158 4d000000 1 1 <![CDATA[<h3>$[name]</h3>]]> </Style> <Style id="style-s2cell-highlight"> ff000000 1.7999999523162842 4d000000 1 1 <![CDATA[<h3>$[name]</h3>]]> </Style> normal #style-s2cell-normal highlight #style-s2cell-highlight test test #style-polygon -122.15210000000002,47.167511 -122.151952,47.16756800000001 -122.15195200000002,47.16768400000001 -122.15210000000002,47.167746 -122.15224799999999,47.167691000000005 -122.15224799999999,47.16757 -122.15210000000002,47.167511 -122.15163675765044,47.167557150782145
- 主要语言
- Java
- 星标
- 587
- 派生
- 232
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google/s2-geometry-library-java 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
google/s2-geometry-library-java#56 · 1 条评论 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 1/5 1 小时以内 新手友好度 68/100
google/s2-geometry-library-java#47 · 2 条评论 ·
-
Added new ant target docs: "Generate documentation"可能已有人在做 @ThomasThelen 于 183 天前认领。 未关闭auto-migrated Type-Patch
难度 1/5 1 小时以内 新手友好度 72/100
google/s2-geometry-library-java#2 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
查看 google/s2-geometry-library-java 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
portfolio-performance/portfolio#6119 ·
维护者通常 8 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
jenkinsci/ec2-plugin#2041 ·
-
L: github:actions L: php:composer
难度 2/5 1-3 小时 新手友好度 88/100
dependabot/dependabot-core#16493 ·
维护者通常 1 天内回复
-
SHOW EDIT of a subclass for an object of its superclass: the form fails to open with AssertionError未关闭
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 1/5 1 小时以内 新手友好度 72/100