feat: 引入可切换星历模型并扩展天象观测链路
- 新增半解析、旧模型、自定义与多源堆叠星历实例,提供 Context、Instance、SPK 读取及状态与视位置计算 - 统一太阳、月球和行星实例接口,扩展黄经穿越、留、相位、最近角距、偕日可见、任意高度升落、轨道节点及凌日等天象查询 - 完善日月食、月掩与凌日的月缘剖面、有限盘面接触、站心修正、局地可见性、全球路径和地图输出 - 新增 SVG、GeoJSON、KML 天象输出及凌日、月掩和月缘地形相关缓存与几何求解 - 新增恒星星表导入与查询,支持 CSV、Hipparcos、BSC5、Stellarium 等格式及名称、交叉标识、锥面检索和星等过滤 - 补充 IAU 2006、地球定向、折射消光、大气观测、轨道传播及半解析行星/月球数据支持 - 将默认未来民用时标切换为 TimeScaleLeapHour,更新 2027–2400 农历速查表、中文日期解析和时区边界处理 - 增加事件基线、跨模型回归、几何边界、月缘地形和输出契约测试,完善中英文手册、示例资源、NOTICE 与忽略规则
This commit is contained in:
@@ -18,18 +18,10 @@ import (
|
||||
"time"
|
||||
|
||||
"b612.me/astro/basic"
|
||||
"b612.me/astro/internal/ephem"
|
||||
"b612.me/astro/internal/geodata"
|
||||
)
|
||||
|
||||
// normalizeLongitude 把经度归一化到 [-180, 180);internal/geodata 与 geojson 各有一份等价的未导出实现,无法跨包复用。
|
||||
func normalizeLongitude(value float64) float64 {
|
||||
value = math.Mod(value+180, 360)
|
||||
if value < 0 {
|
||||
value += 360
|
||||
}
|
||||
return value - 180
|
||||
}
|
||||
|
||||
// defaultToleranceDegrees 是 GeoJSON 导出使用的误差门限。GeoJSON 客户端可以无限放大,
|
||||
// 因此这里取远小于任何地图像素的角度。
|
||||
// defaultToleranceDegrees is the error tolerance used by the GeoJSON export. GeoJSON clients
|
||||
@@ -47,7 +39,12 @@ const DefaultToleranceDegrees = defaultToleranceDegrees
|
||||
// longitude. Refine in map coordinates before clipping; extra vertices are
|
||||
// corrected to the same topocentric zero-altitude curve as the source ring.
|
||||
func Refine(points []geodata.GeoPoint, at time.Time) []geodata.GeoPoint {
|
||||
return RefineWithin(points, at, defaultToleranceDegrees)
|
||||
return RefineWithInstance(points, at, nil)
|
||||
}
|
||||
|
||||
// RefineWithInstance 指定星历实例的站心地平线细分 / topocentric horizon refinement with an explicit instance.
|
||||
func RefineWithInstance(points []geodata.GeoPoint, at time.Time, inst *ephem.Instance) []geodata.GeoPoint {
|
||||
return RefineWithinWithInstance(points, at, defaultToleranceDegrees, inst)
|
||||
}
|
||||
|
||||
// RefineWithin 用给定误差门限(单位:度)细分一条站心地平线。插入的顶点被校正回零高度,
|
||||
@@ -58,6 +55,11 @@ func Refine(points []geodata.GeoPoint, at time.Time) []geodata.GeoPoint {
|
||||
// accuracy without moving the curve. A fixed-resolution target such as an SVG map can pass a
|
||||
// tolerance matched to its pixel scale instead of emitting vertices no display can resolve.
|
||||
func RefineWithin(points []geodata.GeoPoint, at time.Time, toleranceDegrees float64) []geodata.GeoPoint {
|
||||
return RefineWithinWithInstance(points, at, toleranceDegrees, nil)
|
||||
}
|
||||
|
||||
// RefineWithinWithInstance 指定星历实例和误差门限的站心地平线细分 / topocentric horizon refinement with an explicit instance and tolerance.
|
||||
func RefineWithinWithInstance(points []geodata.GeoPoint, at time.Time, toleranceDegrees float64, inst *ephem.Instance) []geodata.GeoPoint {
|
||||
if !(toleranceDegrees > 0) {
|
||||
toleranceDegrees = defaultToleranceDegrees
|
||||
}
|
||||
@@ -66,10 +68,10 @@ func RefineWithin(points []geodata.GeoPoint, at time.Time, toleranceDegrees floa
|
||||
}
|
||||
jd := basic.Date2JD(at.UTC())
|
||||
tt := basic.UTC2TT(jd)
|
||||
ra, dec := basic.HMoonTrueRaDec(tt)
|
||||
distanceAU := basic.HMoonAway(tt) / 149597870.7
|
||||
ra, dec := basic.HMoonTrueRaDecWithInstance(tt, inst)
|
||||
distanceAU := basic.HMoonAwayWithInstance(tt, inst) / 149597870.7
|
||||
sidereal := basic.ApparentSiderealTime(basic.UTC2UT1(jd)) * 15
|
||||
center := geodata.GeoPoint{Longitude: normalizeLongitude(ra - sidereal), Latitude: dec}
|
||||
center := geodata.GeoPoint{Longitude: geodata.NormalizeLongitude(ra - sidereal), Latitude: dec}
|
||||
// Every correction is at the same instant. Reuse its full ephemeris while
|
||||
// retaining the ellipsoid and topocentric transform used by HMoonHeight.
|
||||
altitudeAt := func(point geodata.GeoPoint) float64 {
|
||||
|
||||
Reference in New Issue
Block a user