_openlayers_get_projections

openlayers/includes/openlayers.form.inc, line 420

Versions
6
_openlayers_get_projections($layers, $seperate_all = FALSE)

Code

<?php
function _openlayers_get_projections($layers, $seperate_all = FALSE){
  $all_projections = array();
  $projection_layers = array();
  $projection_layers['all'] = array();
  foreach ($layers as $layer_key => $layer) {
    if ($layer['projection']){
      foreach ($layer['projection'] as $projection){
        if (!array_key_exists($projection, $projection_layers)){
          $projection_layers[$projection] = array();
        }
        $projection_layers[$projection][] = $layer_key;
        
      }
    }
    else{
      $projection_layers['all'][] = $layer_key;
    }
  }
  
  // Merge all layers that have been marked as 'all' into the list of compatible
  // layers for all projections. Default is to do this.
  if ($seperate_all == FALSE){
    // Add the layers that are compatible with all projections to our $projection_layers array
    foreach ($projection_layers['all'] as $layer_key){
      foreach ($projection_layers as $projection => $list_of_layers){
        if ($projection != 'all'){
          $projection_layers[$projection][] = $layer_key;
        }
      }
    }
    unset($projection_layers['all']);
  }
  
  return $projection_layers;
}
?>