From 4411dc268999d3a6b1974f78a174d29ddc2fc4e9 Mon Sep 17 00:00:00 2001 From: rmartin Date: Mon, 14 Nov 2022 14:58:23 +0100 Subject: [PATCH 1/2] change proj4php classname with new class name --- mapBuilder/classes/mapBuilderView.listener.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mapBuilder/classes/mapBuilderView.listener.php b/mapBuilder/classes/mapBuilderView.listener.php index 8ab0dbe8..7a2f0738 100644 --- a/mapBuilder/classes/mapBuilderView.listener.php +++ b/mapBuilder/classes/mapBuilderView.listener.php @@ -21,9 +21,9 @@ 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); + $proj4 = new \proj4php\Proj4php(); + $sourceProj = new \proj4php\Proj('EPSG:4326', $proj4); + $destProj = new \proj4php\Proj('EPSG:3857', $proj4); $extentArraySource = explode(",", $readConfigPath['extent']); @@ -33,8 +33,8 @@ 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) ); + $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)); try { $destMinPt = $proj4->transform($sourceProj,$destProj,$sourceMinPt); From 9373171b73d9c3f6dc90ec2ad86b4b1ae55136b7 Mon Sep 17 00:00:00 2001 From: rmartin Date: Fri, 25 Nov 2022 09:11:11 +0100 Subject: [PATCH 2/2] check if class exists to support Proj4php version --- .../classes/mapBuilderView.listener.php | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/mapBuilder/classes/mapBuilderView.listener.php b/mapBuilder/classes/mapBuilderView.listener.php index 7a2f0738..e045c61c 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\Proj4php(); - $sourceProj = new \proj4php\Proj('EPSG:4326', $proj4); - $destProj = new \proj4php\Proj('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 \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)); - + 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);