<commit_before>Skyderby.views.TrackMapView = Backbone.View.extend({

    render: function() {
        var center = new google.maps.LatLng(26.703115, 22.085180);
        var options = {
            'zoom': 2,
            'center': center,
            'mapTypeId': google.maps.MapTypeId.ROADMAP
        };

        this.map = new google.maps.Map(this.$('#map')[0], options);

        this.draw_polyline();
    },

    draw_polyline: function() {
        var path_coordinates = [], 
            prev_point = null,
            polyline;

        var points = this.model.get('points');

        for (var index in points) {
            var current_point = points[index];
          
            if (path_coordinates.length === 0 || (this.speed_group(prev_point.h_speed) == this.speed_group(current_point.h_speed))) {
                path_coordinates.push({
                    'lat': Number(current_point.latitude),
                    'lng': Number(current_point.longitude)
                });
            } else {

                polyline = new google.maps.Polyline({
                    path: path_coordinates,
                    strokeColor: $('.hl' + this.speed_group(prev_point.h_speed)).css( "background-color" ),
                    strokeOpacity: 1, strokeWeight: 6
                });

                polyline.setMap(this.map);

                path_coordinates = [];
                path_coordinates.push({
                    'lat': Number(prev_point.latitude), 
                    'lng': Number(prev_point.longitude)
                });
            }
            prev_point = current_point;
        }

        polyline = new google.maps.Polyline({
            path: path_coordinates,
            strokeColor: $('.hl' + this.speed_group(prev_point.h_speed)).css( "background-color" ),
            strokeOpacity: 1, strokeWeight: 6
        });

        polyline.setMap(this.map);

        var bounds = new google.maps.LatLngBounds();
        bounds.extend(new google.maps.LatLng(
            Number(points[0].latitude), 
            Number(points[0].longitude)
        ));

        bounds.extend(new google.maps.LatLng(
            Number(points[points.length - 1].latitude),
            Number(points[points.length - 1].longitude)
        ));

        this.map.fitBounds(bounds);
        this.map.setCenter(bounds.getCenter());
    },

    speed_group: function(speed) {
        if (speed > 250) {
          return 6;
        } else if (speed > 220) {
          return 5;
        } else if (speed > 190) {
          return 4;
        } else if (speed > 160) {
          return 3;
        } else if (speed > 130) {
          return 2;
        } else {
          return 1;
        }
    },

    speed_group_color: function(spd_group) {
        if (spd_group == 1) {
          return 'aa2e7e2d';
        } else if (spd_group == 2) {
          return 'aa43c042';
        } else if (spd_group == 3) {
          return 'aa34ced9';
        } else if (spd_group == 4) {
          return 'aa0f67e4';
        } else if (spd_group == 5) {
          return 'aa0c00e7';
        } else if (spd_group == 6) {
          return 'aa0c0060';
        }
    },
});<commit_msg>changed maptype to terrain, added console log lat, lon, elev on click<commit_after>Skyderby.views.TrackMapView = Backbone.View.extend({

    render: function() {
        var center = new google.maps.LatLng(26.703115, 22.085180);
        var options = {
            'zoom': 2,
            'center': center,
            'mapTypeId': 'terrain'
        };

        this.map = new google.maps.Map(this.$('#map')[0], options);

        this.map.addListener('click', this.displayLocationElevation);

        this.draw_polyline();
    },

    draw_polyline: function() {
        var path_coordinates = [], 
            prev_point = null,
            polyline;

        var points = this.model.get('points');

        for (var index in points) {
            var current_point = points[index];
          
            if (path_coordinates.length === 0 || (this.speed_group(prev_point.h_speed) == this.speed_group(current_point.h_speed))) {
                path_coordinates.push({
                    'lat': Number(current_point.latitude),
                    'lng': Number(current_point.longitude)
                });
            } else {

                polyline = new google.maps.Polyline({
                    path: path_coordinates,
                    strokeColor: $('.hl' + this.speed_group(prev_point.h_speed)).css( "background-color" ),
                    strokeOpacity: 1, strokeWeight: 6
                });

                polyline.setMap(this.map);

                path_coordinates = [];
                path_coordinates.push({
                    'lat': Number(prev_point.latitude), 
                    'lng': Number(prev_point.longitude)
                });
            }
            prev_point = current_point;
        }

        polyline = new google.maps.Polyline({
            path: path_coordinates,
            strokeColor: $('.hl' + this.speed_group(prev_point.h_speed)).css( "background-color" ),
            strokeOpacity: 1, strokeWeight: 6
        });

        polyline.setMap(this.map);

        var bounds = new google.maps.LatLngBounds();
        bounds.extend(new google.maps.LatLng(
            Number(points[0].latitude), 
            Number(points[0].longitude)
        ));

        bounds.extend(new google.maps.LatLng(
            Number(points[points.length - 1].latitude),
            Number(points[points.length - 1].longitude)
        ));

        this.map.fitBounds(bounds);
        this.map.setCenter(bounds.getCenter());
    },

    speed_group: function(speed) {
        if (speed > 250) {
          return 6;
        } else if (speed > 220) {
          return 5;
        } else if (speed > 190) {
          return 4;
        } else if (speed > 160) {
          return 3;
        } else if (speed > 130) {
          return 2;
        } else {
          return 1;
        }
    },

    speed_group_color: function(spd_group) {
        if (spd_group == 1) {
          return 'aa2e7e2d';
        } else if (spd_group == 2) {
          return 'aa43c042';
        } else if (spd_group == 3) {
          return 'aa34ced9';
        } else if (spd_group == 4) {
          return 'aa0f67e4';
        } else if (spd_group == 5) {
          return 'aa0c00e7';
        } else if (spd_group == 6) {
          return 'aa0c0060';
        }
    },

    displayLocationElevation: function (event) {
        var location = event.latLng;
        var elevator = new google.maps.ElevationService();
        // Initiate the location request
        elevator.getElevationForLocations({
            'locations': [location]
        }, function(results, status) {
            if (status === google.maps.ElevationStatus.OK) {
                // Retrieve the first result
                if (results[0]) {
                    console.log(
                        'Latitude: ' + location.lat().toFixed(8) + ' - ' +
                        'Longitude: ' + location.lng().toFixed(8) + ' - ' +
                        'Elevation: ' + Math.round(results[0].elevation) + ' m.');
                } else {
                    console.log('No results found');
                }
            } else {
                console.log('Elevation service failed due to: ' + status);
            }
        });
    },
});
{'fraction_non_alphanumeric': 0.1254577512545775, 'fraction_numerical': 0.021700800217008, 'mean_word_length': 1.5340206185567011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '6608244', 'n_tokens_mistral': 2300, 'n_tokens_neox': 2097, 'n_words': 408}