<commit_before>import Legend from './Legend';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import { Route } from 'react-router-dom';
import ReactMapboxGl, { Feature, Layer, Popup as MapboxPopup, ZoomControl } from 'react-mapbox-gl';
import throttle from 'lodash.throttle';
import turfBboxPolygon from '@turf/bbox-polygon';
import turfInside from '@turf/inside';
import { point as turfPoint } from '@turf/helpers';
import BusMarker from './BusMarker';
import BusMenu from './BusMenu';
import CurrentPositionRadius from './CurrentPositionRadius';
import FeatureHighlight from './FeatureHighlight';
import Popup from './Popup';
import { getBuses } from '../services/bus';
import { busRouteLayerNames } from '../config';

const routeLayerLabels = {
  'bike-lanes': 'Bike Lane',
  'bike-routes': 'Bike Route',
  'bike-trails-background': 'Bike Trail',
  'bike-trails-dashes': 'Bike Trail'
};

const bounds = [24.49, -81.94, 24.64, -81.61];
const boundsBbox = turfBboxPolygon(bounds);
const footerHeight = 60;

class BikeMap extends Component {
  static propTypes = {
    history: PropTypes.object.isRequired,
    match: PropTypes.object.isRequired
  }

  constructor(props) {
    super(props);
    this.state = {
      buses: [],
      busMenuOpen: false,
      busRoutesEnabled: false,
      center: [-81.778836, 24.558053],
      currentPosition: null,
      currentPositionRadiusEnabled: false,
      legendShown: false,
      map: null,
      mapHeight: 0,
      mouseOverClickable: false,
      popupLabel: null,
      popupCoordinates: null,
      selectedBuses: [],
      selectedFeature: null,
      zoom: [13]
    };
  }

  componentWillMount() {
    if (!this.state.buses.length) {
      this.getBusRoutes();
    }

    // Add map height resize
    this.updateMapHeight();
    const bound = this.updateMapHeight.bind(this);
    this.resizeListener = throttle(bound, 100);
    window.addEventListener('resize', this.resizeListener);

    this.watchPositionId = navigator.geolocation.watchPosition(position => {
      let currentPosition = [position.coords.longitude, position.coords.latitude];
      if (!turfInside(turfPoint(currentPosition), boundsBbox)) {
        currentPosition = [-81.802118, 24.554755];
      }
      this.setState({ currentPosition });
    });
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.resizeListener);
    navigator.geolocation.clearWatch(this.watchPositionId);
  }

  onClick(map, event) {
    const features = map.queryRenderedFeatures(event.point, {
      layers: ['circulator-stops-fill', 'harbor-walk', 'poi-cfkw'].concat(Object.keys(routeLayerLabels).concat(busRouteLayerNames))
    });
    if (!features.length) {
      this.deselectFeature();
      return;<commit_msg>Log when using default position<commit_after>import Legend from './Legend';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router';
import { Route } from 'react-router-dom';
import ReactMapboxGl, { Feature, Layer, Popup as MapboxPopup, ZoomControl } from 'react-mapbox-gl';
import throttle from 'lodash.throttle';
import turfBboxPolygon from '@turf/bbox-polygon';
import turfInside from '@turf/inside';
import { point as turfPoint } from '@turf/helpers';
import BusMarker from './BusMarker';
import BusMenu from './BusMenu';
import CurrentPositionRadius from './CurrentPositionRadius';
import FeatureHighlight from './FeatureHighlight';
import Popup from './Popup';
import { getBuses } from '../services/bus';
import { busRouteLayerNames } from '../config';

const routeLayerLabels = {
  'bike-lanes': 'Bike Lane',
  'bike-routes': 'Bike Route',
  'bike-trails-background': 'Bike Trail',
  'bike-trails-dashes': 'Bike Trail'
};

const bounds = [24.49, -81.94, 24.64, -81.61];
const boundsBbox = turfBboxPolygon(bounds);
const footerHeight = 60;

class BikeMap extends Component {
  static propTypes = {
    history: PropTypes.object.isRequired,
    match: PropTypes.object.isRequired
  }

  constructor(props) {
    super(props);
    this.state = {
      buses: [],
      busMenuOpen: false,
      busRoutesEnabled: false,
      center: [-81.778836, 24.558053],
      currentPosition: null,
      currentPositionRadiusEnabled: false,
      legendShown: false,
      map: null,
      mapHeight: 0,
      mouseOverClickable: false,
      popupLabel: null,
      popupCoordinates: null,
      selectedBuses: [],
      selectedFeature: null,
      zoom: [13]
    };
  }

  componentWillMount() {
    if (!this.state.buses.length) {
      this.getBusRoutes();
    }

    // Add map height resize
    this.updateMapHeight();
    const bound = this.updateMapHeight.bind(this);
    this.resizeListener = throttle(bound, 100);
    window.addEventListener('resize', this.resizeListener);

    this.watchPositionId = navigator.geolocation.watchPosition(position => {
      let currentPosition = [position.coords.longitude, position.coords.latitude];
      if (!turfInside(turfPoint(currentPosition), boundsBbox)) {
        console.log('Outside bounds: using default position');
        currentPosition = [-81.802118, 24.554755];
      }
      this.setState({ currentPosition });
    });
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.resizeListener);
    navigator.geolocation.clearWatch(this.watchPositionId);
  }

  onClick(map, event) {
    const features = map.queryRenderedFeatures(event.point, {
      layers: ['circulator-stops-fill', 'harbor-walk', 'poi-cfkw'].concat(Object.keys(routeLayerLabels).concat(busRouteLayerNames))
    });
    if (!features.length) {
      this.deselectFeature();
      return;
{'fraction_non_alphanumeric': 0.13175853018372705, 'fraction_numerical': 0.019597550306211724, 'mean_word_length': 3.751454696591854, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3071438', 'n_tokens_mistral': 1843, 'n_tokens_neox': 1724, 'n_words': 394}