<commit_before>import Ember from 'ember';
import getNextSmallerIndex from '../utils/next-smaller-index';
import computedPoint from '../computed/computed-point';

export default Ember.Service.extend({
  fixCalc: Ember.inject.service(),

  selection: null,

  flight: Ember.computed.readOnly('fixCalc.flights.firstObject'),

  coordinates: Ember.computed('flight', 'selection.{start,end}', function() {
    let selection = this.get('selection');
    if (!selection) {
      return;
    }

    let { start, end } = selection;

    let flight = this.get('flight');
    let times = flight.get('time');

    let start_index = getNextSmallerIndex(times, start);
    let end_index = getNextSmallerIndex(times, end);
    if (start_index >= end_index) {
      return;
    }

    let coordinates = flight.get('geometry').getCoordinates();
    return coordinates.slice(start_index, end_index + 1);
  }),

  startCoordinate: Ember.computed.readOnly('coordinates.firstObject'),
  endCoordinate: Ember.computed.readOnly('coordinates.lastObject'),

  startPoint: computedPoint('coordinates.firstObject'),
  endPoint: computedPoint('coordinates.lastObject'),

  init() {
    this._super(...arguments);
    window.flightPhaseService = this;
  },
});<commit_msg>services/flight-phase: Remove unused "flightPhaseService" global<commit_after>import Ember from 'ember';
import getNextSmallerIndex from '../utils/next-smaller-index';
import computedPoint from '../computed/computed-point';

export default Ember.Service.extend({
  fixCalc: Ember.inject.service(),

  selection: null,

  flight: Ember.computed.readOnly('fixCalc.flights.firstObject'),

  coordinates: Ember.computed('flight', 'selection.{start,end}', function() {
    let selection = this.get('selection');
    if (!selection) {
      return;
    }

    let { start, end } = selection;

    let flight = this.get('flight');
    let times = flight.get('time');

    let start_index = getNextSmallerIndex(times, start);
    let end_index = getNextSmallerIndex(times, end);
    if (start_index >= end_index) {
      return;
    }

    let coordinates = flight.get('geometry').getCoordinates();
    return coordinates.slice(start_index, end_index + 1);
  }),

  startCoordinate: Ember.computed.readOnly('coordinates.firstObject'),
  endCoordinate: Ember.computed.readOnly('coordinates.lastObject'),

  startPoint: computedPoint('coordinates.firstObject'),
  endPoint: computedPoint('coordinates.lastObject'),
});
{'fraction_non_alphanumeric': 0.1419828641370869, 'fraction_numerical': 0.0008159934720522236, 'mean_word_length': 4.473214285714286, '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': '3084649', 'n_tokens_mistral': 753, 'n_tokens_neox': 728, 'n_words': 144}