参考QT源码 distanceTo函数:
https://code.qt.io/cgit/qt/qtpositioning.git/tree/src/positioning/qgeocoordinate.cpp
https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qmath.h
参考公式:
https://blog.csdn.net/gaocuisheng/article/details/126060795
实现:
double getDistanceByLongitudeAndLatitude(){//计算两个经纬度距离static const double qgeocoordinate_EARTH_MEAN_RADIUS = 6371.0072;// Haversine formula//传入的源经纬度double lat_source=22.8910392648613;double lat_target=22.89363385078864;//传入的目标经纬度double lng_source=113.395039373115;double lng_target=113.3974394623876;//传入的目标与源经纬度差值double lat = lat_target - lat_source;double lng = lng_target - lng_source;//差值浮点数转弧度double dlat = lat * float(