Created
June 30, 2022 10:22
-
-
Save almeida1492/1ea2780155bebc47659aafcd3f22450b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ICoordinates } from "../types"; | |
export const getIsWithinRange = ( | |
claimantCoordinates: ICoordinates, | |
reportCoordinates: ICoordinates | |
): boolean => { | |
const rangeRadius = 0.0008695277120173415; | |
const deltaLat = reportCoordinates.lat - claimantCoordinates.lat; | |
const deltaLng = reportCoordinates.lng - claimantCoordinates.lng; | |
const squareLegLat = Math.pow(deltaLat, 2); | |
const squareLegLng = Math.pow(deltaLng, 2); | |
const hypotenuse = Math.sqrt(squareLegLat + squareLegLng); | |
return hypotenuse <= rangeRadius; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment