Create a vector source based on a
Mapbox GL styles definition.

@param {Object} glSource A Mapbox GL styles defintiion of the source.
@param {Object} mapView The OpenLayers map view.
@param {string} baseUrl The mapbox base url.
@param {boolean} wrapX Should we wrap the world?
@param {Object} fetchOptions Options to use for fetch calls.

@returns {Object} ol.source.vector instance.
function configureGeojsonSource(glSource, mapView, baseUrl, wrapX, fetchOptions) {
  const use_bbox = (typeof glSource.data === 'string' && glSource.data.indexOf(BBOX_STRING) >= 0);
  const vector_src = new VectorSource({
    strategy: use_bbox ? bboxStrategy : allStrategy,
    loader: getLoaderFunction(glSource, mapView.getProjection(), baseUrl, fetchOptions),
    useSpatialIndex: true,
    wrapX: wrapX,
  });

  // GeoJson sources can be clustered but OpenLayers
  // uses a special source type for that. This handles the
  // "switch" of source-class.
  let new_src = vector_src;
  if (glSource.cluster) {
    new_src = new ClusterSource({
      source: vector_src,
      // default the distance to 50 as that's what
      //  is specified by Mapbox.
      distance: glSource.clusterRadius ? glSource.clusterRadius : 50,
    });
  }

  // seed the vector source with the first update
  //  before returning it.
  updateGeojsonSource(new_src, glSource, mapView, baseUrl, fetchOptions);
  return new_src;
}