distance-between

wayland/gps/distance-between

Calculates distance in metres between two positions, both specified as signed decimal-degrees latitude and longitude. Uses great-circle distance computation for hypothetical sphere of radius 6372795 meters. Because Earth is no exact sphere, rounding errors may be up to 0.5%.
distance-between
@/distance-between
Calculates distance in metres between two positions, both specified as signed decimal-degrees latitude and longitude. Uses great-circle distance computation for hypothetical sphere of radius 6372795 meters. Because Earth is no exact sphere, rounding errors may be up to 0.5%.
Lat1number
Latititude (decimal degrees) of position one.
Long1number
Longitude (decimal degrees) of position one.
Lat2number
Latititude (decimal degrees) of position two.
Long2number
Longitude (decimal degrees) of position two.
distance-between
Lat1
Long1
Lat2
Long2
Dist
Distnumber
Distance in metres.
To use the node in your project you should have the wayland/gps library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD dirtieness disable
#pragma XOD require "https://github.com/mikalhart/TinyGPSPlus"
#include <TinyGPSPlus.h>

node {
    void evaluate(Context ctx) {
        double lat1 = getValue<input_Lat1>(ctx);
        double long1 = getValue<input_Long1>(ctx);
        double lat2 = getValue<input_Lat2>(ctx);
        double long2 = getValue<input_Long2>(ctx);
        //distanceBetween is a static method, so we don't need an instance of the class TinyGPSPlus
        emitValue<output_Dist>(ctx, TinyGPSPlus::distanceBetween(lat1, long1, lat2, long2));
    }
}