# Distance between repeatable points

Since Fulcrum calculations are written in JavaScript, we can incorporate 3rd party scripts to provide helper functions. One excellent open source library for working with basic geospatial operations in JavaScript is Geolib. The example below demonstrates how to incorporate the Geolib library into a calculation field and use the `getPathLength` function to calculate the total distance between repeatable points.

``````/*! geolib 2.0.21 by Manuel Bieh
* Library to provide geo functions like distance calculation,
* conversion of decimal coordinates to sexagesimal and vice versa, etc.
* WGS 84 (World Geodetic System 1984)
*
* @author Manuel Bieh
* @url http://www.manuelbieh.com/
* @version 2.0.21
**/
// end of Geolib code

// set geolib library as a variable
var geolib = module.exports;

// empty array to hold coordinate objects
var pathCoordinates = [];

// if there is more than 1 item in the repeatable field named "sites", loop through the repeatable objects and push the coordinates into the pathCoordinates array
if (\$sites && \$sites.length > 1) {
for (var i = 0; i < \$sites.length; ++i) {
pathCoordinates.push({
latitude: \$sites[i].geometry.coordinates[1],
longitude: \$sites[i].geometry.coordinates[0]
});
}

// get the distance between points in meters
var distance = geolib.getPathLength(pathCoordinates);

// set the result of the calc field with a label
SETRESULT(distance + " meters");
} else {
SETRESULT(null);
}
``````

Copy and paste the entire code block above into the expression section of your calculation field, making sure to replace `\$sites` with the data name of your repeatable field.