<commit_before>import Ember from 'ember';
import mapBboxRoute from 'mobility-playground/mixins/map-bbox-route';

export default Ember.Route.extend(mapBboxRoute, {
  queryParams: {
    onestop_id: {
      refreshModel: true
    },
    bbox: {
      replace: true,
      refreshModel: true
    },
    served_by: {
      refreshModel: true
    },
    isochrone_mode: {
      replace: true,
      refreshModel: true,
    },
    isochrones_mode: {
       replace: true,
      refreshModel: true,
    },
    bus_only: {
      replace: true,
      refreshModel: true,
    }
  },
  setupController: function (controller, model) {
    if (controller.get('bbox') !== null){
      var coordinateArray = [];
      var bboxString = controller.get('bbox');
      var tempArray = [];
      var boundsArray = [];
      coordinateArray = bboxString.split(',');
      for (var i = 0; i < coordinateArray.length; i++){
        tempArray.push(parseFloat(coordinateArray[i]));
      }
      var arrayOne = [];
      var arrayTwo = [];
      arrayOne.push(tempArray[1]);
      arrayOne.push(tempArray[0]);
      arrayTwo.push(tempArray[3]);
      arrayTwo.push(tempArray[2]);
      boundsArray.push(arrayOne);
      boundsArray.push(arrayTwo);
      controller.set('leafletBbox', boundsArray);
    }
    this._super(controller, model);
  },
  model: function(params){
    this.store.unloadAll('data/transitland/operator');
    this.store.unloadAll('data/transitland/stop');
    this.store.unloadAll('data/transitland/route');
    var self = this;
    return this.store.query('data/transitland/stop', params).then(function(stops) {
      if (stops.get('query.isochrone_mode')){
        var onlyStop = stops.get('firstObject');
        var stopLocation = onlyStop.get('geometry.coordinates');
        var url = 'https://matrix.mapzen.com/isochrone?api_key=matrix-bHS1xBE&json=';
        var mode = stops.get('query.isochrone_mode');
        var busOnly = stops.get('query.bus_only');
        if (busOnly) {
          var json = {
            locations: [{"lat":stopLocation[1], "lon":stopLocation[0]}],
            costing: mode,
            costing_options: {"transit":{"use_bus":1.0}},
            contours: [{"time":15},{"time":30},{"time":45},{"time":60}]
          };
        } else {
          var json = {
            locations: [{"lat":stopLocation[1], "lon":stopLocation[0]}],
            costing: mode,
            costing_options: {"pedestrian":{"use_ferry":0}},
            contours: [{"time":15},{"time":30},{"time":45},{"time":60}]
          };
        }
        url += escape(JSON.stringify(json));
        return Ember.RSVP.hash({
          stops: stops,
          onlyStop: onlyStop,
          url: url,
          isochrones: Ember.$.ajax({ url }).then(function(response){
            var polygons= response.features;
            for (var i = 0; i < (polygons.length-1); i++){
              var ring = polygons[i].geometry.coordinates.push(polygons[i+1].geometry.coordinates[0]);
            }
            return response;
          })
        });

      } else if (stops.get('query.isochrones_mode')){
        var stopLocations = [];
        var isochrones = [];
        stopLocations = stopLocations.concat(stops.map(function(stop){return stop.get('geometry.coordinates')}))

        for (var i = 0; i < stopLocations.length; i++){
          var url = 'https://matrix.mapzen.com/isochrone?api_key=matrix-bHS1xBE&json=';
          var mode = 'pedestrian';
          var json = {
            locations: [{"lat":stopLocations[i][1], "lon":stopLocations[i][0]}],
            costing: mode,<commit_msg>proper dev api format<commit_after>import Ember from 'ember';
import mapBboxRoute from 'mobility-playground/mixins/map-bbox-route';

export default Ember.Route.extend(mapBboxRoute, {
  queryParams: {
    onestop_id: {
      refreshModel: true
    },
    bbox: {
      replace: true,
      refreshModel: true
    },
    served_by: {
      refreshModel: true
    },
    isochrone_mode: {
      replace: true,
      refreshModel: true,
    },
    isochrones_mode: {
       replace: true,
      refreshModel: true,
    },
    bus_only: {
      replace: true,
      refreshModel: true,
    }
  },
  setupController: function (controller, model) {
    if (controller.get('bbox') !== null){
      var coordinateArray = [];
      var bboxString = controller.get('bbox');
      var tempArray = [];
      var boundsArray = [];
      coordinateArray = bboxString.split(',');
      for (var i = 0; i < coordinateArray.length; i++){
        tempArray.push(parseFloat(coordinateArray[i]));
      }
      var arrayOne = [];
      var arrayTwo = [];
      arrayOne.push(tempArray[1]);
      arrayOne.push(tempArray[0]);
      arrayTwo.push(tempArray[3]);
      arrayTwo.push(tempArray[2]);
      boundsArray.push(arrayOne);
      boundsArray.push(arrayTwo);
      controller.set('leafletBbox', boundsArray);
    }
    this._super(controller, model);
  },
  model: function(params){
    this.store.unloadAll('data/transitland/operator');
    this.store.unloadAll('data/transitland/stop');
    this.store.unloadAll('data/transitland/route');
    var self = this;
    return this.store.query('data/transitland/stop', params).then(function(stops) {
      if (stops.get('query.isochrone_mode')){
        var onlyStop = stops.get('firstObject');
        var stopLocation = onlyStop.get('geometry.coordinates');
        var url = 'https://matrix.mapzen.com/isochrone?api_key=matrix-bHS1xBE&json=';
        var mode = stops.get('query.isochrone_mode');
        var busOnly = stops.get('query.bus_only');
        if (busOnly) {
          var json = {
            locations: [{"lat":stopLocation[1], "lon":stopLocation[0]}],
            costing: mode,
            costing_options: {"transit":{"use_bus":1.0}},
            contours: [{"time":15},{"time":30},{"time":45},{"time":60}]
          };
        } else {
          var json = {
            locations: [{"lat":stopLocation[1], "lon":stopLocation[0]}],
            costing: mode,
            costing_options: {"pedestrian":{"use_ferry":0}},
            contours: [{"time":15},{"time":30},{"time":45},{"time":60}]
          };
        }
        url += escape(JSON.stringify(json));
        return Ember.RSVP.hash({
          stops: stops,
          onlyStop: onlyStop,
          url: url,
          isochrones: Ember.$.ajax({ url }).then(function(response){
            var polygons= response.features;
            for (var i = 0; i < (polygons.length-1); i++){
              var ring = polygons[i].geometry.coordinates.push(polygons[i+1].geometry.coordinates[0]);
            }
            return response;
          })
        });

      } else if (stops.get('query.isochrones_mode')){
        var stopLocations = [];
        var isochrones = [];
        stopLocations = stopLocations.concat(stops.map(function(stop){return stop.get('geometry.coordinates')}));

        // https://valhalla.dev.mapzen.com/isochrone?api_key=valhalla-t_16n1c
        // &json=%7B%22
        // locations%22%3A%5B%7B%22lat%22%3A40.41035916448923%2C%22lon%22%3A-76.47994995117189%7D%5D%2C%22
        // costing%22%3A%22auto%22%2C%22
        // contours%22%3A%5B%7B%22time%22%3A15%7D%2C%7B%22time%22%3A30%7D%2C%7B%22time%22%3A45%7D%2C%7B%22time%22%3A60%7D%5D%7D

        for (var i = 0; i < stopLocations.length; i++){
          var url = 'https://valhalla.dev.mapzen.com/isochrone?api_key=valhalla-ThKqdPw&json=';
          var mode = 'pedestrian';
          var json = {
            locations: [{"lat":stopLocations[i][1], "lon":stopLocations[i][0]}],
            costing: mode,
{'fraction_non_alphanumeric': 0.16068601583113457, 'fraction_numerical': 0.02467018469656992, 'mean_word_length': 2.5458372310570625, 'pattern_counts': {'":': 36, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 5, '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': '2050781', 'n_tokens_mistral': 2566, 'n_tokens_neox': 2467, 'n_words': 387}