function openlayers_update_7207 in Openlayers 7.2
Migrate configured projections so that other projections than those of EPSG can be used, too.
File
- ./
openlayers.install, line 503 - This file holds the functions for the installing and enabling of the openlayers module.
Code
function openlayers_update_7207() {
openlayers_update_create_projection_table();
// Migrate stored layers
foreach (openlayers_layers_load(TRUE) as $key => $layer) {
$projections = array();
// Takeover srs key that no longer exists and migrate it to a projection
if ($layer instanceof openlayers_layer_type_wms && array_key_exists('srs', $layer->data['options']) && !in_array($layer->data['options']['srs'], $layer->data['projection'])) {
$projections[] = $layer->data['options']['srs'];
}
unset($layer->data['options']['srs']);
foreach ($layer->data['projection'] as $projection) {
if (is_string($projection)) {
$projections[] = $projection;
}
else {
throw new DrupalUpdateException("Unsupported projection type encountered in layer " . $key);
}
}
$layer->data['projection'] = $projections;
ctools_export_crud_save('openlayers_layers', $layer);
}
// The code for the projection changed but its semantics stayed.
// Only update the display projection as servers might be in use that don't yet support the new code.
foreach (openlayers_maps(TRUE) as $key => $map) {
if ($map->data['displayProjection'] === 'EPSG:900913') {
$map->data['displayProjection'] = 'EPSG:3857';
}
ctools_export_crud_save('openlayers_maps', $map);
}
}