fetchRouteForMot(viaPoints, mot, sequenceProps, isStart, isEnd) {
    this.abortController = new AbortController();

    const via = viaPoints.map((viaPoint) => {
      if (Array.isArray(viaPoint)) {
        return `${viaPoint[0]},${viaPoint[1]}`;
      }
      return `!${viaPoint}`;
    });

    const urlParams = {
      profile: 'sbb',
      [this.apiKeyName || 'key']: this.apiKey || '',
      via: via.join('|'),
      mot,
    };

    const url = `${this.url}/?${qs.stringify(urlParams)}`;
    const format = new GeoJSON({
      dataProjection: 'EPSG:4326',
      featureProjection: this.projection,
    });

    return fetch(url, { signal: this.abortController.signal })
      .then((res) => res.json())
      .then((data) => {
        const lineStrings = format.readFeatures(data);
        const feature = new Feature({
          geometry: new MultiLineString(
            lineStrings.map((l) => l.getGeometry()),
          ),
        });
        feature.setProperties({
          ...sequenceProps,
          isStart,
          isEnd,
        });
        return feature;
      })
      .catch(() => {
        // Ignore failed API requests.
      });
  }
/**
   * Getting the Mot-features on specific route.
   * @private
   * @param {Object} viaPoints Route Informations
   * @param {String} mot Ask for specific Route
   * @param {Object[]} sequenceProps Properties for the returned features.
   * @param {Boolean} isStart Determines if the sequence is the first of the route.
   * @param {Boolean} isEnd Determines if the sequence is the final of the route.
   * @returns {array<ol.Feature>} Features
   */
Getting the Mot-features on specific route.
@private
@param {Object} viaPoints Route Informations
@param {String} mot Ask for specific Route
@param {Object[]} sequenceProps Properties for the returned features.
@param {Boolean} isStart Determines if the sequence is the first of the route.
@param {Boolean} isEnd Determines if the sequence is the final of the route.
@returns {array} Features
Getting the Mot - features on specific route . @private @param { Object } viaPoints Route Informations @param { String } mot Ask for specific Route @param { Object [] } sequenceProps Properties for the returned features . @param { Boolean } isStart Determines if the sequence is the first of the route . @param { Boolean } isEnd Determines if the sequence is the final of the route . @returns { array } Features
fetchRouteForMot(viaPoints, mot, sequenceProps, isStart, isEnd) {
    this.abortController = new AbortController();
    const via = viaPoints.map((viaPoint) => {
      if (Array.isArray(viaPoint)) {
        return `${viaPoint[0]},${viaPoint[1]}`;
      }
      return `!${viaPoint}`;
    });
    const urlParams = {
      profile: 'sbb',
      [this.apiKeyName || 'key']: this.apiKey || '',
      via: via.join('|'),
      mot,
    };
    const url = `${this.url}/?${qs.stringify(urlParams)}`;
    const format = new GeoJSON({
      dataProjection: 'EPSG:4326',
      featureProjection: this.projection,
    });
    return fetch(url, { signal: this.abortController.signal })
      .then((res) => res.json())
      .then((data) => {
        const lineStrings = format.readFeatures(data);
        const feature = new Feature({
          geometry: new MultiLineString(
            lineStrings.map((l) => l.getGeometry()),
          ),
        });
        feature.setProperties({
          ...sequenceProps,
          isStart,
          isEnd,
        });
        return feature;
      })
      .catch(() => {
      });
  }
fetchRouteForMot ( viaPoints , mot , sequenceProps , isStart , isEnd ) { this . abortController = new AbortController ( ) ; const via = viaPoints . map ( ( viaPoint ) => { if ( Array . isArray ( viaPoint ) ) { return ` ${ viaPoint [ 0 ] } ${ viaPoint [ 1 ] } ` ; } return ` ${ viaPoint } ` ; } ) ; const urlParams = { profile : 'sbb' , [ this . apiKeyName || 'key' ] : this . apiKey || '' , via : via . join ( '|' ) , mot , } ; const url = ` ${ this . url } ${ qs . stringify ( urlParams ) } ` ; const format = new GeoJSON ( { dataProjection : 'EPSG:4326' , featureProjection : this . projection , } ) ; return fetch ( url , { signal : this . abortController . signal } ) . then ( ( res ) => res . json ( ) ) . then ( ( data ) => { const lineStrings = format . readFeatures ( data ) ; const feature = new Feature ( { geometry : new MultiLineString ( lineStrings . map ( ( l ) => l . getGeometry ( ) ) , ) , } ) ; feature . setProperties ( { ... sequenceProps , isStart , isEnd , } ) ; return feature ; } ) . catch ( ( ) => { } ) ; }
Getting the Mot-features on specific route.
Getting the Mot - features on specific route .
// Ignore failed API requests.