From fcd7cac6d9a6a7e7bb34a07b9237c6ce3755efe6 Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 15 Oct 2024 17:00:33 +0300 Subject: [PATCH] fixed php compatibility issues --- src/Mgrs/LatLong.php | 2 +- src/Mgrs/Mgrs.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Mgrs/LatLong.php b/src/Mgrs/LatLong.php index baca59c..7a878f2 100644 --- a/src/Mgrs/LatLong.php +++ b/src/Mgrs/LatLong.php @@ -36,7 +36,7 @@ public function normalizeLatitude($latitude) { */ public function normalizeLongitude($longitude) { - if (180 === $longitude % 360) { + if (180 === fmod($longitude, 360)) { return 180.0; } diff --git a/src/Mgrs/Mgrs.php b/src/Mgrs/Mgrs.php index a4dc23e..573d4bf 100644 --- a/src/Mgrs/Mgrs.php +++ b/src/Mgrs/Mgrs.php @@ -157,7 +157,7 @@ public function toGridReference($template = null, $accuracy = null) { $seasting = (string)$this->getEasting(); $snorthing = (string)$this->getNorthing(); - + $fields = array( // The zone number. '%z' => $this->getZoneNumber(), @@ -477,7 +477,7 @@ public static function fromGridReference($mgrs_reference) { $northing, $easting, $zone_number, - $zone_letter + $zone_letter, ); // Set the accuracy according to the number of digits found. @@ -502,11 +502,11 @@ public static function fromGridReference($mgrs_reference) { protected static function getEastingFromChar($e, $set) { // colOrigin is the letter at the origin of the set for the column. - $curCol = substr(static::SET_ORIGIN_COLUMN_LETTERS, $set - 1, 1); + $curCol = ord(substr(static::SET_ORIGIN_COLUMN_LETTERS, $set - 1, 1)); $eastingValue = 100000.0; $rewindMarker = false; - while ($curCol !== substr($e, 0, 1)) { + while ($curCol !== ord(substr($e, 0, 1))) { $curCol++; if ($curCol === static::I) { @@ -551,7 +551,7 @@ protected static function getEastingFromChar($e, $set) { * @todo Better name: use "letter" rather than "char" and show this is just the second letter. */ - protected function getNorthingFromChar($n, $set) { + protected static function getNorthingFromChar($n, $set) { if ($n > 'V') { throw new \Exception("MGRSPoint given invalid Northing " . $n); }