<commit_before>var geo = function() {
	this.deg2rad = Math.PI / 180;
	this.rad2deg = 180 / Math.PI;
	this.earthRad = 6371;
	this.earthDia = this.earthRad * 2;
}

var proto = geo.prototype;

proto.constructor = geo;


proto.distance = function(geo1, geo2) {
	var latCenterRad=geo1.latitude,
		lonCenterRad=geo1.longitude,
		latVals=geo2.latitude,
		lonVals=geo2.longitude;

	//计算经纬度
	  var latRad = latVals * this.deg2rad;
      var lonRad = lonVals * this.deg2rad;

      //计算经纬度的差
      var diffX = latCenterRad * this.deg2rad - latRad;
      var diffY = lonCenterRad * this.deg2rad - lonRad;
      //计算正弦和余弦
      var hsinX = Math.sin(diffX * 0.5);
      var hsinY = Math.sin(diffY * 0.5);
      var latCenterRad_cos = Math.cos(latCenterRad * this.deg2rad);
      var h = hsinX * hsinX+ (latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);

      return (this.earthDia * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h)));
}<commit_msg>geolocation<commit_after>var geo = function() {
		this.deg2rad = Math.PI / 180;
		this.rad2deg = 180 / Math.PI;
		this.earthRad = 6371;
		this.earthDia = this.earthRad * 2;
	}

	var proto = geo.prototype;

	proto.constructor = geo;


	proto.distance = function(geo1, geo2) {
		var latCenterRad = geo1.latitude,
			lonCenterRad = geo1.longitude,
			latVals = geo2.latitude,
			lonVals = geo2.longitude;

		//计算经纬度
		var latRad = latVals * this.deg2rad;
		var lonRad = lonVals * this.deg2rad;

		//计算经纬度的差
		var diffX = latCenterRad * this.deg2rad - latRad;
		var diffY = lonCenterRad * this.deg2rad - lonRad;
		//计算正弦和余弦
		var hsinX = Math.sin(diffX * 0.5);
		var hsinY = Math.sin(diffY * 0.5);
		var latCenterRad_cos = Math.cos(latCenterRad * this.deg2rad);
		var h = hsinX * hsinX + (latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);

		var distance=this.earthDia * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));

		if(distance>1){
			var _km=distance-distance%1000;
			return _km.toString()+'km';
		}
		else{
			var _m=parseInt(distance*1000);
			return _m.toString()+'m';
		}

	}

	proto.value = function(geo1, geo2) {
		var latCenterRad = geo1.latitude,
			lonCenterRad = geo1.longitude,
			latVals = geo2.latitude,
			lonVals = geo2.longitude;

		//计算经纬度
		var latRad = latVals * this.deg2rad;
		var lonRad = lonVals * this.deg2rad;

		//计算经纬度的差
		var diffX = latCenterRad * this.deg2rad - latRad;
		var diffY = lonCenterRad * this.deg2rad - lonRad;
		//计算正弦和余弦
		var hsinX = Math.sin(diffX * 0.5);
		var hsinY = Math.sin(diffY * 0.5);
		var latCenterRad_cos = Math.cos(latCenterRad * this.deg2rad);
		var h = hsinX * hsinX + (latCenterRad_cos * Math.cos(latRad) * hsinY * hsinY);

		return this.earthDia * Math.atan2(Math.sqrt(h), Math.sqrt(1 - h));

	}

	proto.getLocation = function(callback) {
		if (navigator.geolocation) {
			navigator.geolocation.getCurrentPosition(function(position) {
				window.latitude=position.coords.latitude;
				window.longitude=position.coords.longitude;
				if (callback && (callback instanceof Function)) {
							callback();
				}
			});
		} else {
			console.log("Geolocation is not supported by this browser.");
		}
	}
{'fraction_non_alphanumeric': 0.13473344103392568, 'fraction_numerical': 0.02778675282714055, 'mean_word_length': 3.241095890410959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5332217', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1255, 'n_words': 239}