All files / src/app/touchpad/transports transport.service.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 4/4
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                1x       8x 8x                   1x 1x                       1x 3x                   1x 2x   1x  
import { Injectable } from '@angular/core';
import { TransportProvider, SwissTransportsProvider } from './transport-providers';
import { HttpClient } from '@angular/common/http';
import { Station } from './utils';
 
@Injectable({
  providedIn: 'root'
})
export class TransportService {
 
  private transportProvider: TransportProvider;
 
  constructor(private http: HttpClient) {
    this.transportProvider = new SwissTransportsProvider(this.http);
  }
 
  /**
   * Get the nearest bus or tram station for a point on a map.
   *
   * @param point An Esri Point with WGS84 coordinates for which the nearest station must be found.
   *
   * @returns A list of Stations near the input point.
   */
  getNearestBusStation(point: __esri.Point): Promise<Station | undefined> {
    return this.transportProvider.getNearestBusStation(point);
  }
 
  /**
   * Search the nearest station serving a specific line.
   *
   * @param point The Esri Point with WGS84 coordinates near which stations serving a
   * given line must be searched.
   * @param line The name of the line to search for in nearby stations.
   *
   * @returns The nearest station serving the input line.
   */
  getNearestStationByLine(point: __esri.Point, line: string): Promise<Station | undefined> {
    return this.transportProvider.getNearestStationByLine(point, line);
  }
 
  /**
   * Get the nearest train station to a point on a map.
   *
   * @param point An Esri Point with WGS84 coordinates near which stations must be searched.
   *
   * @returns The nearest station to the input point.
   */
  getNearestTrainStation(point: __esri.Point): Promise<Station | undefined> {
    return this.transportProvider.getNearestTrainStation(point);
  }
}