function openlayers_get_resolutions in Openlayers 7.2
Same name and namespace in other branches
- 6.2 openlayers.module \openlayers_get_resolutions()
Get resolution given projection
Returns a default set of resolutions for standard TMS, WMS, etc servers serving up common projections. Layers supporting less common projections and resolutions can easily define custom resolutions arrays.
Parameters
$projection: String specifying which projection this should take, like EPSG:900913.
$zoom_start: Integer of first zoom level, default 0.
$zoom_end: Integer of last zoom level, default FALSE.
Return value
Array of resolutions.
11 calls to openlayers_get_resolutions()
- openlayers_behavior_layerzoom::options_form in plugins/
behaviors/ openlayers_behavior_layerzoom.inc - openlayers_layer_type::options_init in ./
openlayers.module - Provides the default options for the layer.
- openlayers_layer_type_geojson::options_init in plugins/
layer_types/ openlayers_layer_type_geojson.inc - Provide initial values for options.
- openlayers_layer_type_gpx::options_init in plugins/
layer_types/ openlayers_layer_type_gpx.inc - Provide initial values for options.
- openlayers_layer_type_kml::options_init in plugins/
layer_types/ openlayers_layer_type_kml.inc - Provide initial values for options.
File
- ./
openlayers.module, line 1152 - Main OpenLayers API File
Code
function openlayers_get_resolutions($projection, $zoom_start = 0, $zoom_end = FALSE) {
// TODO This is conceptually flawed and should not exist. Resolutions depend on the server in use in combination with the tile size.
switch ($projection) {
case 'EPSG:900913':
// 16 zoom levels, taken from
// openlayers.org TMS map
$res = array(
156543.0339,
78271.51695,
39135.758475,
19567.8792375,
9783.939618750001,
4891.969809375,
2445.9849046875,
1222.99245234375,
611.496226171875,
305.7481130859375,
152.87405654296876,
76.43702827148438,
38.21851413574219,
19.109257067871095,
9.554628533935547,
4.777314266967774,
2.388657133483887,
1.1943285667419434,
0.5971642833709717,
0.29858214169740677,
0.14929107084870338,
0.07464553542435169,
);
break;
case 'EPSG:4326':
// 16 zoom levels, taken from
// openlayers.org default WMS map
$res = array(
0.703125,
0.3515625,
0.17578125,
0.087890625,
0.0439453125,
0.02197265625,
0.010986328125,
0.0054931640625,
0.00274658203125,
0.001373291015625,
0.0006866455078125,
0.00034332275390625,
0.000171661376953125,
8.58306884765625E-5,
4.291534423828125E-5,
2.1457672119140625E-5,
1.0728836059570312E-5,
);
break;
default:
$res = array();
break;
}
$length = $zoom_end == FALSE ? NULL : $zoom_end - $zoom_start;
// By default this will not actually clip the array
$resolutions = array_slice($res, $zoom_start, $length);
return $resolutions;
}