diff --git a/sdrsrv/webapi/webapiadaptersrv.cpp b/sdrsrv/webapi/webapiadaptersrv.cpp index 612f8241a..26d48caf4 100644 --- a/sdrsrv/webapi/webapiadaptersrv.cpp +++ b/sdrsrv/webapi/webapiadaptersrv.cpp @@ -27,6 +27,7 @@ #include "SWGLoggingInfo.h" #include "SWGAudioDevices.h" #include "SWGAudioDevicesSelect.h" +#include "SWGLocationInformation.h" #include "SWGErrorResponse.h" #include "maincore.h" @@ -261,6 +262,35 @@ int WebAPIAdapterSrv::instanceAudioPatch( return 200; } +int WebAPIAdapterSrv::instanceLocationGet( + SWGSDRangel::SWGLocationInformation& response, + SWGSDRangel::SWGErrorResponse& error __attribute__((unused))) +{ + response.setLatitude(m_mainCore.m_settings.getLatitude()); + response.setLongitude(m_mainCore.m_settings.getLongitude()); + + return 200; +} + +int WebAPIAdapterSrv::instanceLocationPut( + SWGSDRangel::SWGLocationInformation& response, + SWGSDRangel::SWGErrorResponse& error __attribute__((unused))) +{ + float latitude = response.getLatitude(); + float longitude = response.getLongitude(); + + latitude = latitude < -90.0 ? -90.0 : latitude > 90.0 ? 90.0 : latitude; + longitude = longitude < -180.0 ? -180.0 : longitude > 180.0 ? 180.0 : longitude; + + m_mainCore.m_settings.setLatitude(latitude); + m_mainCore.m_settings.setLongitude(longitude); + + response.setLatitude(m_mainCore.m_settings.getLatitude()); + response.setLongitude(m_mainCore.m_settings.getLongitude()); + + return 200; +} + void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList) { deviceSetList->init(); diff --git a/sdrsrv/webapi/webapiadaptersrv.h b/sdrsrv/webapi/webapiadaptersrv.h index aa7b94a5b..c0a931dfa 100644 --- a/sdrsrv/webapi/webapiadaptersrv.h +++ b/sdrsrv/webapi/webapiadaptersrv.h @@ -66,6 +66,14 @@ public: SWGSDRangel::SWGAudioDevicesSelect& response, SWGSDRangel::SWGErrorResponse& error); + virtual int instanceLocationGet( + SWGSDRangel::SWGLocationInformation& response, + SWGSDRangel::SWGErrorResponse& error); + + virtual int instanceLocationPut( + SWGSDRangel::SWGLocationInformation& response, + SWGSDRangel::SWGErrorResponse& error); + private: MainCore& m_mainCore;