diff --git a/mapBuilder/classes/mapBuilderView.listener.php b/mapBuilder/classes/mapBuilderView.listener.php index 5d2c4b4f..18ffa953 100644 --- a/mapBuilder/classes/mapBuilderView.listener.php +++ b/mapBuilder/classes/mapBuilderView.listener.php @@ -21,10 +21,16 @@ function onmainviewGetMaps ($event) { // Get original extent from ini file if set if(array_key_exists('extent', $readConfigPath)){ // Reproject extent in ini file from EPSG:4326 to EPSG:3857. - $proj4 = new Proj4php(); - $sourceProj = new Proj4phpProj('EPSG:4326', $proj4); - $destProj = new Proj4phpProj('EPSG:3857', $proj4); - + if (! class_exists('Proj4phpProj') ) { + // proj4php > 2.0 + $proj4 = new \proj4php\Proj4php(); + $sourceProj = new \proj4php\Proj('EPSG:4326', $proj4); + $destProj = new \proj4php\Proj('EPSG:3857', $proj4); + } else { + $proj4 = new Proj4php(); + $sourceProj = new Proj4Proj('EPSG:4326', $proj4); + $destProj = new Proj4Proj('EPSG:3857', $proj4); + } $extentArraySource = explode(",", $readConfigPath['extent']); // Is extent valid ? @@ -33,9 +39,14 @@ function onmainviewGetMaps ($event) { $extentArraySource = array_map('floatval', $extentArraySource); // Handle WGS84 bounds - $sourceMinPt = new proj4phpPoint( max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06) ); - $sourceMaxPt = new proj4phpPoint( min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06) ); - + if (! class_exists('Proj4phpPoint') ) { + // proj4php >2.0 + $sourceMinPt = new \proj4php\Point(max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06)); + $sourceMaxPt = new \proj4php\Point(min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06)); + } else { + $sourceMinPt = new Proj4phpPoint(max($extentArraySource[0], -180.0), max($extentArraySource[1], -85.06)); + $sourceMaxPt = new Proj4phpPoint(min($extentArraySource[2], 180.0), min($extentArraySource[3], 85.06)); + } try { $destMinPt = $proj4->transform($sourceProj,$destProj,$sourceMinPt); $destMaxPt = $proj4->transform($sourceProj,$destProj,$sourceMaxPt);