railwise-ai 1.2.32 → 1.2.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-pack/README.md +16 -0
- package/agent-pack/assets/agent/chief_manager.md +69 -0
- package/agent-pack/assets/agent/commercial_specialist.md +47 -0
- package/agent-pack/assets/agent/data_analyst.md +54 -0
- package/agent-pack/assets/agent/docs.md +38 -0
- package/agent-pack/assets/agent/duplicate-pr.md +25 -0
- package/agent-pack/assets/agent/qa_inspector.md +58 -0
- package/agent-pack/assets/agent/qa_reviewer.md +57 -0
- package/agent-pack/assets/agent/solution_architect.md +53 -0
- package/agent-pack/assets/agent/technical_writer.md +61 -0
- package/agent-pack/assets/agent/translator.md +34 -0
- package/agent-pack/assets/agent/triage.md +139 -0
- package/agent-pack/assets/command/ai-deps.md +24 -0
- package/agent-pack/assets/command/bid-intel.md +29 -0
- package/agent-pack/assets/command/bid-prepare.md +24 -0
- package/agent-pack/assets/command/commit.md +37 -0
- package/agent-pack/assets/command/daily-report.md +26 -0
- package/agent-pack/assets/command/data-check.md +22 -0
- package/agent-pack/assets/command/emergency-response.md +66 -0
- package/agent-pack/assets/command/issues.md +23 -0
- package/agent-pack/assets/command/learn.md +42 -0
- package/agent-pack/assets/command/monthly-report.md +35 -0
- package/agent-pack/assets/command/payment-reminder.md +27 -0
- package/agent-pack/assets/command/plan-draft.md +28 -0
- package/agent-pack/assets/command/review-response.md +23 -0
- package/agent-pack/assets/command/rmslop.md +15 -0
- package/agent-pack/assets/command/safety-check.md +20 -0
- package/agent-pack/assets/command/spellcheck.md +5 -0
- package/agent-pack/assets/command/trend-analysis.md +38 -0
- package/agent-pack/assets/command/weekly-report.md +28 -0
- package/agent-pack/assets/lib/os_api.ts +100 -0
- package/agent-pack/assets/skill/adjustment-report/SKILL.md +88 -0
- package/agent-pack/assets/skill/approval-flow-intelligence/SKILL.md +123 -0
- package/agent-pack/assets/skill/bidding-knowledge/SKILL.md +98 -0
- package/agent-pack/assets/skill/bun-file-io/SKILL.md +42 -0
- package/agent-pack/assets/skill/business-finance/SKILL.md +91 -0
- package/agent-pack/assets/skill/business-operations-analytics/SKILL.md +120 -0
- package/agent-pack/assets/skill/cad-bim-review/SKILL.md +84 -0
- package/agent-pack/assets/skill/canvas-design/SKILL.md +141 -0
- package/agent-pack/assets/skill/construction-monitoring/SKILL.md +89 -0
- package/agent-pack/assets/skill/customer-portal-brief/SKILL.md +121 -0
- package/agent-pack/assets/skill/data-analysis/SKILL.md +79 -0
- package/agent-pack/assets/skill/di-bao-monitoring/SKILL.md +680 -0
- package/agent-pack/assets/skill/di-bao-monitoring/agents/openai.yaml +4 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/crossing-static-level-input-template.csv +2 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/crossing-total-station-input-template.csv +2 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/crossing-total-station-report-template.md +59 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/daily-report-template.md +90 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/data-input-template.csv +2 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/initial-value-report-template.md +92 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/monthly-report-template.md +103 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/plan-template.md +673 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/point-alias-map-template.json +25 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/project-brief-template.md +59 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/project-summary-template.md +154 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/warning-notice-template.md +58 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets/weekly-report-template.md +49 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets//345/256/214/346/225/264/346/212/245/350/241/250/346/250/241/346/235/277.xlsx +0 -0
- package/agent-pack/assets/skill/di-bao-monitoring/assets//345/277/253/346/212/245/346/250/241/346/235/277.xlsx +0 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/crossing-static-level-report.md +115 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/crossing-total-station-report.md +206 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/data-processing.md +170 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/elevated-line.md +319 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/initial-and-summary-workflow.md +222 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/key-difficulties.md +216 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/monitoring-catalog.md +80 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/phase0-intake.md +169 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/phase1-drafting.md +185 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/phase2-internal-review.md +166 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/report-workflow.md +181 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/review-checklist.md +140 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/review-response-template.md +87 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/scoping-and-pricing.md +214 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/source-analysis.md +137 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/technical-standards.md +188 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/toc-template-A.md +142 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/toc-template-B.md +100 -0
- package/agent-pack/assets/skill/di-bao-monitoring/references/warning-workflow.md +63 -0
- package/agent-pack/assets/skill/di-bao-monitoring/scripts/build_crossing_total_station_xlsx.py +2438 -0
- package/agent-pack/assets/skill/di-bao-monitoring/scripts/evaluate_alarms.py +215 -0
- package/agent-pack/assets/skill/di-bao-monitoring/scripts/fetch_adjusted_total_station.py +946 -0
- package/agent-pack/assets/skill/di-bao-monitoring/scripts/fetch_shhh_static_level.py +556 -0
- package/agent-pack/assets/skill/di-bao-monitoring/scripts/run_crossing_4h_report.sh +141 -0
- package/agent-pack/assets/skill/di-bao-monitoring/scripts/summarize_crossing_total_station.py +303 -0
- package/agent-pack/assets/skill/docx-generation/SKILL.md +141 -0
- package/agent-pack/assets/skill/excel-operations/SKILL.md +121 -0
- package/agent-pack/assets/skill/frontend-design/SKILL.md +151 -0
- package/agent-pack/assets/skill/humanizer/SKILL.md +90 -0
- package/agent-pack/assets/skill/monitoring-design/SKILL.md +100 -0
- package/agent-pack/assets/skill/operational-monitoring/SKILL.md +135 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/checklists/archive-self-check.md +54 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/schemas/convergence-result-table.csv +5 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/schemas/horizontal-result-table.csv +3 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/schemas/settlement-result-table.csv +7 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/scripts/init-archive-tree.sh +65 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/control-network-report.md +102 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/daily-log.md +47 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/i-angle-check.md +38 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/monitoring-scheme.md +234 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/period-report.md +95 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/point-acceptance-record.md +51 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/point-installation-record.md +38 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/summary-report.md +89 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/warning-bulletin.md +61 -0
- package/agent-pack/assets/skill/operational-monitoring/assets/templates/weekly-monthly-report.md +46 -0
- package/agent-pack/assets/skill/operational-monitoring/references/archive-and-delivery.md +146 -0
- package/agent-pack/assets/skill/operational-monitoring/references/baseline-network.md +131 -0
- package/agent-pack/assets/skill/operational-monitoring/references/convergence-monitoring.md +134 -0
- package/agent-pack/assets/skill/operational-monitoring/references/data-processing.md +178 -0
- package/agent-pack/assets/skill/operational-monitoring/references/horizontal-displacement.md +128 -0
- package/agent-pack/assets/skill/operational-monitoring/references/monitoring-points.md +132 -0
- package/agent-pack/assets/skill/operational-monitoring/references/monitoring-scheme.md +178 -0
- package/agent-pack/assets/skill/operational-monitoring/references/period-report.md +108 -0
- package/agent-pack/assets/skill/operational-monitoring/references/regulations-and-frequency.md +127 -0
- package/agent-pack/assets/skill/operational-monitoring/references/settlement-monitoring.md +116 -0
- package/agent-pack/assets/skill/operational-monitoring/references/summary-report.md +128 -0
- package/agent-pack/assets/skill/operational-monitoring/references/warning-and-disposal.md +118 -0
- package/agent-pack/assets/skill/ops-monitoring/SKILL.md +93 -0
- package/agent-pack/assets/skill/railwise-knowledge-curation/SKILL.md +92 -0
- package/agent-pack/assets/skill/report-dibao/SKILL.md +60 -0
- package/agent-pack/assets/skill/report-writing/SKILL.md +103 -0
- package/agent-pack/assets/skill/resource-dispatch-intelligence/SKILL.md +125 -0
- package/agent-pack/assets/skill/standard-reference/SKILL.md +101 -0
- package/agent-pack/assets/skill/weekly-work-intelligence/SKILL.md +123 -0
- package/agent-pack/assets/template/adjustment-trend.json +53 -0
- package/agent-pack/assets/template/bid-technical-proposal.json +42 -0
- package/agent-pack/assets/template/compliance-review.json +35 -0
- package/agent-pack/assets/template/daily-monitor-report.json +34 -0
- package/agent-pack/assets/template/field-data-qa.json +47 -0
- package/agent-pack/assets/template/monitoring-plan.json +28 -0
- package/agent-pack/assets/template/monthly-monitor-report.json +47 -0
- package/agent-pack/assets/template/project-ppt.json +47 -0
- package/agent-pack/assets/template/review-response.json +28 -0
- package/agent-pack/assets/template/schema.json +72 -0
- package/agent-pack/assets/template/weekly-monitor-report.json +33 -0
- package/agent-pack/assets/theme/mytheme.json +223 -0
- package/agent-pack/assets/tool/angle_convert.ts +151 -0
- package/agent-pack/assets/tool/axial_force.ts +186 -0
- package/agent-pack/assets/tool/chart_generator.ts +185 -0
- package/agent-pack/assets/tool/control_network.ts +413 -0
- package/agent-pack/assets/tool/coord_transform.ts +333 -0
- package/agent-pack/assets/tool/cpiii_adjustment.ts +446 -0
- package/agent-pack/assets/tool/cross_section.ts +356 -0
- package/agent-pack/assets/tool/deformation_rate.ts +234 -0
- package/agent-pack/assets/tool/distance_calculator.ts +239 -0
- package/agent-pack/assets/tool/excel_export.ts +494 -0
- package/agent-pack/assets/tool/format_parser.ts +181 -0
- package/agent-pack/assets/tool/github-pr-search.ts +57 -0
- package/agent-pack/assets/tool/github-pr-search.txt +10 -0
- package/agent-pack/assets/tool/github-triage.ts +113 -0
- package/agent-pack/assets/tool/github-triage.txt +6 -0
- package/agent-pack/assets/tool/inclinometer.ts +248 -0
- package/agent-pack/assets/tool/monitoring_csv.ts +120 -0
- package/agent-pack/assets/tool/os_contract_query.ts +63 -0
- package/agent-pack/assets/tool/os_dibao_project_files.ts +75 -0
- package/agent-pack/assets/tool/os_file_download_ref.ts +48 -0
- package/agent-pack/assets/tool/os_file_preview.ts +46 -0
- package/agent-pack/assets/tool/os_gbrain_think.ts +31 -0
- package/agent-pack/assets/tool/os_ppt_generate.ts +37 -0
- package/agent-pack/assets/tool/os_project_context.ts +24 -0
- package/agent-pack/assets/tool/os_report_publish.ts +28 -0
- package/agent-pack/assets/tool/os_wiki_ingest.ts +38 -0
- package/agent-pack/assets/tool/os_wiki_query.ts +26 -0
- package/agent-pack/assets/tool/pile_stakeout.ts +299 -0
- package/agent-pack/assets/tool/report_export.ts +279 -0
- package/agent-pack/assets/tool/shield_guidance.ts +311 -0
- package/agent-pack/assets/tool/standard_query.ts +391 -0
- package/agent-pack/assets/tool/survey_calculator.ts +415 -0
- package/agent-pack/assets/tool/water_level.ts +209 -0
- package/agent-pack/bin/install.js +183 -0
- package/agent-pack/package.json +695 -0
- package/package.json +14 -8
- package/postinstall.mjs +53 -22
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/// <reference path="../env.d.ts" />
|
|
2
|
+
import { tool } from "nb-railwise/tool"
|
|
3
|
+
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Ellipsoid parameters for Chinese geodetic datums
|
|
6
|
+
// ============================================================
|
|
7
|
+
|
|
8
|
+
const ELLIPSOIDS = {
|
|
9
|
+
CGCS2000: { a: 6378137.0, f: 1 / 298.257222101, desc: "中国大地坐标系2000" },
|
|
10
|
+
WGS84: { a: 6378137.0, f: 1 / 298.257223563, desc: "WGS-84坐标系" },
|
|
11
|
+
Xian80: { a: 6378140.0, f: 1 / 298.257, desc: "1980西安坐标系(IAG-75椭球)" },
|
|
12
|
+
Beijing54: { a: 6378245.0, f: 1 / 298.3, desc: "1954北京坐标系(克拉索夫斯基椭球)" },
|
|
13
|
+
} as const
|
|
14
|
+
|
|
15
|
+
type Datum = keyof typeof ELLIPSOIDS
|
|
16
|
+
|
|
17
|
+
function params(datum: Datum) {
|
|
18
|
+
const e = ELLIPSOIDS[datum]
|
|
19
|
+
const b = e.a * (1 - e.f)
|
|
20
|
+
const e2 = (e.a * e.a - b * b) / (e.a * e.a)
|
|
21
|
+
const ep2 = (e.a * e.a - b * b) / (b * b)
|
|
22
|
+
return { a: e.a, b, f: e.f, e2, ep2, desc: e.desc }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ============================================================
|
|
26
|
+
// Gauss-Krüger forward projection (BL → xy)
|
|
27
|
+
// ============================================================
|
|
28
|
+
|
|
29
|
+
function forward(latDeg: number, lonDeg: number, centralMeridian: number, datum: Datum) {
|
|
30
|
+
const p = params(datum)
|
|
31
|
+
const lat = (latDeg * Math.PI) / 180
|
|
32
|
+
const dl = ((lonDeg - centralMeridian) * Math.PI) / 180
|
|
33
|
+
|
|
34
|
+
const sinB = Math.sin(lat)
|
|
35
|
+
const cosB = Math.cos(lat)
|
|
36
|
+
const tanB = Math.tan(lat)
|
|
37
|
+
const N = p.a / Math.sqrt(1 - p.e2 * sinB * sinB)
|
|
38
|
+
const eta2 = p.ep2 * cosB * cosB
|
|
39
|
+
const t = tanB
|
|
40
|
+
|
|
41
|
+
// Meridian arc length
|
|
42
|
+
const A0 = 1 - p.e2 / 4 - (3 * p.e2 * p.e2) / 64 - (5 * p.e2 * p.e2 * p.e2) / 256
|
|
43
|
+
const A2 = (3 / 8) * (p.e2 + (p.e2 * p.e2) / 4 + (15 * p.e2 * p.e2 * p.e2) / 128)
|
|
44
|
+
const A4 = (15 / 256) * (p.e2 * p.e2 + (3 * p.e2 * p.e2 * p.e2) / 4)
|
|
45
|
+
const A6 = (35 * p.e2 * p.e2 * p.e2) / 3072
|
|
46
|
+
const M = p.a * (A0 * lat - A2 * Math.sin(2 * lat) + A4 * Math.sin(4 * lat) - A6 * Math.sin(6 * lat))
|
|
47
|
+
|
|
48
|
+
const dl2 = dl * dl
|
|
49
|
+
const dl4 = dl2 * dl2
|
|
50
|
+
const dl6 = dl4 * dl2
|
|
51
|
+
|
|
52
|
+
const x =
|
|
53
|
+
M +
|
|
54
|
+
((N * sinB * cosB) / 2) * dl2 +
|
|
55
|
+
((N * sinB * cosB * cosB * cosB) / 24) * (5 - t * t + 9 * eta2 + 4 * eta2 * eta2) * dl4 +
|
|
56
|
+
((N * sinB * Math.pow(cosB, 5)) / 720) * (61 - 58 * t * t + t * t * t * t) * dl6
|
|
57
|
+
|
|
58
|
+
const y =
|
|
59
|
+
N * cosB * dl +
|
|
60
|
+
((N * cosB * cosB * cosB) / 6) * (1 - t * t + eta2) * dl2 * dl +
|
|
61
|
+
((N * Math.pow(cosB, 5)) / 120) * (5 - 18 * t * t + t * t * t * t + 14 * eta2 - 58 * eta2 * t * t) * dl4 * dl
|
|
62
|
+
|
|
63
|
+
return { x, y }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ============================================================
|
|
67
|
+
// Gauss-Krüger inverse projection (xy → BL)
|
|
68
|
+
// ============================================================
|
|
69
|
+
|
|
70
|
+
function inverse(x: number, y: number, centralMeridian: number, datum: Datum) {
|
|
71
|
+
const p = params(datum)
|
|
72
|
+
|
|
73
|
+
// Footprint latitude by iterating meridian arc
|
|
74
|
+
const A0 = 1 - p.e2 / 4 - (3 * p.e2 * p.e2) / 64 - (5 * p.e2 * p.e2 * p.e2) / 256
|
|
75
|
+
let Bf = x / (p.a * A0)
|
|
76
|
+
for (let i = 0; i < 10; i++) {
|
|
77
|
+
const A2 = (3 / 8) * (p.e2 + (p.e2 * p.e2) / 4 + (15 * p.e2 * p.e2 * p.e2) / 128)
|
|
78
|
+
const A4 = (15 / 256) * (p.e2 * p.e2 + (3 * p.e2 * p.e2 * p.e2) / 4)
|
|
79
|
+
const A6 = (35 * p.e2 * p.e2 * p.e2) / 3072
|
|
80
|
+
const Mf = p.a * (A0 * Bf - A2 * Math.sin(2 * Bf) + A4 * Math.sin(4 * Bf) - A6 * Math.sin(6 * Bf))
|
|
81
|
+
Bf = Bf + (x - Mf) / (p.a * A0)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const sinBf = Math.sin(Bf)
|
|
85
|
+
const cosBf = Math.cos(Bf)
|
|
86
|
+
const tanBf = Math.tan(Bf)
|
|
87
|
+
const Nf = p.a / Math.sqrt(1 - p.e2 * sinBf * sinBf)
|
|
88
|
+
const Rf = (p.a * (1 - p.e2)) / Math.pow(1 - p.e2 * sinBf * sinBf, 1.5)
|
|
89
|
+
const eta2 = p.ep2 * cosBf * cosBf
|
|
90
|
+
const tf = tanBf
|
|
91
|
+
const tf2 = tf * tf
|
|
92
|
+
|
|
93
|
+
const y2 = y * y
|
|
94
|
+
const y4 = y2 * y2
|
|
95
|
+
const y6 = y4 * y2
|
|
96
|
+
|
|
97
|
+
const lat =
|
|
98
|
+
Bf -
|
|
99
|
+
(tf / (2 * Rf * Nf)) * y2 +
|
|
100
|
+
(tf / (24 * Rf * Nf * Nf * Nf)) * (5 + 3 * tf2 + eta2 - 9 * eta2 * tf2) * y4 -
|
|
101
|
+
(tf / (720 * Rf * Math.pow(Nf, 5))) * (61 + 90 * tf2 + 45 * tf2 * tf2) * y6
|
|
102
|
+
|
|
103
|
+
const lon =
|
|
104
|
+
y / (Nf * cosBf) -
|
|
105
|
+
((y2 * y) / (6 * Nf * Nf * Nf * cosBf)) * (1 + 2 * tf2 + eta2) +
|
|
106
|
+
((y4 * y) / (120 * Math.pow(Nf, 5) * cosBf)) * (5 + 28 * tf2 + 24 * tf2 * tf2 + 6 * eta2 + 8 * eta2 * tf2)
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
lat: (lat * 180) / Math.PI,
|
|
110
|
+
lon: centralMeridian + (lon * 180) / Math.PI,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ============================================================
|
|
115
|
+
// 7-parameter Bursa-Wolf datum transformation
|
|
116
|
+
// ============================================================
|
|
117
|
+
|
|
118
|
+
function blh2xyz(latDeg: number, lonDeg: number, h: number, datum: Datum) {
|
|
119
|
+
const p = params(datum)
|
|
120
|
+
const lat = (latDeg * Math.PI) / 180
|
|
121
|
+
const lon = (lonDeg * Math.PI) / 180
|
|
122
|
+
const sinB = Math.sin(lat)
|
|
123
|
+
const cosB = Math.cos(lat)
|
|
124
|
+
const sinL = Math.sin(lon)
|
|
125
|
+
const cosL = Math.cos(lon)
|
|
126
|
+
const N = p.a / Math.sqrt(1 - p.e2 * sinB * sinB)
|
|
127
|
+
return {
|
|
128
|
+
X: (N + h) * cosB * cosL,
|
|
129
|
+
Y: (N + h) * cosB * sinL,
|
|
130
|
+
Z: (N * (1 - p.e2) + h) * sinB,
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function xyz2blh(X: number, Y: number, Z: number, datum: Datum) {
|
|
135
|
+
const p = params(datum)
|
|
136
|
+
const lon = Math.atan2(Y, X)
|
|
137
|
+
const rho = Math.sqrt(X * X + Y * Y)
|
|
138
|
+
let lat = Math.atan2(Z, rho * (1 - p.e2))
|
|
139
|
+
|
|
140
|
+
for (let i = 0; i < 10; i++) {
|
|
141
|
+
const sinB = Math.sin(lat)
|
|
142
|
+
const N = p.a / Math.sqrt(1 - p.e2 * sinB * sinB)
|
|
143
|
+
lat = Math.atan2(Z + p.e2 * N * sinB, rho)
|
|
144
|
+
}
|
|
145
|
+
const sinB = Math.sin(lat)
|
|
146
|
+
const N = p.a / Math.sqrt(1 - p.e2 * sinB * sinB)
|
|
147
|
+
const h = rho / Math.cos(lat) - N
|
|
148
|
+
|
|
149
|
+
return { lat: (lat * 180) / Math.PI, lon: (lon * 180) / Math.PI, h }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function bursa(
|
|
153
|
+
X: number,
|
|
154
|
+
Y: number,
|
|
155
|
+
Z: number,
|
|
156
|
+
dx: number,
|
|
157
|
+
dy: number,
|
|
158
|
+
dz: number,
|
|
159
|
+
rx: number,
|
|
160
|
+
ry: number,
|
|
161
|
+
rz: number,
|
|
162
|
+
s: number,
|
|
163
|
+
) {
|
|
164
|
+
const rxr = (rx * Math.PI) / 180 / 3600
|
|
165
|
+
const ryr = (ry * Math.PI) / 180 / 3600
|
|
166
|
+
const rzr = (rz * Math.PI) / 180 / 3600
|
|
167
|
+
const sc = 1 + s * 1e-6
|
|
168
|
+
return {
|
|
169
|
+
X: dx + sc * (X + rzr * Y - ryr * Z),
|
|
170
|
+
Y: dy + sc * (-rzr * X + Y + rxr * Z),
|
|
171
|
+
Z: dz + sc * (ryr * X - rxr * Y + Z),
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Common approximate 7-parameter sets (China region, for engineering use)
|
|
176
|
+
// These are approximate values for demonstration; real projects should use
|
|
177
|
+
// local control point fitting for high-precision transformations.
|
|
178
|
+
const TRANSFORMS: Record<
|
|
179
|
+
string,
|
|
180
|
+
{ dx: number; dy: number; dz: number; rx: number; ry: number; rz: number; s: number }
|
|
181
|
+
> = {
|
|
182
|
+
WGS84_to_CGCS2000: { dx: 0, dy: 0, dz: 0, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
183
|
+
CGCS2000_to_WGS84: { dx: 0, dy: 0, dz: 0, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
184
|
+
Beijing54_to_CGCS2000: { dx: -12.064, dy: 130.736, dz: 91.496, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
185
|
+
CGCS2000_to_Beijing54: { dx: 12.064, dy: -130.736, dz: -91.496, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
186
|
+
Xian80_to_CGCS2000: { dx: -4.2, dy: 72.4, dz: 80.6, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
187
|
+
CGCS2000_to_Xian80: { dx: 4.2, dy: -72.4, dz: -80.6, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
188
|
+
Beijing54_to_WGS84: { dx: -12.064, dy: 130.736, dz: 91.496, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
189
|
+
WGS84_to_Beijing54: { dx: 12.064, dy: -130.736, dz: -91.496, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
190
|
+
Xian80_to_WGS84: { dx: -4.2, dy: 72.4, dz: 80.6, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
191
|
+
WGS84_to_Xian80: { dx: 4.2, dy: -72.4, dz: -80.6, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
192
|
+
Beijing54_to_Xian80: { dx: -7.864, dy: 58.336, dz: 10.896, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
193
|
+
Xian80_to_Beijing54: { dx: 7.864, dy: -58.336, dz: -10.896, rx: 0, ry: 0, rz: 0, s: 0 },
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ============================================================
|
|
197
|
+
// Tool: Gauss-Krüger forward projection
|
|
198
|
+
// ============================================================
|
|
199
|
+
|
|
200
|
+
export const gauss_forward = tool({
|
|
201
|
+
description:
|
|
202
|
+
"高斯-克吕格投影正算:将大地经纬度(B, L)转换为平面直角坐标(x, y)。data_analyst 在将GPS采集的经纬度数据转换为工程平面坐标时调用此工具。",
|
|
203
|
+
args: {
|
|
204
|
+
lat: tool.schema.number().describe("纬度(十进制度),如 30.123456"),
|
|
205
|
+
lon: tool.schema.number().describe("经度(十进制度),如 120.654321"),
|
|
206
|
+
centralMeridian: tool.schema
|
|
207
|
+
.number()
|
|
208
|
+
.describe("中央子午线经度(度),3度带常用:120、123等;6度带常用:117、123等"),
|
|
209
|
+
datum: tool.schema.enum(["CGCS2000", "WGS84", "Xian80", "Beijing54"]).default("CGCS2000").describe("坐标系"),
|
|
210
|
+
addFalseEasting: tool.schema.boolean().default(true).describe("是否加500km假东偏移(工程坐标通常为true)"),
|
|
211
|
+
zonePrefix: tool.schema.boolean().default(false).describe("y坐标是否加带号前缀(如3度带第40带则y前缀40)"),
|
|
212
|
+
},
|
|
213
|
+
async execute(args) {
|
|
214
|
+
const { x, y: rawY } = forward(args.lat, args.lon, args.centralMeridian, args.datum)
|
|
215
|
+
const zone = Math.round(args.centralMeridian / 3)
|
|
216
|
+
let y = rawY
|
|
217
|
+
if (args.addFalseEasting) y += 500000
|
|
218
|
+
if (args.zonePrefix) y += zone * 1000000
|
|
219
|
+
|
|
220
|
+
const ep = params(args.datum)
|
|
221
|
+
return JSON.stringify({
|
|
222
|
+
datum: args.datum,
|
|
223
|
+
datum_desc: ep.desc,
|
|
224
|
+
central_meridian: args.centralMeridian,
|
|
225
|
+
zone_3deg: zone,
|
|
226
|
+
input: { lat_deg: args.lat, lon_deg: args.lon },
|
|
227
|
+
output: { x_m: Number(x.toFixed(4)), y_m: Number(y.toFixed(4)) },
|
|
228
|
+
false_easting: args.addFalseEasting,
|
|
229
|
+
zone_prefix: args.zonePrefix,
|
|
230
|
+
message: `✅ 高斯正算完成(${ep.desc}):B=${args.lat}°, L=${args.lon}° → x=${x.toFixed(4)}m, y=${y.toFixed(4)}m`,
|
|
231
|
+
})
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
// ============================================================
|
|
236
|
+
// Tool: Gauss-Krüger inverse projection
|
|
237
|
+
// ============================================================
|
|
238
|
+
|
|
239
|
+
export const gauss_inverse = tool({
|
|
240
|
+
description:
|
|
241
|
+
"高斯-克吕格投影反算:将平面直角坐标(x, y)转换为大地经纬度(B, L)。在需要将工程坐标还原为经纬度(如报告附图、GIS叠加)时调用。",
|
|
242
|
+
args: {
|
|
243
|
+
x: tool.schema.number().describe("北方向坐标(m)"),
|
|
244
|
+
y: tool.schema.number().describe("东方向坐标(m),可含500km假东偏移和带号前缀"),
|
|
245
|
+
centralMeridian: tool.schema.number().describe("中央子午线经度(度)"),
|
|
246
|
+
datum: tool.schema.enum(["CGCS2000", "WGS84", "Xian80", "Beijing54"]).default("CGCS2000").describe("坐标系"),
|
|
247
|
+
hasFalseEasting: tool.schema.boolean().default(true).describe("y坐标是否已含500km假东偏移"),
|
|
248
|
+
hasZonePrefix: tool.schema.boolean().default(false).describe("y坐标是否已含带号前缀"),
|
|
249
|
+
},
|
|
250
|
+
async execute(args) {
|
|
251
|
+
let y = args.y
|
|
252
|
+
if (args.hasZonePrefix) y = y % 1000000
|
|
253
|
+
if (args.hasFalseEasting) y -= 500000
|
|
254
|
+
|
|
255
|
+
const { lat, lon } = inverse(args.x, y, args.centralMeridian, args.datum)
|
|
256
|
+
const ep = params(args.datum)
|
|
257
|
+
|
|
258
|
+
return JSON.stringify({
|
|
259
|
+
datum: args.datum,
|
|
260
|
+
datum_desc: ep.desc,
|
|
261
|
+
central_meridian: args.centralMeridian,
|
|
262
|
+
input: { x_m: args.x, y_m: args.y },
|
|
263
|
+
output: { lat_deg: Number(lat.toFixed(8)), lon_deg: Number(lon.toFixed(8)) },
|
|
264
|
+
message: `✅ 高斯反算完成(${ep.desc}):x=${args.x}m, y=${args.y}m → B=${lat.toFixed(8)}°, L=${lon.toFixed(8)}°`,
|
|
265
|
+
})
|
|
266
|
+
},
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
// ============================================================
|
|
270
|
+
// Tool: Datum transformation (7-parameter Bursa-Wolf)
|
|
271
|
+
// ============================================================
|
|
272
|
+
|
|
273
|
+
export const datum_transform = tool({
|
|
274
|
+
description:
|
|
275
|
+
"坐标系转换(七参数布尔莎模型):在 CGCS2000、WGS84、1980西安坐标系、1954北京坐标系之间转换经纬度。使用内置的全国概略参数,精度约1~2m,满足一般工程复核需求。若需高精度转换(亚毫米级),请提供当地控制点拟合的七参数。",
|
|
276
|
+
args: {
|
|
277
|
+
lat: tool.schema.number().describe("纬度(十进制度)"),
|
|
278
|
+
lon: tool.schema.number().describe("经度(十进制度)"),
|
|
279
|
+
h: tool.schema.number().default(0).describe("大地高(m),默认0"),
|
|
280
|
+
from: tool.schema.enum(["CGCS2000", "WGS84", "Xian80", "Beijing54"]).describe("源坐标系"),
|
|
281
|
+
to: tool.schema.enum(["CGCS2000", "WGS84", "Xian80", "Beijing54"]).describe("目标坐标系"),
|
|
282
|
+
customParams: tool.schema
|
|
283
|
+
.object({
|
|
284
|
+
dx: tool.schema.number().describe("X平移(m)"),
|
|
285
|
+
dy: tool.schema.number().describe("Y平移(m)"),
|
|
286
|
+
dz: tool.schema.number().describe("Z平移(m)"),
|
|
287
|
+
rx: tool.schema.number().describe("X旋转(角秒)"),
|
|
288
|
+
ry: tool.schema.number().describe("Y旋转(角秒)"),
|
|
289
|
+
rz: tool.schema.number().describe("Z旋转(角秒)"),
|
|
290
|
+
s: tool.schema.number().describe("尺度因子(ppm)"),
|
|
291
|
+
})
|
|
292
|
+
.optional()
|
|
293
|
+
.describe("自定义七参数(若提供则覆盖内置参数,用于高精度区域转换)"),
|
|
294
|
+
},
|
|
295
|
+
async execute(args) {
|
|
296
|
+
if (args.from === args.to)
|
|
297
|
+
return JSON.stringify({
|
|
298
|
+
from: args.from,
|
|
299
|
+
to: args.to,
|
|
300
|
+
input: { lat: args.lat, lon: args.lon, h: args.h },
|
|
301
|
+
output: { lat: args.lat, lon: args.lon, h: args.h },
|
|
302
|
+
message: "源坐标系与目标坐标系相同,无需转换。",
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
const key = `${args.from}_to_${args.to}`
|
|
306
|
+
const tp = args.customParams ?? TRANSFORMS[key]
|
|
307
|
+
if (!tp) return JSON.stringify({ error: `不支持 ${args.from} → ${args.to} 的直接转换。` })
|
|
308
|
+
|
|
309
|
+
const src = blh2xyz(args.lat, args.lon, args.h, args.from)
|
|
310
|
+
const dst = bursa(src.X, src.Y, src.Z, tp.dx, tp.dy, tp.dz, tp.rx, tp.ry, tp.rz, tp.s)
|
|
311
|
+
const result = xyz2blh(dst.X, dst.Y, dst.Z, args.to)
|
|
312
|
+
|
|
313
|
+
const fromDesc = ELLIPSOIDS[args.from].desc
|
|
314
|
+
const toDesc = ELLIPSOIDS[args.to].desc
|
|
315
|
+
const isCustom = !!args.customParams
|
|
316
|
+
|
|
317
|
+
return JSON.stringify({
|
|
318
|
+
from: { datum: args.from, desc: fromDesc },
|
|
319
|
+
to: { datum: args.to, desc: toDesc },
|
|
320
|
+
input: { lat_deg: args.lat, lon_deg: args.lon, h_m: args.h },
|
|
321
|
+
output: {
|
|
322
|
+
lat_deg: Number(result.lat.toFixed(8)),
|
|
323
|
+
lon_deg: Number(result.lon.toFixed(8)),
|
|
324
|
+
h_m: Number(result.h.toFixed(3)),
|
|
325
|
+
},
|
|
326
|
+
parameters_used: isCustom ? "用户自定义七参数" : "内置全国概略参数",
|
|
327
|
+
precision_note: isCustom
|
|
328
|
+
? "使用自定义参数,精度取决于参数拟合质量"
|
|
329
|
+
: "内置概略参数精度约1~2m,仅供工程复核。高精度需求请提供当地控制点拟合参数。",
|
|
330
|
+
message: `✅ 坐标系转换完成:${fromDesc} → ${toDesc},B=${result.lat.toFixed(8)}°, L=${result.lon.toFixed(8)}°, H=${result.h.toFixed(3)}m`,
|
|
331
|
+
})
|
|
332
|
+
},
|
|
333
|
+
})
|