044f2f4381
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
77 lines
2.8 KiB
Go
77 lines
2.8 KiB
Go
package svg
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"b612.me/astro/basic"
|
|
"b612.me/astro/moon"
|
|
)
|
|
|
|
type constantLimb float64
|
|
|
|
func (r constantLimb) LimbRadiusKM(_, _, _ float64) (float64, bool) { return float64(r), true }
|
|
|
|
type failingLimb struct{}
|
|
|
|
func (failingLimb) LimbRadiusKM(_, _, _ float64) (float64, bool) { return 0, false }
|
|
|
|
func TestLocalOccultationSVGAcceptsCustomLimbAndRejectsFailedLimbFlag(t *testing.T) {
|
|
start := time.Date(2034, time.November, 21, 0, 0, 0, 0, time.UTC)
|
|
end := time.Date(2034, time.November, 23, 0, 0, 0, 0, time.UTC)
|
|
find := func(profile basic.LunarLimb) moon.PlanetOccultationInfo {
|
|
t.Helper()
|
|
events, err := moon.FindPlanetOccultations(start, end, moon.OccultationJupiter,
|
|
-42.36358358336173, 21.762064240049245, 0, moon.OccultationSearchOptions{LunarLimb: profile})
|
|
if err != nil || len(events) != 1 {
|
|
t.Fatalf("FindPlanetOccultations() = %d events, %v; want one", len(events), err)
|
|
}
|
|
return events[0]
|
|
}
|
|
circular := find(nil)
|
|
|
|
custom := find(constantLimb(1750))
|
|
if !custom.LunarLimbApplied {
|
|
t.Fatal("constant 1750 km limb: LunarLimbApplied = false, want true")
|
|
}
|
|
if custom.ExternalImmersion.Equal(circular.ExternalImmersion) {
|
|
t.Fatal("constant 1750 km limb did not move the contact")
|
|
}
|
|
diagram, err := LocalPlanetOccultationSVG(custom, LocalPlanetOccultationSVGOptions{Location: time.UTC})
|
|
if err != nil {
|
|
t.Fatalf("LocalPlanetOccultationSVG(custom limb) error = %v", err)
|
|
}
|
|
if !strings.Contains(diagram, "月缘剖面") {
|
|
t.Fatal("custom limb chart does not declare the limb profile")
|
|
}
|
|
|
|
failed := find(failingLimb{})
|
|
if failed.LunarLimbApplied {
|
|
t.Fatal("failing limb: LunarLimbApplied = true, want false")
|
|
}
|
|
if !failed.ExternalImmersion.Equal(circular.ExternalImmersion) || !failed.InternalEmersion.Equal(circular.InternalEmersion) {
|
|
t.Fatal("failing limb changed the circular contacts")
|
|
}
|
|
diagram, err = LocalPlanetOccultationSVG(failed, LocalPlanetOccultationSVGOptions{Location: time.UTC})
|
|
if err != nil {
|
|
t.Fatalf("LocalPlanetOccultationSVG(failed limb) error = %v", err)
|
|
}
|
|
if strings.Contains(diagram, "月缘剖面") || !strings.Contains(diagram, "圆月面") {
|
|
t.Fatal("failed limb chart must declare the circular limb")
|
|
}
|
|
}
|
|
|
|
func TestOccultationPathLimbFlagRequiresCorrectedLimit(t *testing.T) {
|
|
start := time.Date(2034, time.November, 21, 0, 0, 0, 0, time.UTC)
|
|
end := time.Date(2034, time.November, 23, 0, 0, 0, 0, time.UTC)
|
|
paths, err := moon.FindPlanetOccultationPaths(start, end, moon.OccultationJupiter,
|
|
moon.OccultationPathOptions{Step: 10 * time.Minute, TargetSpacingKM: 400, LunarLimb: failingLimb{}})
|
|
if err != nil || len(paths) != 1 {
|
|
t.Fatalf("FindPlanetOccultationPaths() = %d paths, %v; want one", len(paths), err)
|
|
}
|
|
if paths[0].LunarLimbApplied {
|
|
t.Fatal("failing limb: path LunarLimbApplied = true, want false")
|
|
}
|
|
}
|