*** in development ***
Collection of geographical and navigation related helper functions.
Functions include:
- GPS conversion utilities
- Robust parsing tool to convert human readable GPS data and deeply nested or XML GPX data to decimal format
- Various distance calculations: Between 2 points, Time and Heading...
- Various position calculations: Intersection from two routes, Bearing and Distance...
- Handles normalizing bearings: Avg of bearings, Median Bearing, Bearing Difference...
- Number utility helpers: toRad, toDeg, toBrng...
...more
ToDo:
- show usage in parsing array of DMS gps
- show how cleans data
- usage in form
- each distance function parses inteval type and returns in that type i.e. Nm or M or Km
npm install geo
--- or ---
include in browser
<script src="../dist/geo.js"></script>
Insert link here to git pages
All functions are well documented in code and inputs and outputs for each function are straightforward. Most functions also have error trapping to check for out of range bad values and will return an error message.
Return average of all bearing values in array normalized for compass bearings.
Calculate bearing from position 1 to position 2 in degrees. Latitude and Longitude must be in Decimal format. i.e. 51.13342.
If using DMS format i.e. 35° 24' 32.22" then run through conversion function to get Decimal format. see parseDMS below
Calculate normalized difference between two bearings by finding the smaller of the two angles of a circle described by the two bearings
Adds and normalizes two bearings. Inputs and outputs in degrees
Finds recirocal heading by inverting and normalizing heading. If heading is 270 returns 90, if 360 return 180 etc.
Calculates difference in two bearings and returns median bearing between those two bearings Effectively finds the smaller of the two angles of a circle and returns the median angle
Calculate distance between two points in km. This method generates more accurate distance for points close together - less than a couple km max.
Calculate distance between two points in km. This method generates more accurate distance for points farther apart and incorporates the curve of the earth as part of the equation.
Calculate distance from speed (in kM/hour) and Time (seconds)
Returns (signed) distance in Km from a given Lat/Lon point to the nearest point on a route that is defined by start-point and end-point. Gives option to use Haversisne calculation whcih will work with longer routes and takes into account Great Circle calcs - or Cosine distance which works better for very short distances less than a couple Km.
Calculate a lat/lon position in decimal format point from;
- Existing lat/lon point in decimal format
- Bearing from initial point in degrees
- Distance travelled from intial point in KM
Calculate intersection point between two lines/routes in lat and lon. The routes are not required to overlap to for the calculation to work.