2bf8478639
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑 - 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口 - 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界 - 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名 - 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验 - 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口 - 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
78 lines
3.0 KiB
Go
78 lines
3.0 KiB
Go
package svg
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// 本文件钉住星掩图的"掩带宽"口径与行星图、详细版一致:取南北限地面间距,
|
|
// 不得与 Greatest.WidthKM 互相换算。
|
|
|
|
func TestStarOccultationSVGUsesLimitSeparationBandWidth(t *testing.T) {
|
|
path := sampleStarOccultationPath()
|
|
path.GreatestLimitSeparationKM = 3123.4
|
|
path.Greatest.WidthKM = 3456.7
|
|
diagram, err := StarOccultationPathSVG(path, StarOccultationSVGOptions{Width: 1200, Height: 800, Location: time.UTC})
|
|
if err != nil {
|
|
t.Fatalf("StarOccultationPathSVG() error = %v", err)
|
|
}
|
|
if !strings.Contains(diagram, "3123.4 km") {
|
|
t.Fatal("stellar SVG band width does not use GreatestLimitSeparationKM")
|
|
}
|
|
if strings.Contains(diagram, "3456.7 km") {
|
|
t.Fatal("stellar SVG band width still uses Greatest.WidthKM")
|
|
}
|
|
}
|
|
|
|
func TestStarOccultationSVGBandWidthFallsBackToGreatestWidth(t *testing.T) {
|
|
path := sampleStarOccultationPath()
|
|
path.GreatestLimitSeparationKM = 0
|
|
path.Greatest.WidthKM = 3456.7
|
|
diagram, err := StarOccultationPathSVG(path, StarOccultationSVGOptions{Width: 1200, Height: 800, Location: time.UTC})
|
|
if err != nil {
|
|
t.Fatalf("StarOccultationPathSVG() error = %v", err)
|
|
}
|
|
if !strings.Contains(diagram, "3456.7 km") {
|
|
t.Fatal("stellar SVG band width lost the Greatest.WidthKM fallback for paths without limit separations")
|
|
}
|
|
}
|
|
|
|
func TestOccultationBandWidthSourcesAreNotInterchangeable(t *testing.T) {
|
|
starPath := occultationTestStarPath(t)
|
|
if starPath.GreatestLimitSeparationKM <= 0 || starPath.Greatest.WidthKM <= 0 {
|
|
t.Fatalf("fixture widths = %.3f / %.3f, want both populated",
|
|
starPath.GreatestLimitSeparationKM, starPath.Greatest.WidthKM)
|
|
}
|
|
if math.Abs(starPath.GreatestLimitSeparationKM-starPath.Greatest.WidthKM) < 1 {
|
|
t.Fatalf("fixture widths %.3f / %.3f are equal; the semantics check would be vacuous",
|
|
starPath.GreatestLimitSeparationKM, starPath.Greatest.WidthKM)
|
|
}
|
|
diagram, err := StarOccultationPathSVG(starPath, StarOccultationSVGOptions{Width: 1200, Height: 800, Location: time.UTC})
|
|
if err != nil {
|
|
t.Fatalf("StarOccultationPathSVG() error = %v", err)
|
|
}
|
|
expected := occultationTestWidthText(starPath.GreatestLimitSeparationKM)
|
|
if !strings.Contains(diagram, expected) {
|
|
t.Fatalf("stellar SVG is missing the limit-separation width %q", expected)
|
|
}
|
|
if other := occultationTestWidthText(starPath.Greatest.WidthKM); strings.Contains(diagram, other) {
|
|
t.Fatalf("stellar SVG reports the non-interchangeable Greatest.WidthKM %q", other)
|
|
}
|
|
|
|
planetPath := occultationTestSaturnPath(t)
|
|
planetDiagram, err := PlanetOccultationPathSVG(planetPath, StarOccultationSVGOptions{Width: 1200, Height: 800, Location: time.UTC})
|
|
if err != nil {
|
|
t.Fatalf("PlanetOccultationPathSVG() error = %v", err)
|
|
}
|
|
if expected := occultationTestWidthText(planetPath.GreatestLimitSeparationKM); !strings.Contains(planetDiagram, expected) {
|
|
t.Fatalf("planetary SVG is missing the limit-separation width %q", expected)
|
|
}
|
|
}
|
|
|
|
func occultationTestWidthText(width float64) string {
|
|
return fmt.Sprintf("%.1f km", width)
|
|
}
|