Sources

As stated in the Structure Overview, the sources section is mandatory. This section always contains one source that describes data format provided by a provider. Currently, data can be provided on tile basis in two formats: GeoJSON and OMV - a format that follows Vector Tile Specification.

As an example, H.service.omv.Provider provides HERE Vector Tile Service data in OMV format, and H.service.traffic.flow.Provider provides HERE Traffic Flow Data in GeoJSON format.

A source section contains the following parameters:

  • type - mandatory parameter that specifies the format provided by the provider. It can be either OMV or GeoJSONTileSource.
  • extra_data - optional parameter that contains any additional data that will be passed to the transform function.
  • transform - optional parameter that allows to process tile data right in the style. This can be either a function:
sources:
  omv:
    type: OMV
    transform: |
      function(data, extraData, tileInfo) {
        if (data.water) {
          for (let i = 0; i < data.water.features.length; i++) {
            data.water.features[i].properties.myProperty1 = 'myValue1';
          }
        }
        return data;
      }

or multiple functions that will sorted by their names and called in corresponding sequence:

sources:
  omv:
    type: OMV
    transform:
      f1: |
        function(data, extraData, tileInfo) {
          if (data.water) {
            for (let i = 0; i < data.water.features.length; i++) {
              data.water.features[i].properties.myProperty1 = 'myValue1';
            }
          }
          return data;
        }
      f2: |
        function(data, extraData, tileInfo) {
          if (data.water) {
            for (let i = 0; i < data.water.features.length; i++) {
              data.water.features[i].properties.myProperty2 = 'myValue2';
            }
          }
          return data;
        }

Each transform function accepts the following arguments:

  1. data - object that contains data from the current tile. This object contains a list of layers (pois, roads, etc.), where each layer is a GeoJSON FeatureCollection. Some providers (for example, H.service.traffic.flow.Provider) provide only one GeoJSON FeatureCollection per tile, in such cases this GeoJSON FeatureCollection will be passed as a data instead list of layers.
  2. extraData - content of the extra_data optional parameter defined in the source section.
  3. tileInfo - object that contains information about the current tile, for example tile coordinates. Each transform function must return the modified version of the data parameter.

results matching ""

    No results matching ""