2bf8478639
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑 - 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口 - 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界 - 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名 - 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验 - 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口 - 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
65 lines
2.4 KiB
Go
65 lines
2.4 KiB
Go
package geojson_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
"time"
|
|
|
|
"b612.me/astro/eclipse"
|
|
"b612.me/astro/geojson"
|
|
)
|
|
|
|
func TestMarshalSolarEclipse21640323ContainsVisibleAnnularEnds(t *testing.T) {
|
|
date := time.Date(2164, 3, 23, 0, 0, 0, 0, time.UTC)
|
|
sites := [][2]float64{{-110.6, 48.75}, {-110.6, 48.5}, {-110.7, 48.76}, {-120.575, 48.75}, {-120.575, 48.745}}
|
|
for _, site := range sites {
|
|
local, ok := eclipse.LocalSolarEclipseOnDate(date, site[0], site[1], 0)
|
|
if !ok || local.Type != eclipse.SolarEclipseAnnular || local.SunAltitude <= 0 {
|
|
t.Fatalf("reference site %v is not visible annular greatest: %+v", site, local)
|
|
}
|
|
}
|
|
for _, step := range []time.Duration{time.Minute, 2 * time.Minute, 5 * time.Minute} {
|
|
t.Run(step.String(), func(t *testing.T) {
|
|
partial, ok := eclipse.SolarEclipsePartialFootprints(date, eclipse.SolarEclipsePartialFootprintOptions{
|
|
Step: step, BoundaryPoints: 96, CentralShadowStep: step,
|
|
MagnitudeValues: []float64{0.2, 0.4, 0.6, 0.8, 1},
|
|
})
|
|
if !ok || partial.Eclipse.Type != eclipse.SolarEclipseHybrid {
|
|
t.Fatal("expected hybrid eclipse")
|
|
}
|
|
central, ok := eclipse.SolarEclipseCentralPath(date, eclipse.SolarEclipsePathOptions{Step: step, TargetSpacingKM: 700})
|
|
if !ok {
|
|
t.Fatal("expected central path")
|
|
}
|
|
data, err := geojson.MarshalSolarEclipse(partial, ¢ral)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
band := featureWithRole(t, decodeCollection(t, data), "central-band")
|
|
for _, site := range sites {
|
|
if !geometryContainsPoint(t, band.Geometry, site[0], site[1]) {
|
|
t.Errorf("central band omits visible annular site %v", site)
|
|
}
|
|
}
|
|
var polygons [][][][]float64
|
|
if err := json.Unmarshal(band.Geometry.Coordinates, &polygons); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, polygon := range polygons {
|
|
assertSolarCentralBandRingSimpleAndSampled(t, polygon[0], 250)
|
|
}
|
|
if len(partial.CentralBandHorizonClosures) != 2 {
|
|
t.Fatalf("horizon closures=%d, want sunrise and sunset", len(partial.CentralBandHorizonClosures))
|
|
}
|
|
for _, closure := range partial.CentralBandHorizonClosures {
|
|
assertSolarPathMaximumEdgeKM(t, closure, 12)
|
|
for _, point := range closure {
|
|
if distance := geoJSONMultiPolygonBoundaryDistanceKM(polygons, []float64{point.Longitude, point.Latitude}); distance > 0.02 {
|
|
t.Fatalf("central band misses horizon closure by %.3f km", distance)
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|