From 59e8f60d4da988754b468975b58d8481908eb785 Mon Sep 17 00:00:00 2001 From: Artyom Beilis Date: Thu, 20 Apr 2023 19:12:25 +0300 Subject: [PATCH] Split HTML/CSS/JS Added calculated direction of plate-sovling correction in units --- include/plate_solver.h | 2 + include/plate_solver_ctl_app.h | 46 ++ src/plate_solver.cpp | 2 + www-data/index.html | 879 +-------------------------------- www-data/media/css/style.css | 75 +++ www-data/media/js/code.js | 851 +++++++++++++++++++++++++++++++ 6 files changed, 984 insertions(+), 871 deletions(-) create mode 100644 www-data/media/css/style.css create mode 100644 www-data/media/js/code.js diff --git a/include/plate_solver.h b/include/plate_solver.h index 741ff17..4313fde 100644 --- a/include/plate_solver.h +++ b/include/plate_solver.h @@ -10,6 +10,8 @@ namespace ols { class PlateSolver { public: struct Result { + double center_ra_deg; + double center_de_deg; int center_row; int center_col; int target_row; diff --git a/include/plate_solver_ctl_app.h b/include/plate_solver_ctl_app.h index 1d71db9..be85bc7 100644 --- a/include/plate_solver_ctl_app.h +++ b/include/plate_solver_ctl_app.h @@ -8,8 +8,10 @@ #include #include +#include "rotation.h" #include "server_sent_events.h" #include "util.h" + namespace ols { class PlateSolverControlApp : public ControlAppBase { public: @@ -20,12 +22,45 @@ namespace ols { { dispatcher().map("POST","/?",&PlateSolverControlApp::solve,this); } + struct DeltaAZ { + double delta_alt; + double delta_az; + }; + + DeltaAZ calc_delta_alt_az(double t_ra,double t_de,double c_ra,double c_de,double lat,double lon) + { + Derotator derot(lon,lat,c_ra,c_de); + double time_now = time(nullptr); + auto src = derot.rayFromPos(c_ra,c_de,time_now); + double src_E = src.x; + double src_N = src.y; + double src_U = src.z; + auto tgt = derot.rayFromPos(t_ra,t_de,time_now); + double tgt_E = tgt.x; + double tgt_N = tgt.y; + double tgt_U = tgt.z; + + double d_alt = (std::asin(tgt_U) - std::asin(src_U)) * 180 / M_PI; + double d_az = (std::atan2(tgt_E,tgt_N) - std::atan2(src_E,src_N)) * 180 / M_PI; + if(d_az > 180) + d_az -= 360; + if(d_az < -180) + d_az += 360; + DeltaAZ res; + res.delta_alt = d_alt; + res.delta_az = d_az; + return res; + } + void solve() { double fov = content_.get("fov"); double ra = content_.get("ra"); double de = content_.get("de"); double rad = content_.get("rad"); + double constexpr invalid_geolocation = 1e6; + double lat = content_.get("lat",invalid_geolocation); + double lon = content_.get("lon",invalid_geolocation); std::string img = "/plate_solving_solution.jpeg"; std::string jpeg = data_dir_ + img; try { @@ -33,6 +68,17 @@ namespace ols { response_["solved"]=true; response_["distance_to_target"] = res.angle_to_target_deg; response_["result_image"] = "/data" + img; + response_["delta_ra"] = ra - res.center_ra_deg; + response_["delta_de"] = de - res.center_de_deg; + if(lat != invalid_geolocation && lon != invalid_geolocation) { + auto delta = calc_delta_alt_az(ra,de,res.center_ra_deg, res.center_de_deg,lat,lon); + response_["delta_alt"] = delta.delta_alt; + response_["delta_az"] = delta.delta_az; + } + else { + response_["delta_alt"] = cppcms::json::null(); + response_["delta_az"] = cppcms::json::null(); + } } catch(std::exception const &e) { response_["solved"]=false; diff --git a/src/plate_solver.cpp b/src/plate_solver.cpp index 194505c..1dc2bc6 100644 --- a/src/plate_solver.cpp +++ b/src/plate_solver.cpp @@ -99,6 +99,8 @@ namespace ols { r.target_col = xt; r.target_row = rows - yt; r.angle_to_target_deg = diff_deg; + r.center_ra_deg = ra0; + r.center_de_deg = de0; return r; } double PlateSolver::get(std::map const &vals,std::string const &name) diff --git a/www-data/index.html b/www-data/index.html index a2eddf7..1919582 100644 --- a/www-data/index.html +++ b/www-data/index.html @@ -4,878 +4,10 @@ + OpenLiveStacker - - -