-
Notifications
You must be signed in to change notification settings - Fork 0
/
nearest.min.js
1 lines (1 loc) · 1.08 KB
/
nearest.min.js
1
(function e(t,n,r){function i(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(s)return s(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var s=typeof require=="function"&&require;for(var o=0;o<r.length;o++)i(r[o]);return i})({1:[function(e,t,n){var r=function(){return this.distanceInKm=function(e,t,n,r){var i=function(e){return e*(Math.PI/180)},s=6371,o=i(n-e),u=i(r-t),a=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i(e))*Math.cos(i(n))*Math.sin(u/2)*Math.sin(u/2),f=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a)),l=s*f;return l},this.find=function(e,t){var t=t||{},n=t.within||10,r=t.limit||50,i=t.coords[0],s=t.coords[1],o=this;return e.map(function(e,t){return{distance:parseFloat(o.distanceInKm(i,s,e.lat,e.lon).toFixed(2)),i:t}}).sort(function(e,t){return e.distance-t.distance}).filter(function(e){return e.distance<n}).map(function(t){return e[t.i].distance=t.distance,e[t.i]}).slice(0,r)},this};t.exports=r},{}]},{},[1]);