2bf8478639
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑 - 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口 - 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界 - 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名 - 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验 - 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口 - 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
package svg
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// 偏食足迹扫描的密步长请求被夹到两分钟:并集需要一整条自洽的扫描序列,
|
|
// 更密的扫描成倍放大成本却不改产物,事后抽稀又会破坏并集的覆盖面判定。
|
|
func TestSolarEclipseMapPartialStepUsesDefaultSweep(t *testing.T) {
|
|
date := time.Date(2024, time.April, 8, 0, 0, 0, 0, time.UTC)
|
|
for _, test := range []struct {
|
|
requested time.Duration
|
|
want time.Duration
|
|
}{
|
|
{requested: 0, want: 2 * time.Minute},
|
|
{requested: -time.Minute, want: 2 * time.Minute},
|
|
{requested: time.Second, want: 2 * time.Minute},
|
|
{requested: 10 * time.Second, want: 2 * time.Minute},
|
|
{requested: time.Minute, want: 2 * time.Minute},
|
|
{requested: 119 * time.Second, want: 2 * time.Minute},
|
|
{requested: 2 * time.Minute, want: 2 * time.Minute},
|
|
{requested: 3 * time.Minute, want: 3 * time.Minute},
|
|
{requested: 10 * time.Minute, want: 10 * time.Minute},
|
|
} {
|
|
got := normalizeSolarEclipseMapSVGOptions(date, SolarEclipseMapSVGOptions{
|
|
PartialStep: test.requested,
|
|
}).PartialStep
|
|
if got != test.want {
|
|
t.Fatalf("PartialStep %s normalized to %s, want %s", test.requested, got, test.want)
|
|
}
|
|
}
|
|
|
|
// 一秒请求与默认两分钟请求必须逐字节相同,代价也回到默认量级。
|
|
fast, fastOK := SolarEclipseMapSVG(date, SolarEclipseMapSVGOptions{
|
|
Width: 900, Height: 620, Location: time.UTC, PartialStep: time.Second,
|
|
})
|
|
defaulted, defaultOK := SolarEclipseMapSVG(date, SolarEclipseMapSVGOptions{
|
|
Width: 900, Height: 620, Location: time.UTC, PartialStep: 2 * time.Minute,
|
|
})
|
|
if !fastOK || !defaultOK {
|
|
t.Fatal("missing 2024-04-08 map")
|
|
}
|
|
if fast != defaulted {
|
|
t.Fatalf("a one-second sweep request changed the rendered document (%d vs %d bytes)", len(fast), len(defaulted))
|
|
}
|
|
}
|