{"size": 8532, "ext": "js", "max_stars_repo_path": "public/js/latlon_v1.min.js", "max_stars_repo_name": "t100n/cesium-explorer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/latlon_v1.min.js", "max_issues_repo_name": "t100n/cesium-explorer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/latlon_v1.min.js", "max_forks_repo_name": "t100n/cesium-explorer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 4266.0, "max_line_length": 8531, "alphanum_fraction": 0.7222222222}
function LatLon(lat,lon,rad){if(typeof(rad)=="undefined"){rad=6371}this._lat=typeof(lat)=="number"?lat:typeof(lat)=="string"&&lat.trim()!=""?+lat:NaN;this._lon=typeof(lon)=="number"?lon:typeof(lon)=="string"&&lon.trim()!=""?+lon:NaN;this._radius=typeof(rad)=="number"?rad:typeof(rad)=="string"&&trim(lon)!=""?+rad:NaN}LatLon.prototype.distanceTo=function(point,precision){if(typeof precision=="undefined"){precision=4}var R=this._radius;var lat1=this._lat.toRad(),lon1=this._lon.toRad();var lat2=point._lat.toRad(),lon2=point._lon.toRad();var dLat=lat2-lat1;var dLon=lon2-lon1;var a=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(lat1)*Math.cos(lat2)*Math.sin(dLon/2)*Math.sin(dLon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=R*c;return d.toPrecisionFixed(precision)};LatLon.prototype.bearingTo=function(point){var lat1=this._lat.toRad(),lat2=point._lat.toRad();var dLon=(point._lon-this._lon).toRad();var y=Math.sin(dLon)*Math.cos(lat2);var x=Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);var brng=Math.atan2(y,x);return(brng.toDeg()+360)%360};LatLon.prototype.finalBearingTo=function(point){var lat1=point._lat.toRad(),lat2=this._lat.toRad();var dLon=(this._lon-point._lon).toRad();var y=Math.sin(dLon)*Math.cos(lat2);var x=Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon);var brng=Math.atan2(y,x);return(brng.toDeg()+180)%360};LatLon.prototype.midpointTo=function(point){lat1=this._lat.toRad(),lon1=this._lon.toRad();lat2=point._lat.toRad();var dLon=(point._lon-this._lon).toRad();var Bx=Math.cos(lat2)*Math.cos(dLon);var By=Math.cos(lat2)*Math.sin(dLon);lat3=Math.atan2(Math.sin(lat1)+Math.sin(lat2),Math.sqrt((Math.cos(lat1)+Bx)*(Math.cos(lat1)+Bx)+By*By));lon3=lon1+Math.atan2(By,Math.cos(lat1)+Bx);return new LatLon(lat3.toDeg(),lon3.toDeg())};LatLon.prototype.destinationPoint=function(brng,dist){dist=typeof(dist)=="number"?dist:typeof(dist)=="string"&&dist.trim()!=""?+dist:NaN;dist=dist/this._radius;brng=brng.toRad();var lat1=this._lat.toRad(),lon1=this._lon.toRad();var lat2=Math.asin(Math.sin(lat1)*Math.cos(dist)+Math.cos(lat1)*Math.sin(dist)*Math.cos(brng));var lon2=lon1+Math.atan2(Math.sin(brng)*Math.sin(dist)*Math.cos(lat1),Math.cos(dist)-Math.sin(lat1)*Math.sin(lat2));lon2=(lon2+3*Math.PI)%(2*Math.PI)-Math.PI;return new LatLon(lat2.toDeg(),lon2.toDeg())};LatLon.intersection=function(p1,brng1,p2,brng2){brng1=typeof brng1=="number"?brng1:typeof brng1=="string"&&trim(brng1)!=""?+brng1:NaN;brng2=typeof brng2=="number"?brng2:typeof brng2=="string"&&trim(brng2)!=""?+brng2:NaN;lat1=p1._lat.toRad(),lon1=p1._lon.toRad();lat2=p2._lat.toRad(),lon2=p2._lon.toRad();brng13=brng1.toRad(),brng23=brng2.toRad();dLat=lat2-lat1,dLon=lon2-lon1;dist12=2*Math.asin(Math.sqrt(Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(lat1)*Math.cos(lat2)*Math.sin(dLon/2)*Math.sin(dLon/2)));if(dist12==0){return null}brngA=Math.acos((Math.sin(lat2)-Math.sin(lat1)*Math.cos(dist12))/(Math.sin(dist12)*Math.cos(lat1)));if(isNaN(brngA)){brngA=0}brngB=Math.acos((Math.sin(lat1)-Math.sin(lat2)*Math.cos(dist12))/(Math.sin(dist12)*Math.cos(lat2)));if(Math.sin(lon2-lon1)>0){brng12=brngA;brng21=2*Math.PI-brngB}else{brng12=2*Math.PI-brngA;brng21=brngB}alpha1=(brng13-brng12+Math.PI)%(2*Math.PI)-Math.PI;alpha2=(brng21-brng23+Math.PI)%(2*Math.PI)-Math.PI;if(Math.sin(alpha1)==0&&Math.sin(alpha2)==0){return null}if(Math.sin(alpha1)*Math.sin(alpha2)<0){return null}alpha3=Math.acos(-Math.cos(alpha1)*Math.cos(alpha2)+Math.sin(alpha1)*Math.sin(alpha2)*Math.cos(dist12));dist13=Math.atan2(Math.sin(dist12)*Math.sin(alpha1)*Math.sin(alpha2),Math.cos(alpha2)+Math.cos(alpha1)*Math.cos(alpha3));lat3=Math.asin(Math.sin(lat1)*Math.cos(dist13)+Math.cos(lat1)*Math.sin(dist13)*Math.cos(brng13));dLon13=Math.atan2(Math.sin(brng13)*Math.sin(dist13)*Math.cos(lat1),Math.cos(dist13)-Math.sin(lat1)*Math.sin(lat3));lon3=lon1+dLon13;lon3=(lon3+Math.PI)%(2*Math.PI)-Math.PI;return new LatLon(lat3.toDeg(),lon3.toDeg())};LatLon.prototype.rhumbDistanceTo=function(point){var R=this._radius;var lat1=this._lat.toRad(),lat2=point._lat.toRad();var dLat=(point._lat-this._lat).toRad();var dLon=Math.abs(point._lon-this._lon).toRad();var dPhi=Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));var q=(!isNaN(dLat/dPhi))?dLat/dPhi:Math.cos(lat1);if(dLon>Math.PI){dLon=2*Math.PI-dLon}var dist=Math.sqrt(dLat*dLat+q*q*dLon*dLon)*R;return dist.toPrecisionFixed(4)};LatLon.prototype.rhumbBearingTo=function(point){var lat1=this._lat.toRad(),lat2=point._lat.toRad();var dLon=(point._lon-this._lon).toRad();var dPhi=Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));if(Math.abs(dLon)>Math.PI){dLon=dLon>0?-(2*Math.PI-dLon):(2*Math.PI+dLon)}var brng=Math.atan2(dLon,dPhi);return(brng.toDeg()+360)%360};LatLon.prototype.rhumbDestinationPoint=function(brng,dist){var R=this._radius;var d=parseFloat(dist)/R;var lat1=this._lat.toRad(),lon1=this._lon.toRad();brng=brng.toRad();var lat2=lat1+d*Math.cos(brng);var dLat=lat2-lat1;var dPhi=Math.log(Math.tan(lat2/2+Math.PI/4)/Math.tan(lat1/2+Math.PI/4));var q=(!isNaN(dLat/dPhi))?dLat/dPhi:Math.cos(lat1);var dLon=d*Math.sin(brng)/q;if(Math.abs(lat2)>Math.PI/2){lat2=lat2>0?Math.PI-lat2:-(Math.PI-lat2)}lon2=(lon1+dLon+3*Math.PI)%(2*Math.PI)-Math.PI;return new LatLon(lat2.toDeg(),lon2.toDeg())};LatLon.prototype.lat=function(format,dp){if(typeof format=="undefined"){return this._lat}return Geo.toLat(this._lat,format,dp)};LatLon.prototype.lon=function(format,dp){if(typeof format=="undefined"){return this._lon}return Geo.toLon(this._lon,format,dp)};LatLon.prototype.toString=function(format,dp){if(typeof format=="undefined"){format="dms"}if(isNaN(this._lat)||isNaN(this._lon)){return"-,-"}return Geo.toLat(this._lat,format,dp)+", "+Geo.toLon(this._lon,format,dp)};if(typeof(Number.prototype.toRad)==="undefined"){Number.prototype.toRad=function(){return this*Math.PI/180}}if(typeof(Number.prototype.toDeg)==="undefined"){Number.prototype.toDeg=function(){return this*180/Math.PI}}if(typeof(Number.prototype.toPrecisionFixed)==="undefined"){Number.prototype.toPrecisionFixed=function(precision){if(isNaN(this)){return"NaN"}var numb=this<0?-this:this;var sign=this<0?"-":"";if(numb==0){n="0.";while(precision--){n+="0"}return n}var scale=Math.ceil(Math.log(numb)*Math.LOG10E);var n=String(Math.round(numb*Math.pow(10,precision-scale)));if(scale>0){l=scale-n.length;while(l-->0){n=n+"0"}if(scale<n.length){n=n.slice(0,scale)+"."+n.slice(scale)}}else{while(scale++<0){n="0"+n}n="0."+n}return sign+n}}if(typeof(String.prototype.trim)==="undefined"){String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")}}var Geo={};Geo.parseDMS=function(dmsStr){if(typeof deg=="object"){throw new TypeError("Geo.parseDMS - dmsStr is [DOM?] object")}if(typeof dmsStr==="number"&&isFinite(dmsStr)){return Number(dmsStr)}var dms=String(dmsStr).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(dms[dms.length-1]==""){dms.splice(dms.length-1)}if(dms==""){return NaN}switch(dms.length){case 3:var deg=dms[0]/1+dms[1]/60+dms[2]/3600;break;case 2:var deg=dms[0]/1+dms[1]/60;break;case 1:var deg=dms[0];if(/[NS]/i.test(dmsStr)){deg="0"+deg}if(/[0-9]{7}/.test(deg)){deg=deg.slice(0,3)/1+deg.slice(3,5)/60+deg.slice(5)/3600}break;default:return NaN}if(/^-|[WS]$/i.test(dmsStr.trim())){deg=-deg}return Number(deg)};Geo.toDMS=function(deg,format,dp){if(typeof deg=="object"){throw new TypeError("Geo.toDMS - deg is [DOM?] object")}if(isNaN(deg)){return"NaN"}if(typeof format=="undefined"){format="dms"}if(typeof dp=="undefined"){switch(format){case"d":dp=4;break;case"dm":dp=2;break;case"dms":dp=0;break;default:format="dms";dp=0}}deg=Math.abs(deg);switch(format){case"d":d=deg.toFixed(dp);if(d<100){d="0"+d}if(d<10){d="0"+d}dms=d+"\u00B0";break;case"dm":var min=(deg*60).toFixed(dp);var d=Math.floor(min/60);var m=(min%60).toFixed(dp);if(d<100){d="0"+d}if(d<10){d="0"+d}if(m<10){m="0"+m}dms=d+"\u00B0"+m+"\u2032";break;case"dms":var sec=(deg*3600).toFixed(dp);var d=Math.floor(sec/3600);var m=Math.floor(sec/60)%60;var s=(sec%60).toFixed(dp);if(d<100){d="0"+d}if(d<10){d="0"+d}if(m<10){m="0"+m}if(s<10){s="0"+s}dms=d+"\u00B0"+m+"\u2032"+s+"\u2033";break}return dms};Geo.toLat=function(deg,format,dp){var lat=Geo.toDMS(deg,format,dp);return lat==""?"":lat.slice(1)+(deg<0?"S":"N")};Geo.toLon=function(deg,format,dp){var lon=Geo.toDMS(deg,format,dp);return lon==""?"":lon+(deg<0?"W":"E")};Geo.toBrng=function(deg,format,dp){deg=(Number(deg)+360)%360;var brng=Geo.toDMS(deg,format,dp);return brng.replace("360","0")};
