<commit_before># TODO: Update API To NOT USE GOOGLE and use Open Source

class Refuge.Library.Geocoder
  statusOK: google.maps.GeocoderStatus.OK

  constructor: ->
    @_googleGeocoder = new google.maps.Geocoder()

  geocodeSearchString: (address) ->
    # This function takes in a string and geocodes it, returning two coordinates.
    # It will resolve a promise with an object that contains the
    # latitude and longtitude.

    requestBody = { 'address': address }
    promise = $.Deferred()

    success: (results, status) =>
      if (status == @statusOK)
        coords =
          lat: results[0].geometry.location.lat(),
          long: results[0].geometry.location.lng()
        promise.resolve(coords)
      else
        promise.reject(status)
    fail: (err) ->
      promise.rejext(err)

    @_googleGeocoder.geocode(requestBody, success, fail)

    return promise.promise()


  getCurrentLocation: ->
    # This function returns a promise that evaluates to an object with the
    # latitute and longitute of the current coordinates.

    support = navigator.geolocation? && navigator.geolocation
    options =
      enableHighAccuracy: true
      timeout: 5000
    promise = $.Deferred()

    # Callback functions
    success = (pos) ->
      result =
        lat: pos.coords.latitude
        long: pos.coords.longitude
      promise.resolve(result)
    error = (err) ->
      promise.reject(err)

    if support
      navigator.geolocation.getCurrentPosition( success, error, options )
    else
      # Geolocation not supported
      promise.reject("Not Supported")<commit_msg>geocoder lib working correctly now<commit_after># TODO: Update API To NOT USE GOOGLE and use Open Source

class Refuge.Library.Geocoder
  statusOK: google.maps.GeocoderStatus.OK

  geocodeSearchString: (address) =>
    _googleGeocoder = new google.maps.Geocoder()
    statusOK = google.maps.GeocoderStatus.OK

    # This function takes in a string and geocodes it, returning two coordinates.
    # It will resolve a promise with an object that contains the
    # latitude and longtitude.

    requestBody = { 'address': address }
    promise = $.Deferred()

    success = (results, status) =>
      if (status == statusOK)
        coords =
          lat: results[0].geometry.location.lat(),
          long: results[0].geometry.location.lng()
        promise.resolve(coords)
      else
        promise.reject(status)
    fail = (err) ->
      promise.rejext(err)

    _googleGeocoder.geocode(requestBody, success, fail)

    return promise.promise()


  getCurrentLocation: ->
    # This function returns a promise that evaluates to an object with the
    # latitute and longitute of the current coordinates.

    support = navigator.geolocation? && navigator.geolocation
    options =
      enableHighAccuracy: true
      timeout: 5000
    promise = $.Deferred()

    # Callback functions
    success = (pos) ->
      result =
        lat: pos.coords.latitude
        long: pos.coords.longitude
      promise.resolve(result)
    error = (err) ->
      promise.reject(err)

    if support
      navigator.geolocation.getCurrentPosition( success, error, options )
    else
      # Geolocation not supported
      promise.reject("Not Supported")
{'fraction_non_alphanumeric': 0.09206054989187519, 'fraction_numerical': 0.0037071362372567192, 'mean_word_length': 2.769499417927823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '1548921', 'n_tokens_mistral': 950, 'n_tokens_neox': 929, 'n_words': 264}