Files
astro/geojson/eclipse_antimeridian_internal_test.go
T
b612 2bf8478639 feat: 完善日月食与月掩几何链路并扩展历法接口
- 新增日月食中心带、偏食带、阴影足迹、等时线、食分线及升落边界计算,支持极区与混合食拓扑
- 新增日食单时刻阴影求解器、站心状态查询、批量采样和 ΔT 覆盖接口
- 重构恒星与行星月掩路径,补充有限盘面接触、站心修正、掩带宽度、极区投影及升落边界
- 扩展 SVG 与 GeoJSON 输出,支持详细面板、全球/极区/地球投影、边界闭合、时间标记和拓扑签名
- 扩展日月食候选搜索、局地搜索、沙罗序列预计算与范围外推,补充系列锚点和成员一致性校验
- 补齐古历纪年、儒略历独有闰日、多公历候选、历法改革跨日及精确日期运算接口
- 优化 ΔT、章动、恒星时、月球地平线、事件根搜索和本地星历缓存,降低重复计算开销并提升边界稳定
2026-09-17 12:27:40 +08:00

40 lines
2.0 KiB
Go

package geojson
import (
"math"
"testing"
eclipsecore "b612.me/astro/eclipse"
)
// solarCentralBandPointSegmentKM 用于判断解析限线与导出带边界的偏离量(超过
// solarCentralBandSnapToleranceKM 就会改用环导出边)。跨换日线的限线必须先把经度差
// 归约到 ±180°,否则会被判成数万公里之外。
// solarCentralBandPointSegmentKM measures how far an analytic limit line deviates from the
// exported band boundary (beyond solarCentralBandSnapToleranceKM the ring edge wins). A
// limit line crossing the antimeridian must wrap its longitude difference to ±180°, or it
// reads as tens of thousands of kilometres away.
func TestSolarCentralBandPointSegmentWrapsAtAntimeridian(t *testing.T) {
point := eclipsecore.SolarEclipsePathPoint{Longitude: 179.99, Latitude: 10}
first := eclipsecore.SolarEclipsePathPoint{Longitude: 179.95, Latitude: 10}
second := eclipsecore.SolarEclipsePathPoint{Longitude: -179.95, Latitude: 10}
// 该点落在这一段的内部(180° 处是段内点),距离必须是 0。
// The point lies inside the segment (which passes 180°), so the distance is zero.
if got := solarCentralBandPointSegmentKM(point, first, second); math.Abs(got) > 0.5 {
t.Fatalf("point on an antimeridian-crossing segment measured %v km away", got)
}
// 反向跨越(从 +179.95 到 -179.95 之外)同样要归约。
// Wrapping must also hold when the segment runs the other way.
if got := solarCentralBandPointSegmentKM(point, second, first); math.Abs(got) > 0.5 {
t.Fatalf("reversed segment measured %v km away", got)
}
// 普通(非换日线)段的距离不受影响:与水平段相差 1° 纬度 ≈ 111.32 km。
// An ordinary segment keeps its plain latitudinal distance: 1° of latitude off a
// horizontal segment is 111.32 km.
far := eclipsecore.SolarEclipsePathPoint{Longitude: 179.99, Latitude: 11}
if got := solarCentralBandPointSegmentKM(far, first, second); math.Abs(got-111.32) > 0.5 {
t.Fatalf("plain segment distance = %v km, want about 111.32 km", got)
}
}