<commit_before>angular.module("logbuch").controller "TrackCtrl", ($scope, $ionicScrollDelegate, $rootScope, $timeout, $log, ToastrService, StorageService, Log, DebugLog, Track, LocationService) ->
  $scope.view = StorageService.get('currentTrackView', 'track')

  $rootScope.$$listeners['locationChange'] = [] # unregister existing listeners
  $rootScope.$on 'locationChange', (event, position) ->
    $log.info 'got position update', position, moment().toISOString()
    return unless $scope.track

    new DebugLog("updating position: #{JSON.stringify(position)}").save()
    $scope.track.updateCurrentPosition(position)
    Track.toStorage($scope.track)

  if $scope.view == 'track'
    $scope.track = Track.fromStorage()
    LocationService.watchPosition() if $scope.track

  $scope.start = ->
    success = (position) ->
      $scope.track = Track.fromPosition(position.latLng.lat, position.latLng.lng)
      Track.toStorage($scope.track)
      ToastrService.hide()
      LocationService.watchPosition()

    error = ->
      ToastrService.show('Ermitteln der Koordinaten fehlgeschlagen.')

    ToastrService.show('Ermittle Koordinaten...', true)
    LocationService.getAccuratePosition().then success, error

  $scope.stop = ->
    success = (position) ->
      ToastrService.hide()
      $scope.track.addWaypoint(position.latLng.lat, position.latLng.lng)<commit_msg>reject new position if accuracy is below 50<commit_after>angular.module("logbuch").controller "TrackCtrl", ($scope, $ionicScrollDelegate, $rootScope, $timeout, $log, ToastrService, StorageService, Log, DebugLog, Track, LocationService) ->
  $scope.view = StorageService.get('currentTrackView', 'track')

  $rootScope.$$listeners['locationChange'] = [] # unregister existing listeners
  $rootScope.$on 'locationChange', (event, position) ->
    return unless $scope.track
    return unless position.coords.accuracy <= 50

    new DebugLog('TrackCtrl Position Update').save()
    $scope.track.updateCurrentPosition(position)
    Track.toStorage($scope.track)

  if $scope.view == 'track'
    $scope.track = Track.fromStorage()
    LocationService.watchPosition() if $scope.track

  $scope.start = ->
    success = (position) ->
      $scope.track = Track.fromPosition(position.latLng.lat, position.latLng.lng)
      Track.toStorage($scope.track)
      ToastrService.hide()
      LocationService.watchPosition()

    error = ->
      ToastrService.show('Ermitteln der Koordinaten fehlgeschlagen.')

    ToastrService.show('Ermittle Koordinaten...', true)
    LocationService.getAccuratePosition().then success, error

  $scope.stop = ->
    success = (position) ->
      ToastrService.hide()
      $scope.track.addWaypoint(position.latLng.lat, position.latLng.lng)
{'fraction_non_alphanumeric': 0.1389904901243599, 'fraction_numerical': 0.001463057790782736, 'mean_word_length': 4.321011673151751, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 17, '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': '2478545', 'n_tokens_mistral': 827, 'n_tokens_neox': 809, 'n_words': 150}