044f2f4381
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
65 lines
2.5 KiB
Go
65 lines
2.5 KiB
Go
package svg
|
||
|
||
import (
|
||
"testing"
|
||
"time"
|
||
|
||
"b612.me/astro/basic"
|
||
eclipsecore "b612.me/astro/eclipse"
|
||
"b612.me/astro/internal/svgmap"
|
||
)
|
||
|
||
// TestLunarEclipseMapSVGPolarWitnessStaysOutsideEquirectangularVisibility 固定全球月食地图在
|
||
// 极区的可见性契约。等距圆柱投影在高纬把经度拉伸:1° 的球面地平弧在极点附近可以横跨近
|
||
// 180° 经度,只连端点就会把地平线以外画进可见区。1904-09-24 的 P1 在南极点附近有一个
|
||
// 月心高度约 −0.05° 的见证点,不得落入 visible-at-p1 多边形。
|
||
func TestLunarEclipseMapSVGPolarWitnessStaysOutsideEquirectangularVisibility(t *testing.T) {
|
||
date := time.Date(1904, 9, 24, 0, 0, 0, 0, time.UTC)
|
||
info, ok := eclipsecore.LunarEclipseOnDate(date)
|
||
if !ok {
|
||
t.Fatal("missing lunar eclipse")
|
||
}
|
||
frame := eclipseMapFrame(lunarEclipseMapDefaultWidth, lunarEclipseMapDefaultHeight,
|
||
svgmap.ProjectionEquirectangular, 142, 92)
|
||
path, boundary := lunarEclipseVisibilityPath(info.PenumbralStart, frame)
|
||
if len(boundary) == 0 {
|
||
t.Fatal("visibility path has no boundary")
|
||
}
|
||
rings := svgClosedPathRings(t, `<path d="`+path+`"/>`)
|
||
if len(rings) == 0 {
|
||
t.Fatal("visibility path has no rings")
|
||
}
|
||
jd := basic.Date2JD(info.PenumbralStart)
|
||
// 只取足够深入地平线以下的见证点:−89.9° 处月心高度约 −0.054°,而更靠近极点的
|
||
// −89.99° 只有约 −0.004°,落在可见性判定本身的数值容差里,不能作为回归依据。
|
||
// Only a witness clearly below the horizon is used: at -89.9 degrees the Moon centre sits
|
||
// about 0.054 degrees down, while -89.99 degrees is only about 0.004 degrees down and lies
|
||
// inside the numerical tolerance of the visibility test itself.
|
||
witnesses := []struct {
|
||
longitude float64
|
||
latitude float64
|
||
}{
|
||
{-115, -89.9},
|
||
}
|
||
for _, witness := range witnesses {
|
||
altitude := basic.HMoonHeight(jd, witness.longitude, witness.latitude, 0)
|
||
if altitude >= -0.01 {
|
||
// 见证点必须先确实是地平线以下,否则这个回归就失去意义。
|
||
t.Fatalf("witness (%g,%g) altitude=%g, want below the horizon",
|
||
witness.longitude, witness.latitude, altitude)
|
||
}
|
||
x, y, projectable := frame.Project(witness.longitude, witness.latitude)
|
||
if !projectable {
|
||
continue
|
||
}
|
||
inside := false
|
||
for _, ring := range rings {
|
||
inside = inside || pointInLunarVisibilityPolygon(x, y, ring)
|
||
}
|
||
if inside {
|
||
t.Fatalf("below-horizon witness (%g,%g) altitude=%g is painted inside the visible region",
|
||
witness.longitude, witness.latitude, altitude)
|
||
}
|
||
}
|
||
}
|