feat: 增强日月食搜索、沙罗周期与内行星凌日
- 使用压缩表加速查找日月食沙罗周期信息 - 优化日月食搜索跳步,减少非食季朔望月扫描 - 新增本地日全食、日环食、月全食搜索接口,返回 ok 区分未找到结果 - 新增水星、金星地心凌日查询及测试
This commit is contained in:
+11
-4
@@ -11,6 +11,7 @@ const (
|
||||
solarEclipseSynodicMonthDays = 29.530588853
|
||||
solarEclipseSearchLimit = 36
|
||||
solarEclipseSearchEpsilonDay = 1e-8
|
||||
solarEclipseLatitudeLimitDeg = 2.0
|
||||
)
|
||||
|
||||
type solarEclipseCalculator func(float64) basic.SolarEclipseResult
|
||||
@@ -236,16 +237,22 @@ func searchSolarEclipse(
|
||||
candidateTT := basic.CalcMoonSHByJDE(targetTT, 0)
|
||||
|
||||
for i := 0; i < solarEclipseSearchLimit; i++ {
|
||||
result := calculator(candidateTT)
|
||||
if result.Type != basic.SolarEclipseNone && solarEclipseMatchesDirection(result.GreatestEclipse, targetTT, direction, includeCurrent) {
|
||||
return solarEclipseInfoFromBasic(result, date.Location()), true
|
||||
if isPotentialSolarEclipse(candidateTT) {
|
||||
result := calculator(candidateTT)
|
||||
if result.Type != basic.SolarEclipseNone && solarEclipseMatchesDirection(result.GreatestEclipse, targetTT, direction, includeCurrent) {
|
||||
return solarEclipseInfoFromBasic(result, date.Location()), true
|
||||
}
|
||||
}
|
||||
candidateTT = basic.CalcMoonSHByJDE(candidateTT+float64(direction)*solarEclipseSynodicMonthDays, 0)
|
||||
candidateTT = nextEclipseSearchCandidateTT(candidateTT, 0, direction, solarEclipseSynodicMonthDays)
|
||||
}
|
||||
|
||||
return SolarEclipseInfo{}, false
|
||||
}
|
||||
|
||||
func isPotentialSolarEclipse(newMoonTT float64) bool {
|
||||
return math.Abs(basic.HMoonTrueBo(newMoonTT)) <= solarEclipseLatitudeLimitDeg
|
||||
}
|
||||
|
||||
func solarEclipseMatchesDirection(greatestTT, targetTT float64, direction int, includeCurrent bool) bool {
|
||||
delta := greatestTT - targetTT
|
||||
if math.Abs(delta) <= solarEclipseSearchEpsilonDay {
|
||||
|
||||
Reference in New Issue
Block a user