2bf8478639
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑 - 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口 - 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界 - 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名 - 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验 - 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口 - 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
62 lines
2.1 KiB
Go
62 lines
2.1 KiB
Go
package geojson_test
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
"time"
|
|
|
|
"b612.me/astro/eclipse"
|
|
"b612.me/astro/geojson"
|
|
)
|
|
|
|
func TestSolarTotalBandIndependentOfMagnitudeLines(t *testing.T) {
|
|
for _, fixture := range []struct {
|
|
date time.Time
|
|
lon, lat float64
|
|
}{
|
|
{time.Date(2026, 8, 12, 0, 0, 0, 0, time.UTC), -5.991755201, 45.070085755},
|
|
{time.Date(2024, 4, 8, 0, 0, 0, 0, time.UTC), -32.007627414, 49.493804579},
|
|
} {
|
|
t.Run(fixture.date.Format("2006-01-02"), func(t *testing.T) {
|
|
central, ok := eclipse.SolarEclipseCentralPath(fixture.date, eclipse.SolarEclipsePathOptions{Step: time.Minute})
|
|
if !ok {
|
|
t.Fatal("missing central path")
|
|
}
|
|
local, ok := eclipse.GeometricLocalSolarEclipseOnDate(fixture.date, fixture.lon, fixture.lat, 0)
|
|
if !ok || local.Type != eclipse.SolarEclipseTotal || !local.VisibleAtGreatest {
|
|
t.Fatal("invalid totality witness")
|
|
}
|
|
var reference [][]eclipse.SolarEclipsePathPoint
|
|
for _, magnitudes := range [][]float64{nil, {1}} {
|
|
partial, ok := eclipse.SolarEclipsePartialFootprints(fixture.date, eclipse.SolarEclipsePartialFootprintOptions{
|
|
Step: 2 * time.Minute, BoundaryPoints: 96, MagnitudeValues: magnitudes,
|
|
})
|
|
if !ok || len(partial.CentralBandSegments) == 0 {
|
|
t.Fatal("missing authoritative totality band")
|
|
}
|
|
if reference == nil {
|
|
reference = partial.CentralBandSegments
|
|
} else if !reflect.DeepEqual(reference, partial.CentralBandSegments) {
|
|
t.Fatal("magnitude display option changes totality geometry")
|
|
}
|
|
if len(magnitudes) == 0 && len(partial.MagnitudeContours) != 0 {
|
|
t.Fatal("unrequested magnitude lines")
|
|
}
|
|
for _, ring := range partial.CentralBandSegments {
|
|
assertSolarPathMaximumEdgeKM(t, ring, 250)
|
|
}
|
|
for _, path := range []*eclipse.SolarEclipsePath{¢ral, nil} {
|
|
data, err := geojson.MarshalSolarEclipse(partial, path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
band := featureWithRole(t, decodeCollection(t, data), "central-band")
|
|
if !geometryContainsPoint(t, band.Geometry, fixture.lon, fixture.lat) {
|
|
t.Fatal("totality band omits visible site")
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|