/layer/featureFormats

The featureFormats module exports utility methods to process the response data from layer queries into Openlayers features.

Methods

(inner) cluster(layer, features) → {Array}

The cluster function processes an array of feature data and returns an array of OpenLayers features to be added to the layer source.

It creates Point geometries from coordinate pairs, extracts count and ID information, and assigns additional properties based on the layer's field definitions.

The function also tracks the maximum count across all features in the layer.cluster.max_size property.

Parameters:
NameTypeDescription
layerlayer

A layer object, likely an OpenLayers layer.

featuresArray

An array of feature data, where each feature is represented as an array.

Properties
NameTypeDescription
layer.clusterlayer-cluster

The vector layer cluster configuration.

cluster.max_sizeinteger

The length of features in the largest cluster feature.

layer.paramsObject
Properties
NameTypeDescription
fieldsArray

Array of field names for additional feature properties.

Returns:

Array of OpenLayers Feature objects.

Type: 
Array

(inner) geojson(layer, features) → {array}

The geojson featureFormats method processes an array of wkt features and returns Openlayers features to be added to the layer source.

The geometry of the features will be projected from the layer.srid data projection to the layer.mapview.srid projection for display in the mapview.Map.

The layer.params.fields[] property values will be added to the layer.featureFields field values arrays to be processed by the featureFields.process() method.

Parameters:
NameTypeDescription
layerlayer

A decorated mapp layer object.

featuresarray

An array of WKT features.

Properties
NameTypeDescription
layer.sridstring

Feature data projection.

layer.paramsObject
params.fieldsArray

Array of field names for feature properties.

Returns:

Array of Openlayers features.

Type: 
array

(inner) wkt(layer, features) → {array}

The wkt featureFormats method processes an array of wkt features and returns Openlayers features to be added to the layer source.

The geometry of the features will be projected from the layer.srid data projection to the layer.mapview.srid projection for display in the mapview.Map.

The layer.params.fields[] property values will be added to the layer.featureFields field values arrays to be processed by the featureFields.process() method.

Parameters:
NameTypeDescription
layerlayer

A decorated mapp layer object.

featuresarray

An array of WKT features.

Properties
NameTypeDescription
layer.sridstring

Feature data projection.

layer.paramsObject
params.fieldsArray

Array of field names for feature properties.

Returns:

Array of Openlayers features.

Type: 
array

(inner) wkt_properties(layer, features)

In order to process featureFields for tiled datasets it is required to request the feature properties separate from the vector tile geometries.

The property features do not have a geometry property and the wkt_properties method does not return an array of Openlayers features.

The feature properties are assigned to the layer.featuresObject{} with the feature ID as property key for lookup of the properties in the featureStyle method.

The layer.params.fields[] property values will be added to the layer.featureFields field values arrays to be processed by the featureFields.process() method.

Parameters:
NameTypeDescription
layerlayer

A decorated mapp layer object.

featuresarray

An array of WKT features.

Properties
NameTypeDescription
layer.featuresObjectObject

Store feature properties with the feature ID as property key for lookup in the featureStyle method.

layer.paramsObject
params.fieldsArray

Array of field names for feature properties.

(async, inner) wkth3(layer, features) → {array}

The wkth3 featureFormats method processes an array of wkth3 features and returns Openlayers features to be added to the layer source.

A wkth3 feature is an array with the first entry being the cellid. Subsequent array entries are cell properties required to for the featureStyle render.

The layer.params.fields[] property values will be added to the layer.featureFields field values arrays to be processed by the featureFields.process() method.

An attempt will be made to look up an Openlayers geometry object from the cellGeomMap.

Otherwise the coordinates will be parsed from the cell id with h3js.cellToBoundary() method.

An Openlayers polygon geometry will be created from the parsed coordinates. The geometry object will be stored in the cellGeomMap.

The wkt layer format is recommended for the "wkth3" featureFormat.

The geometry field is required for the request viewport parameter. This is used to limit the data displayed to the current mapview extent.

The "no_geom" flag should be set to not return the geometry with the wkt features.This is as it is not required for rendering the h3 cells.

The "qID" flag should return the h3 cell id from the database table for lookup to find the h3 geometry.

The assignment of properties to the cellGeomMap requires each h3 cell to be unique, thus the qID should return a unique h3 cell id for each feature.

"format": "wkt",
"srid": "4326",
"geom": "geom_4326",
"params": {
  "viewport": true,
  "no_geom": true
},
"featureFormat": "wkth3",
"qID": "h3res9",
Parameters:
NameTypeDescription
layerlayer

A decorated mapp layer object.

featuresarray

An array of wkth3 features.

Properties
NameTypeDescription
layer.sridstring

Feature data projection.

layer.paramsObject
params.fieldsArray

Array of field names for feature properties.

Returns:

Array of Openlayers features.

Type: 
array