Advanced Math Module

The Advanced Math module provides distance calculation helper methods.

Distance calculation methods

Advanced Math provides a method that will display the distance, in miles, between two lat/long coordinates.

Usage: getDistance(lat1, lon1, lat2, lon2), where:

  • lat1: latitude of first point
  • lon1: longitude of first point
  • lat2: latitude of second point
  • lng2: longitude of second point
const advancedMath = require('advanced_math');
const distanceInMiles = advancedMath.getDistance(43.7001100, -79.4163000, 37.7749300, -122.4194200);

Degrees to Radians

Advanced Math provides a method that will convert from degrees to radians.

Usage: deg2rad(deg), where:

  • deg: input of degrees
const advancedMath = require('advanced_math');
const radians = advancedMath.deg2rad(30);
Functions support

PubNub Functions provides a rich set of tools, and this documentation does not cover all of the potential situations you may encounter. If you need help with a situation not covered by the documentation, please contact PubNub Support

Last updated on