function openlayers_views_style_data::coalesce_groups in Openlayers 7.2
Coalesce features into single grouped feature when grouping is enabled.
openlayers_views_style_data specific
1 call to openlayers_views_style_data::coalesce_groups()
- openlayers_views_style_data::map_features in modules/
openlayers_views/ views/ openlayers_views_style_data.inc
File
- modules/
openlayers_views/ views/ openlayers_views_style_data.inc, line 384 - This file holds style plugin for OpenLayers Views
Class
- openlayers_views_style_data
- @class Extension of the Views Plugin Style for OpenLayers
Code
function coalesce_groups($features, $handlers, $ds) {
// Combine wkt into geometry collections if they are an array
foreach ($features as &$feature) {
if (is_array($feature['wkt'])) {
if (count($feature['wkt']) > 1) {
$feature['wkt'] = $this
->get_group_wkt($feature['wkt']);
}
else {
$feature['wkt'] = $feature['wkt'][0];
}
}
}
// Process title and description for groups
foreach ($features as $k => &$feature) {
$feature['attributes']['name'] = $k;
$feature['attributes'] = array_merge($feature['attributes'], $feature['features'][0]['attributes']);
$formatted_features = array();
foreach ($feature['features'] as $subfeature) {
// Create name and description attributes. Note that there are a
// couple exceptions to using fields.
$exceptions = array(
'#row',
);
// Run the output through a theme.
$formatted_features[] = theme('openlayers_views_group_display_item', array(
'name' => isset($handlers[$ds['name_field']]) ? $subfeature['attributes'][$ds['name_field']] : FALSE,
'description' => in_array($ds['description_field'], $exceptions) || isset($handlers[$ds['description_field']]) ? $subfeature['attributes'][$ds['description_field']] : FALSE,
));
// Remove rendered rows to keep data size down for JS.
if (in_array($ds['description_field'], $exceptions)) {
unset($subfeature['attributes'][$ds['description_field']]);
}
}
// Then run all gathered features through item_ist theme.
$feature['attributes']['description'] = theme('item_list', array(
'items' => $formatted_features,
));
}
return $features;
}