<commit_before>angular.module('ScoutIOApp')
  .controller('PhotoDialogCtrl', ['$mdDialog', '$scope', '$rootScope', '$state', 'NgMap', function ($mdDialog, $rootScope, $scope, $state, NgMap) {
    $scope.showDialog = function (e, photo) {
      $scope.photo = photo;
      $scope.mapStyle = [{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}];
      $scope.photo.datetaken = new Date($scope.photo.datetaken).toLocaleString();
      $scope.photoDialogFlexWidth = "80";
      $rootScope.directions = {};
      $rootScope.directions.place = '';
      $scope.origin = '';
      $scope.distance = '';
      $scope.duration = '';

      if ($scope.photo.height_m > $scope.photo.width_m) {
        $scope.photoDialogFlexWidth = "60";
      }

      var displayPath = function () {
        NgMap.getMap({id: 'photomap'}).then(function (map) {
          //console.log(map.directionsRenderers[0].directions.routes[0].overview_path);
          var elevator = new google.maps.ElevationService;

          var route = map.directionsRenderers[0].directions.routes[0].legs[0];
          $scope.distance = route.distance.text;
          $scope.duration = route.duration.text;
          //var path = map.directionsRenderers[0].directions.overview_path; //too many points for the width of the chart
          var path = [];

          for (var i = 0; i < route.steps.length; i++) {
            path.push(route.steps[i].end_location);
          }

          elevator.getElevationForLocations({
            'locations': path
          }, plotElevation);
        });
      };

      var plotElevation = function(elevations, status) {
        var chartDiv = document.getElementById('pathDiv');
        var chart = new google.visualization.ColumnChart(chartDiv);
        var data = new google.visualization.DataTable();

        data.addColumn('string', 'Sample');
        data.addColumn('number', 'Elevation');

        for (var i = 0; i < elevations.length; i++) {
          data.addRow(['', elevations[i].elevation]);
        }

        chart.draw(data, {
          //height: 100,
          //width:  450,
          legend: 'none',
          titleY: 'Elevation (m)'
        });
      };

      $scope.placeChanged = function () {
        var place = this.getPlace();

        if (place && place.geometry) {
          $scope.origin = place.geometry.location.lat() + "," + place.geometry.location.lng();

          setTimeout(displayPath, 1000);  //wait for the map to render
        } else {
          document.getElementById('photo-dialog-places-textbox').value = '';
          $rootScope.directions.place = '';
          $scope.origin = '';
          $scopegrun.distance = '';
          $scope.duration = '';

          NgMap.getMap({id: 'photomap'}).then(function (map) {
            $scope.map = map;

            if (map.directionsRenderers && map.directionsRenderers[0]) {
              var directionDisplay = map.directionsRenderers;
              directionDisplay[0].set('directions', null);
            }

            $scope.map.setCenter(new google.maps.LatLng(parseFloat(photo.latitude), parseFloat(photo.longitude)));<commit_msg>apply photo dialog mapping and directions features<commit_after>angular.module('ScoutIOApp')
  .controller('PhotoDialogCtrl', ['$mdDialog', '$scope', '$rootScope', '$state', 'NgMap', function ($mdDialog, $rootScope, $scope, $state, NgMap) {
    $scope.showDialog = function (e, photo) {
      $scope.photo = photo;
      $scope.mapStyle = [{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}];
      $scope.photo.datetaken = new Date($scope.photo.datetaken).toLocaleString();
      $scope.photoDialogFlexWidth = "80";
      $rootScope.directions = {};
      $rootScope.directions.place = '';
      $scope.origin = '';
      $scope.distance = '';
      $scope.duration = '';

      if ($scope.photo.height_m > $scope.photo.width_m) {
        $scope.photoDialogFlexWidth = "60";
      }

      var displayPath = function () {
        NgMap.getMap({id: 'photomap'}).then(function (map) {
          //console.log(map.directionsRenderers[0].directions.routes[0].overview_path);
          var elevator = new google.maps.ElevationService;

          var route = map.directionsRenderers[0].directions.routes[0].legs[0];
          $scope.distance = route.distance.text;
          $scope.duration = route.duration.text;
          //var path = map.directionsRenderers[0].directions.overview_path; //too many points for the width of the chart
          var path = [];

          for (var i = 0; i < route.steps.length; i++) {
            path.push(route.steps[i].end_location);
          }

          elevator.getElevationForLocations({
            'locations': path
          }, plotElevation);
        });
      };

      var plotElevation = function(elevations, status) {
        var chartDiv = document.getElementById('pathDiv');
        var chart = new google.visualization.ColumnChart(chartDiv);
        var data = new google.visualization.DataTable();

        data.addColumn('string', 'Sample');
        data.addColumn('number', 'Elevation');

        for (var i = 0; i < elevations.length; i++) {
          data.addRow(['', elevations[i].elevation]);
        }

        chart.draw(data, {
          //height: 100,
          //width:  450,
          legend: 'none',
          titleY: 'Elevation (m)'
        });
      };

      $scope.placeChanged = function () {
        var place = this.getPlace();

        if (place && place.geometry) {
          $scope.origin = place.geometry.location.lat() + "," + place.geometry.location.lng();

          setTimeout(displayPath, 1000);  //wait for the map to render
        } else {
          document.getElementById('photo-dialog-places-textbox').value = '';
          $rootScope.directions.place = '';
          $scope.origin = '';
          $scope.distance = '';
          $scope.duration = '';

          NgMap.getMap({id: 'photomap'}).then(function (map) {
            $scope.map = map;

            if (map.directionsRenderers && map.directionsRenderers[0]) {
              var directionDisplay = map.directionsRenderers;
              directionDisplay[0].set('directions', null);
            }

            $scope.map.setCenter(new google.maps.LatLng(parseFloat(photo.latitude), parseFloat(photo.longitude)));
{'fraction_non_alphanumeric': 0.18755682556176126, 'fraction_numerical': 0.050915703338095857, 'mean_word_length': 3.0848806366047747, 'pattern_counts': {'":': 72, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, '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': '3741654', 'n_tokens_mistral': 2649, 'n_tokens_neox': 2354, 'n_words': 323}