<commit_before># This handles the routing calls and will eventually become only one way we get
# routing information
class window.beats.GoogleMapRouteHandler
  $a = window.beats
  queue = []
  rate = 100
  
  constructor: (@links) ->
    @directionsService = new google.maps.DirectionsService()
    @_requestLink(@links.length - 1)
  
  # recursive method used to grab the Google route for every link
  # indexOfLink starts at the end of the link list and is decreased 
  # on each recursive call. If geometry exists we just draw the link
  _requestLink: (indexOfLink) ->
    if indexOfLink > -1
      link = @links[indexOfLink]
      if(@_geomDoesNotExist(link))
        link.index = indexOfLink
        @setUpLink(link)
        @_directionsRequest(link)
        if(indexOfLink % 10 == 0)
          $a.broker.trigger('app:show_message:info', 'Loading ...')
      else
        $a.broker.trigger('map:draw_link', link)
        @_requestLink(indexOfLink - 1)
    else
      $a.broker.trigger('app:show_message:success', 'Loaded map successfully')
  
  # setUpLink takes the link that may need geometry and a flag indicating 
  # whether or not we want to force new geometry to be querried. This happens
  # when an existing node is dragged or a node is added.
  setUpLink: (link) ->
      begin =  link.get('begin').get('node')
      end = link.get('end').get('node')
      #Create DirectionsRequest using DRIVING directions.
      link.request = {
       origin: $a.Util.getLatLng(begin),
       destination: $a.Util.getLatLng(end),
       travelMode: google.maps.TravelMode.DRIVING,
      }
      link
  
  # check to see if the geometry exists before cycling to get route
  _geomDoesNotExist: (link) ->
     geom = link.get('shape')?.get('text')
     return geom is undefined or geom is null
  
  # _directionsRequest makes the actual route request to google. if we 
  # recieve any error, this method will wait 3 seconds and then 
  # call itself again with the same request object. I removed
  # monitoring the the number of attempts and just keep trying until we are 
  # done. If get a route, this method calls _drawLink to render the link on the 
  # page
  _directionsRequest: (link) ->
      @directionsService.route(link.request, (response, status) =>
        if (status == google.maps.DirectionsStatus.OK)
          rte = response.routes[0]
          if rte.warnings.length > 0
            msg = "#{WARNING_MSG} #{rte.warnings}"
            $a.broker.trigger('app:show_message:info', msg)
          if link?
            link.legs = rte.legs 
            $a.broker.trigger('map:draw_link', link)
            if(rate > 200)
              rate -= 100
            setTimeout (() =>  @_requestLink(link.index - 1)), rate
        else
          rate = 1000
          setTimeout (() =>  @_requestLink(link.index)), rate
      )
    
  #checks to see if we are over the google query limit
  _isOverQuery: (status) ->
    status == google.maps.DirectionsStatus.OVER_QUERY_LIMIT
  <commit_msg>added countdown during loading of network<commit_after># This handles the routing calls and will eventually become only one way we get
# routing information
class window.beats.GoogleMapRouteHandler
  $a = window.beats
  queue = []
  rate = 100
  
  constructor: (@links) ->
    @directionsService = new google.maps.DirectionsService()
    @_requestLink(@links.length - 1)
  
  # recursive method used to grab the Google route for every link
  # indexOfLink starts at the end of the link list and is decreased 
  # on each recursive call. If geometry exists we just draw the link
  _requestLink: (indexOfLink) ->
    if indexOfLink > -1
      link = @links[indexOfLink]
      if(@_geomDoesNotExist(link))
        link.index = indexOfLink
        @setUpLink(link)
        @_directionsRequest(link)
        if(indexOfLink % 10 == 0)
          $a.broker.trigger('app:show_message:info', "Loading ... #{indexOfLink} more" )
      else
        $a.broker.trigger('map:draw_link', link)
        @_requestLink(indexOfLink - 1)
    else
      $a.broker.trigger('app:show_message:success', 'Loaded map successfully')
  
  # setUpLink takes the link that may need geometry and a flag indicating 
  # whether or not we want to force new geometry to be querried. This happens
  # when an existing node is dragged or a node is added.
  setUpLink: (link) ->
      begin =  link.get('begin').get('node')
      end = link.get('end').get('node')
      #Create DirectionsRequest using DRIVING directions.
      link.request = {
       origin: $a.Util.getLatLng(begin),
       destination: $a.Util.getLatLng(end),
       travelMode: google.maps.TravelMode.DRIVING,
      }
      link
  
  # check to see if the geometry exists before cycling to get route
  _geomDoesNotExist: (link) ->
     geom = link.get('shape')?.get('text')
     return geom is undefined or geom is null
  
  # _directionsRequest makes the actual route request to google. if we 
  # recieve any error, this method will wait 3 seconds and then 
  # call itself again with the same request object. I removed
  # monitoring the the number of attempts and just keep trying until we are 
  # done. If get a route, this method calls _drawLink to render the link on the 
  # page
  _directionsRequest: (link) ->
      @directionsService.route(link.request, (response, status) =>
        if (status == google.maps.DirectionsStatus.OK)
          rte = response.routes[0]
          if rte.warnings.length > 0
            msg = "#{WARNING_MSG} #{rte.warnings}"
            $a.broker.trigger('app:show_message:info', msg)
          if link?
            link.legs = rte.legs 
            $a.broker.trigger('map:draw_link', link)
            if(rate > 200)
              rate -= 100
            setTimeout (() =>  @_requestLink(link.index - 1)), rate
        else
          rate = 1000
          setTimeout (() =>  @_requestLink(link.index)), rate
      )
    
  #checks to see if we are over the google query limit
  _isOverQuery: (status) ->
    status == google.maps.DirectionsStatus.OVER_QUERY_LIMIT
  
{'fraction_non_alphanumeric': 0.09792874896437448, 'fraction_numerical': 0.007622203811101905, 'mean_word_length': 2.660400242571255, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '2137452', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1762, 'n_words': 579}