<commit_before>var rp = require("request-promise");

Number.prototype.toRad = function() {
  return this * Math.PI / 180;
}

Number.prototype.toDeg = function() {
  return this * 180 / Math.PI;
}

// Returns a new lat/lng pair at a specific bearing and distance (radius) from a starting point
function createPointOnRadius(startPoint, bearing, dist) {
  dist = dist / 6371;
  bearing = bearing.toRad();
  const lat1 = startPoint.lat.toRad();
  const lng1 = startPoint.lng.toRad();
  const lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(bearing));
  const lng2 = lng1 + Math.atan2(
                      Math.sin(bearing) * Math.sin(dist) * Math.cos(lat1),
                      Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2)
                    );

  if (isNaN(lat2) || isNaN(lng2)) return null;
  const newLat = lat2.toDeg()
  const newLng = lng2.toDeg()
  return {lat: newLat, lng: newLng};
}

// Accepts a lat/lng pair and checks for closest valid point on land
function reverseGeoCode(geoPoint) {
  const baseUrl = 'https://maps.googleapis.com/maps/api/geocode/json';
  const googlekey = process.env.GOOGLE_KEY;
  const lat = geoPoint.lat;
  const lng = geoPoint.lng;

  var options = {
    uri: `${baseUrl}?latlng=${lat},${lng}&key=${googlekey}`,
    headers: {
      'User-Agent': 'Request-Promise'
    },
    json: true
  }
  return rp(options).then((resp) => {
    return resp.results[0].geometry.location;
  })
}

// Accepts a starting lat/lng and generates valid lat/lng coordinates at each bearing
function createGeoRadius(coords) {
  const startPoint = coords.start;
  const radius = .5;  // 1km

  // Creates promiseList array and instantiates with the validated start point
  const promiseList = [reverseGeoCode(createPointOnRadius(startPoint, 0, 0))];
  // const bearings = [0, 45, 90, 135, 180, 225, 270, 315];
  const bearings = [0, 90, 180, 270];
  bearings.forEach((bearing) => {<commit_msg>tweaked radius search<commit_after>var rp = require("request-promise");

Number.prototype.toRad = function() {
  return this * Math.PI / 180;
}

Number.prototype.toDeg = function() {
  return this * 180 / Math.PI;
}

// Returns a new lat/lng pair at a specific bearing and distance (radius) from a starting point
function createPointOnRadius(startPoint, bearing, dist) {
  dist = dist / 6371;
  bearing = bearing.toRad();
  const lat1 = startPoint.lat.toRad();
  const lng1 = startPoint.lng.toRad();
  const lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(bearing));
  const lng2 = lng1 + Math.atan2(
                      Math.sin(bearing) * Math.sin(dist) * Math.cos(lat1),
                      Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2)
                    );

  if (isNaN(lat2) || isNaN(lng2)) return null;
  const newLat = lat2.toDeg()
  const newLng = lng2.toDeg()
  return {lat: newLat, lng: newLng};
}

// Accepts a lat/lng pair and checks for closest valid point on land
function reverseGeoCode(geoPoint) {
  const baseUrl = 'https://maps.googleapis.com/maps/api/geocode/json';
  const googlekey = process.env.GOOGLE_KEY;
  const lat = geoPoint.lat;
  const lng = geoPoint.lng;

  var options = {
    uri: `${baseUrl}?latlng=${lat},${lng}&key=${googlekey}`,
    headers: {
      'User-Agent': 'Request-Promise'
    },
    json: true
  }
  return rp(options).then((resp) => {
    return resp.results[0].geometry.location;
  })
}

// Accepts a starting lat/lng and generates valid lat/lng coordinates at each bearing
function createGeoRadius(coords) {
  const startPoint = coords.start;
  const radius = .25;  // 1km

  // Creates promiseList array and instantiates with the validated start point
  const promiseList = [reverseGeoCode(createPointOnRadius(startPoint, 0, 0))];
  // const bearings = [0, 45, 90, 135, 180, 225, 270, 315];
  const bearings = [0, 90, 180, 270];
  bearings.forEach((bearing) => {
{'fraction_non_alphanumeric': 0.14063694267515925, 'fraction_numerical': 0.030318471337579617, 'mean_word_length': 3.328555678059537, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '4521537', 'n_tokens_mistral': 1446, 'n_tokens_neox': 1326, 'n_words': 344}