mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 14:11:02 +01:00
Merge branch 'mattnotmax-haversine'
This commit is contained in:
commit
46929e1844
@ -41,8 +41,8 @@ class HaversineDistance extends Operation {
|
|||||||
|
|
||||||
const lat1 = parseFloat(values[1]);
|
const lat1 = parseFloat(values[1]);
|
||||||
const lng1 = parseFloat(values[3]);
|
const lng1 = parseFloat(values[3]);
|
||||||
const lat2 = parseFloat(values[6]);
|
const lat2 = parseFloat(values[5]);
|
||||||
const lng2 = parseFloat(values[8]);
|
const lng2 = parseFloat(values[7]);
|
||||||
|
|
||||||
const TO_RAD = Math.PI / 180;
|
const TO_RAD = Math.PI / 180;
|
||||||
const dLat = (lat2-lat1) * TO_RAD;
|
const dLat = (lat2-lat1) * TO_RAD;
|
||||||
|
@ -11,7 +11,18 @@ TestRegister.addTests([
|
|||||||
{
|
{
|
||||||
name: "Haversine distance",
|
name: "Haversine distance",
|
||||||
input: "51.487263,-0.124323, 38.9517,-77.1467",
|
input: "51.487263,-0.124323, 38.9517,-77.1467",
|
||||||
expectedOutput: "5619355.701829259",
|
expectedOutput: "5902542.836307819",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
"op": "Haversine distance",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Haversine distance, zero distance",
|
||||||
|
input: "51.487263,-0.124323, 51.487263,-0.124323",
|
||||||
|
expectedOutput: "0",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "Haversine distance",
|
"op": "Haversine distance",
|
||||||
|
Loading…
Reference in New Issue
Block a user