From 4266dc735d0824cfa7589ec712869d192624167c Mon Sep 17 00:00:00 2001 From: Nacho C <106687713+nacho-skydweller@users.noreply.github.com> Date: Mon, 13 Mar 2023 17:18:41 -0400 Subject: [PATCH 1/2] Use earth radius from constants for default value in compute destination point --- src/computeDestinationPoint.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/computeDestinationPoint.ts b/src/computeDestinationPoint.ts index 09b3ae0..72ff811 100644 --- a/src/computeDestinationPoint.ts +++ b/src/computeDestinationPoint.ts @@ -2,7 +2,7 @@ import getLatitude from './getLatitude'; import getLongitude from './getLongitude'; import toRad from './toRad'; import toDeg from './toDeg'; -import { MAXLON, MINLON } from './constants'; +import { MAXLON, MINLON, earthRadius } from './constants'; import { GeolibInputCoordinates } from './types'; // Computes the destination point given an initial point, a distance and a bearing @@ -11,7 +11,7 @@ const computeDestinationPoint = ( start: GeolibInputCoordinates, distance: number, bearing: number, - radius: number = 6371000 + radius: number = earthRadius ) => { const lat = getLatitude(start); const lng = getLongitude(start); From 3eb71d91822b33d0113961534a9ce8caedbf7721 Mon Sep 17 00:00:00 2001 From: Nacho Carnicero Date: Tue, 14 Mar 2023 09:02:17 -0400 Subject: [PATCH 2/2] Update computeDestinationPoint tests --- src/computeDestinationPoint.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/computeDestinationPoint.test.js b/src/computeDestinationPoint.test.js index 4f7bebe..bcbf994 100644 --- a/src/computeDestinationPoint.test.js +++ b/src/computeDestinationPoint.test.js @@ -9,7 +9,7 @@ describe('computeDestinationPoint', () => { 180 ) ).toEqual({ - latitude: 52.383712759112186, + latitude: 52.38386370738208, longitude: 13.408056, }); @@ -20,8 +20,8 @@ describe('computeDestinationPoint', () => { 135 ) ).toEqual({ - latitude: 52.42312025947117, - longitude: 13.56447370636139, + latitude: 52.42322722672353, + longitude: 13.564299057246112, }); }); @@ -33,7 +33,7 @@ describe('computeDestinationPoint', () => { 0 ) ).toEqual({ - latitude: 71.83167384063478, + latitude: 72.3348347402393, longitude: -106.19528790000001, }); }); @@ -46,7 +46,7 @@ describe('computeDestinationPoint', () => { 0 ) ).toEqual({ - latitude: 18.512019808029596, + latitude: 18.5120147764206, longitude: 73.8047121, }); @@ -57,7 +57,7 @@ describe('computeDestinationPoint', () => { 180 ) ).toEqual({ - latitude: 18.50302659197041, + latitude: 18.50303162357941, longitude: 73.8047121, }); });