diff --git a/sdrbase/feature/featurewebapiutils.cpp b/sdrbase/feature/featurewebapiutils.cpp index 43381ba55..9ea3ac870 100644 --- a/sdrbase/feature/featurewebapiutils.cpp +++ b/sdrbase/feature/featurewebapiutils.cpp @@ -86,6 +86,36 @@ bool FeatureWebAPIUtils::mapSetDateTime(const QDateTime& dateTime, int featureSe } } +// Find the specified target on the sky map +bool FeatureWebAPIUtils::skyMapFind(const QString& target, int featureSetIndex, int featureIndex) +{ + Feature *feature = FeatureWebAPIUtils::getFeature(featureSetIndex, featureIndex, "sdrangel.feature.skymap"); + if (feature != nullptr) + { + QString errorMessage; + QStringList featureActionKeys = {"find"}; + SWGSDRangel::SWGFeatureActions query; + SWGSDRangel::SWGSkyMapActions *skyMapActions = new SWGSDRangel::SWGSkyMapActions(); + + skyMapActions->setFind(new QString(target)); + query.setSkyMapActions(skyMapActions); + + int httpRC = feature->webapiActionsPost(featureActionKeys, query, errorMessage); + if (httpRC/100 != 2) + { + qWarning() << "FeatureWebAPIUtils::skyMapFind: error " << httpRC << ":" << errorMessage; + return false; + } + + return true; + } + else + { + qWarning("FeatureWebAPIUtils::skyMapFind: no Sky Map feature"); + return false; + } +} + // Get first feature with the given URI Feature* FeatureWebAPIUtils::getFeature(int& featureSetIndex, int& featureIndex, const QString& uri) { diff --git a/sdrbase/feature/featurewebapiutils.h b/sdrbase/feature/featurewebapiutils.h index 93296fa59..df6e78c68 100644 --- a/sdrbase/feature/featurewebapiutils.h +++ b/sdrbase/feature/featurewebapiutils.h @@ -32,6 +32,7 @@ class SDRBASE_API FeatureWebAPIUtils public: static bool mapFind(const QString& target, int featureSetIndex=-1, int featureIndex=-1); static bool mapSetDateTime(const QDateTime& dateTime, int featureSetIndex=-1, int featureIndex=-1); + static bool skyMapFind(const QString& target, int featureSetIndex=-1, int featureIndex=-1); static Feature *getFeature(int& featureSetIndex, int& featureIndex, const QString& uri); static bool satelliteAOS(const QString name, const QDateTime aos, const QDateTime los); static bool satelliteLOS(const QString name);