<commit_before>function Mapper() {
    this.setupDrawingSpace();
    this.setupControls();
    this.loadAllBaseMaps();
    this.lazyLoadStreetsBaseMap();
}

Mapper.prototype = {
    refreshRate: 10,
    refreshInterval: null,
    baseProjectionScale: 350000,
    baseMapCenter: [-122.433701, 37.767683],
    baseMapNames: [
        'neighborhoods',
        'arteries',
        'freeways',
    ],
    baseMapGeoJSON: [],
    baseMapGroups: [],
    vehicleGroups: {},
    zoomTransform: null,
    routes: [],
    routeColors: {},
    routeTileBackgroundColor: 'rgba(0,0,0,0.40)',
    activeRoutes: [],
    vehicleStore: {},
    myPositionGroup: null,
    getProxyURL: function() {
        if (window.location.hostname === 'localhost') {
            return 'proxy?url='
        } else {
            return 'https://jbpmunimap.herokuapp.com/proxy?url='
        }

    },

    isSecure: function() {
        var _t = this;
        if (window.location.protocol.indexOf('https:') > -1) {
            return _t.getProxyURL()
        } else {
            return ''
        }

    },

    setupDrawingSpace: function() {
        var _t = this;
        var width = window.innerWidth,
            height = window.innerHeight;

        _t.zoom = d3.zoom()
            .scaleExtent([1, 10])
            .on("zoom", function() {
                _t.zoomed()
            })

        _t.svg = d3.select(".map-container").append("svg")
            .attr("preserveAspectRatio", "xMidYMid slice")
            .attr("viewBox", "0 0 " + width + " " + height)
            .classed("svg-content-responsive", true)
            .call(_t.zoom)

        _t.projection = d3.geoMercator()
            .scale(_t.baseProjectionScale)
            .rotate([0, 0])
            .center(_t.baseMapCenter)
            .translate([width / 2, height / 2])

    },

    zoomed: function() {
        var _t = this;

        _t.baseMapGroups.forEach(function(mapGroup) {
            mapGroup.attr("transform", d3.event.transform);
        });

        for (var property in _t.vehicleGroups) {
            if (_t.vehicleGroups.hasOwnProperty(property)) {
                _t.vehicleGroups[property].attr("transform", d3.event.transform);
            }
        }

        _t.svg.selectAll('.route-path').attr('transform', d3.event.transform)
        if (_t.myPositionGroup !== null) {
            _t.myPositionGroup.attr('transform', d3.event.transform)
        }
        _t.zoomTransform = d3.event.transform;

    },

    loadAllBaseMaps: function() {
        var _t = this;

        _t.baseMapNames.forEach(function(mapName) {
            _t.loadBaseMap(mapName);
        })
    },

    lazyLoadStreetsBaseMap: function() {
        var _t = this;

        d3.json("assets/sfmaps/streets.json", function(error, geojson) {
            if (error) {
                console.error(error);
                return
            }
            geojson.name = 'streets';
            _t.baseMapGeoJSON.push(geojson);
            _t.addStreetsBaseMapLayer(geojson);

        });
    },

    addStreetsBaseMapLayer: function(geojson) {
        var _t = this;
        var svgGroup = _t.svg.append("g").attr('id', 'layer_streets')

        var geoPath = d3.geoPath()
            .projection(_t.projection);

        svgGroup.selectAll("path")
            .data(geojson.features)
            .enter()
            .append("path")
            .style("stroke", getRandomHexColor())
            .attr("d", geoPath)

        var streetsLayer = document.getElementById('layer_streets');
        var svg = document.getElementsByTagName('svg')[0];

        svg.insertBefore(streetsLayer, svg.children[1])

        _t.baseMapGroups.push(svgGroup);

    },

    loadBaseMap: function(mapName) {
        var _t = this;<commit_msg>random fill for streets too<commit_after>function Mapper() {
    this.setupDrawingSpace();
    this.setupControls();
    this.loadAllBaseMaps();
    this.lazyLoadStreetsBaseMap();
}

Mapper.prototype = {
    refreshRate: 10,
    refreshInterval: null,
    baseProjectionScale: 350000,
    baseMapCenter: [-122.433701, 37.767683],
    baseMapNames: [
        'neighborhoods',
        'arteries',
        'freeways',
    ],
    baseMapGeoJSON: [],
    baseMapGroups: [],
    vehicleGroups: {},
    zoomTransform: null,
    routes: [],
    routeColors: {},
    routeTileBackgroundColor: 'rgba(0,0,0,0.40)',
    activeRoutes: [],
    vehicleStore: {},
    myPositionGroup: null,
    getProxyURL: function() {
        if (window.location.hostname === 'localhost') {
            return 'proxy?url='
        } else {
            return 'https://jbpmunimap.herokuapp.com/proxy?url='
        }

    },

    isSecure: function() {
        var _t = this;
        if (window.location.protocol.indexOf('https:') > -1) {
            return _t.getProxyURL()
        } else {
            return ''
        }

    },

    setupDrawingSpace: function() {
        var _t = this;
        var width = window.innerWidth,
            height = window.innerHeight;

        _t.zoom = d3.zoom()
            .scaleExtent([1, 10])
            .on("zoom", function() {
                _t.zoomed()
            })

        _t.svg = d3.select(".map-container").append("svg")
            .attr("preserveAspectRatio", "xMidYMid slice")
            .attr("viewBox", "0 0 " + width + " " + height)
            .classed("svg-content-responsive", true)
            .call(_t.zoom)

        _t.projection = d3.geoMercator()
            .scale(_t.baseProjectionScale)
            .rotate([0, 0])
            .center(_t.baseMapCenter)
            .translate([width / 2, height / 2])

    },

    zoomed: function() {
        var _t = this;

        _t.baseMapGroups.forEach(function(mapGroup) {
            mapGroup.attr("transform", d3.event.transform);
        });

        for (var property in _t.vehicleGroups) {
            if (_t.vehicleGroups.hasOwnProperty(property)) {
                _t.vehicleGroups[property].attr("transform", d3.event.transform);
            }
        }

        _t.svg.selectAll('.route-path').attr('transform', d3.event.transform)
        if (_t.myPositionGroup !== null) {
            _t.myPositionGroup.attr('transform', d3.event.transform)
        }
        _t.zoomTransform = d3.event.transform;

    },

    loadAllBaseMaps: function() {
        var _t = this;

        _t.baseMapNames.forEach(function(mapName) {
            _t.loadBaseMap(mapName);
        })
    },

    lazyLoadStreetsBaseMap: function() {
        var _t = this;

        d3.json("assets/sfmaps/streets.json", function(error, geojson) {
            if (error) {
                console.error(error);
                return
            }
            geojson.name = 'streets';
            _t.baseMapGeoJSON.push(geojson);
            _t.addStreetsBaseMapLayer(geojson);

        });
    },

    addStreetsBaseMapLayer: function(geojson) {
        var _t = this;
        var svgGroup = _t.svg.append("g").attr('id', 'layer_streets')

        var geoPath = d3.geoPath()
            .projection(_t.projection);

        svgGroup.selectAll("path")
            .data(geojson.features)
            .enter()
            .append("path")
            .style("fill", getRandomHexColor())
            .style("stroke", getRandomHexColor())
            .attr("d", geoPath)

        var streetsLayer = document.getElementById('layer_streets');
        var svg = document.getElementsByTagName('svg')[0];

        svg.insertBefore(streetsLayer, svg.children[1])

        _t.baseMapGroups.push(svgGroup);

    },

    loadBaseMap: function(mapName) {
        var _t = this;
{'fraction_non_alphanumeric': 0.13833157338965152, 'fraction_numerical': 0.01399155227032735, 'mean_word_length': 1.9030651340996168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1249035', 'n_tokens_mistral': 2429, 'n_tokens_neox': 2297, 'n_words': 363}