044f2f4381
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
58 lines
2.1 KiB
Go
58 lines
2.1 KiB
Go
package geodata
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
)
|
|
|
|
// 居中后的等经纬接缝必须落在视图中心对面;旋转前后地理点集合应当一致。
|
|
func TestPolygonFragmentsCentredSeamKeepsGeometry(t *testing.T) {
|
|
// 密集采样,避免矩形边在大圆上鼓向极点——库按大圆处理边,稀疏顶点会放大这个效应。
|
|
ring := make([]GeoPoint, 0, 240)
|
|
for longitude := -60.0; longitude <= 60; longitude += 2 {
|
|
ring = append(ring, GeoPoint{Longitude: longitude, Latitude: -30})
|
|
}
|
|
for longitude := 60.0; longitude >= -60; longitude -= 2 {
|
|
ring = append(ring, GeoPoint{Longitude: longitude, Latitude: 30})
|
|
}
|
|
plain := PolygonFragments(ring, ClipView{Projection: ProjectionEquirectangular})
|
|
if len(plain) != 1 {
|
|
t.Fatalf("uncentred: got %d fragments, want 1", len(plain))
|
|
}
|
|
// 中心放在 176.269°E 时接缝落到 -3.73°,这个环横跨接缝,应当被切成两段。
|
|
centred := PolygonFragments(ring, ClipView{
|
|
Projection: ProjectionEquirectangular,
|
|
Center: GeoPoint{Longitude: 176.269},
|
|
})
|
|
if len(centred) != 2 {
|
|
t.Fatalf("centred: got %d fragments, want 2", len(centred))
|
|
}
|
|
for _, fragment := range centred {
|
|
if len(fragment) < 3 {
|
|
t.Fatalf("fragment has %d points", len(fragment))
|
|
}
|
|
for _, point := range fragment {
|
|
// 分段用地图窗口坐标表示(居中经线 ±180),折回 -180…180 后再比对。
|
|
if longitude := NormalizeLongitude(point.Longitude); longitude < -60-1e-6 || longitude > 60+1e-6 {
|
|
t.Fatalf("fragment longitude %.3f escaped the ring", longitude)
|
|
}
|
|
if math.Abs(point.Latitude) > 30+0.5 {
|
|
t.Fatalf("fragment latitude %.3f escaped the ring", point.Latitude)
|
|
}
|
|
}
|
|
}
|
|
// 两段拼起来的经度跨度和应等于原环的 120°。
|
|
total := 0.0
|
|
for _, fragment := range centred {
|
|
minLon, maxLon := fragment[0].Longitude, fragment[0].Longitude
|
|
for _, point := range fragment[1:] {
|
|
minLon = math.Min(minLon, point.Longitude)
|
|
maxLon = math.Max(maxLon, point.Longitude)
|
|
}
|
|
total += maxLon - minLon
|
|
}
|
|
if math.Abs(total-120) > 4 {
|
|
t.Fatalf("fragment longitude span %.3f, want about 120", total)
|
|
}
|
|
}
|