summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-14 09:51:41 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-14 09:51:41 +0100
commit72119ef864e1a5ffa377a504dc2ef430d7e6cd4a (patch)
tree24a4b9539cf4f4b8116bd38d3444001843cb8e45 /lib
parent72312119fe678d14b61e3c508db98a6dd0ee4ec0 (diff)
downloadcontact-72119ef864e1a5ffa377a504dc2ef430d7e6cd4a.tar.gz
contact-72119ef864e1a5ffa377a504dc2ef430d7e6cd4a.tar.bz2
contact-72119ef864e1a5ffa377a504dc2ef430d7e6cd4a.zip
php-cs-fixer tidies to php8.5 standards
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/phpcoord-2.3.php35
-rwxr-xr-xlib/test-2.3.php89
2 files changed, 51 insertions, 73 deletions
diff --git a/lib/phpcoord-2.3.php b/lib/phpcoord-2.3.php
index ae5b4d6..b158963 100755
--- a/lib/phpcoord-2.3.php
+++ b/lib/phpcoord-2.3.php
@@ -26,7 +26,6 @@
// - Initial version
//--------------------------------------------------------------------------
-
// ================================================================== LatLng
class LatLng {
@@ -34,7 +33,6 @@ class LatLng {
public $lat;
public $lng;
-
/**
* Create a new LatLng object from the given latitude and longitude
*
@@ -46,7 +44,6 @@ class LatLng {
$this->lng = $lng;
}
-
/**
* Return a string representation of this LatLng object
*
@@ -56,7 +53,6 @@ class LatLng {
return "({$this->lat}, {$this->lng})";
}
-
/**
* Calculate the surface distance between this LatLng object and the one
* passed in as a parameter.
@@ -81,11 +77,10 @@ class LatLng {
$z2 = $er * cos($latTo);
$d = acos(sin($latFrom)*sin($latTo) + cos($latFrom)*cos($latTo)*cos($lngTo-$lngFrom)) * $er;
-
+
return $d;
}
-
/**
* Convert this LatLng object from OSGB36 datum to WGS84 datum.
*/
@@ -129,12 +124,11 @@ class LatLng {
}
$phiB = rad2deg($phiN);
-
+
$this->lat = $phiB;
$this->lng = $lambdaB;
}
-
/**
* Convert this LatLng object from WGS84 datum to OSGB36 datum.
*/
@@ -178,7 +172,7 @@ class LatLng {
}
$phiB = rad2deg($phiN);
-
+
$this->lat = $phiB;
$this->lng = $lambdaB;
}
@@ -261,7 +255,6 @@ class LatLng {
return $osref->toString();
}
-
/**
* Convert a latitude and longitude to an UTM reference
*
@@ -360,7 +353,6 @@ class LatLng {
}
}
-
// =================================================================== OSRef
// References given with OSRef are accurate to 1m.
@@ -369,7 +361,6 @@ class OSRef {
public $easting;
public $northing;
-
/**
* Create a new OSRef object representing an OSGB grid reference. Note
* that the parameters for this constructor require eastings and
@@ -391,7 +382,6 @@ class OSRef {
$this->northing = $northing;
}
-
/**
* Convert this grid reference into a string showing the exact values
* of the easting and northing.
@@ -402,7 +392,6 @@ class OSRef {
return "({$this->easting}, {$this->northing})";
}
-
/**
* Convert this grid reference into a string using a standard six-figure
* grid reference including the two-character designation for the 100km
@@ -414,8 +403,8 @@ class OSRef {
$hundredkmE = floor($this->easting / 100000);
$hundredkmN = floor($this->northing / 100000);
$firstLetter = "";
- $firstLetter = $hundredkmN < 5
- ? ( $hundredkmE < 5 ? "S" : "T" )
+ $firstLetter = $hundredkmN < 5
+ ? ( $hundredkmE < 5 ? "S" : "T" )
: ( $hundredkmN < 10 ? ( $hundredkmE < 5 ? "N" : "O" ) : "H" );
$secondLetter = "";
@@ -430,7 +419,6 @@ class OSRef {
return sprintf("%s%s%03d%03d", $firstLetter, $secondLetter, $e, $n);
}
-
/**
* Convert this grid reference into a latitude and longitude
*
@@ -522,7 +510,6 @@ class OSRef {
}
}
-
// ================================================================== UTMRef
class UTMRef {
@@ -532,7 +519,6 @@ class UTMRef {
public $latZone;
public $lngZone;
-
/**
* Create a new object representing a UTM reference.
*
@@ -548,7 +534,6 @@ class UTMRef {
$this->lngZone = $lngZone;
}
-
/**
* Return a string representation of this UTM reference
*
@@ -558,7 +543,6 @@ class UTMRef {
return "{$this->lngZone}{$this->latZone} {$this->easting} {$this->northing}";
}
-
/**
* Convert this UTM reference to a latitude and longitude
*
@@ -611,7 +595,7 @@ class UTMRef {
* (1.0 - $eSquared)
/ pow(
1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad),
- 1.5);
+ 1.5, );
$d = $x / ($n * $UTM_F0);
$latitude = (
@@ -649,10 +633,9 @@ class UTMRef {
$latlog = new LatLng($latitude, $longitude);
return $latlog->toString();
- }
+ }
}
-
// ================================================================== RefEll
class RefEll {
@@ -661,7 +644,6 @@ class UTMRef {
public $min;
public $ecc;
-
/**
* Create a new RefEll object to represent a reference ellipsoid
*
@@ -675,7 +657,6 @@ class UTMRef {
}
}
-
// ================================================== Mathematical Functions
function sinSquared($x) {
@@ -694,7 +675,6 @@ function sec($x) {
return 1.0 / cos($x);
}
-
/**
* Take a string formatted as a six-figure OS grid reference (e.g.
* "TG514131") and return a reference to an OSRef object that represents
@@ -734,7 +714,6 @@ function getOSRefFromSixFigureReference($ref) {
return $osref->toString();
}
-
/**
* Work out the UTM latitude zone from the latitude
*
diff --git a/lib/test-2.3.php b/lib/test-2.3.php
index c9edc8b..87f6ac9 100755
--- a/lib/test-2.3.php
+++ b/lib/test-2.3.php
@@ -17,7 +17,6 @@
// - Added OSGB36/WGS84 data conversions
// 1.0 - 11 Aug 2005 // - Initial version //--------------------------------------------------------------------------
-
require_once("phpcoord-2.3.php");
?>
@@ -46,13 +45,13 @@ $d = $lld1->distance($lld2);
echo "Surface Distance between New York and London: " . $d . "km";</pre>
<?php
- $lld1 = new LatLng(40.718119, -73.995667); // New York
- echo "New York Lat/Long: " . $lld1->toString() . "<br />";
- $lld2 = new LatLng(51.499981, -0.125313); // London
- echo "London Lat/Long: " . $lld2->toString() . "<br />";
- $d = $lld1->distance($lld2);
- echo "Surface Distance between New York and London: " . $d . "km";
- ?>
+ $lld1 = new LatLng(40.718119, -73.995667); // New York
+ echo "New York Lat/Long: " . $lld1->toString() . "<br />";
+ $lld2 = new LatLng(51.499981, -0.125313); // London
+ echo "London Lat/Long: " . $lld2->toString() . "<br />";
+ $d = $lld1->distance($lld2);
+ echo "Surface Distance between New York and London: " . $d . "km";
+ ?>
</p>
<h2>Convert OS Grid Reference to Latitude/Longitude</h2>
@@ -72,11 +71,11 @@ $ll1 = $os1->toLatLng();
echo "Converted to Lat/Long: " . $ll1->toString();</pre>
<?php
- $os1 = new OSRef(651409.903, 313177.270);
- echo "OS Grid Reference: " . $os1->toString() . " - " . $os1->toSixFigureString() . "<br />";
- $ll1 = $os1->toLatLng();
- echo "Converted to Lat/Long: " . $ll1->toString();
- ?>
+ $os1 = new OSRef(651409.903, 313177.270);
+ echo "OS Grid Reference: " . $os1->toString() . " - " . $os1->toSixFigureString() . "<br />";
+ $ll1 = $os1->toLatLng();
+ echo "Converted to Lat/Long: " . $ll1->toString();
+ ?>
</p>
<p>
@@ -89,12 +88,12 @@ $l1w->OSGB36ToWGS84();
echo "Converted to Lat/Long: " . $ll1w->toString();</pre>
<?php
- $os1w = new OSRef(651409.903, 313177.270);
- echo "OS Grid Reference: " . $os1w->toString() . " - " . $os1w->toSixFigureString() . "<br />";
- $ll1w = $os1w->toLatLng();
- $ll1w->OSGB36ToWGS84();
- echo "Converted to Lat/Long: " . $ll1w->toString();
- ?>
+ $os1w = new OSRef(651409.903, 313177.270);
+ echo "OS Grid Reference: " . $os1w->toString() . " - " . $os1w->toSixFigureString() . "<br />";
+ $ll1w = $os1w->toLatLng();
+ $ll1w->OSGB36ToWGS84();
+ echo "Converted to Lat/Long: " . $ll1w->toString();
+ ?>
</p>
<h2>Convert Latitude/Longitude to OS Grid Reference</h2>
@@ -114,11 +113,11 @@ $os2 = $ll2->toOSRef();
echo "Converted to OS Grid Ref: " . $os2->toString() . " - " . $os2->toSixFigureString();</pre>
<?php
- $ll2 = new LatLng(52.657570301933, 1.7179215806451);
- echo "Latitude/Longitude: " . $ll2->toString() . "<br />";
- $os2 = $ll2->toOSRef();
- echo "Converted to OS Grid Ref: " . $os2->toString() . " - " . $os2->toSixFigureString();
- ?>
+ $ll2 = new LatLng(52.657570301933, 1.7179215806451);
+ echo "Latitude/Longitude: " . $ll2->toString() . "<br />";
+ $os2 = $ll2->toOSRef();
+ echo "Converted to OS Grid Ref: " . $os2->toString() . " - " . $os2->toSixFigureString();
+ ?>
</p>
<p>
@@ -131,12 +130,12 @@ $os2w = $ll2w->toOSRef();
echo "Converted to OS Grid Ref: " . $os2w->toString() . " - " . $os2w->toSixFigureString();</pre>
<?php
- $ll2w = new LatLng(52.657570301933, 1.7179215806451);
- echo "Latitude/Longitude: " . $ll2->toString() . "<br />";
- $ll2w->WGS84ToOSGB36();
- $os2w = $ll2w->toOSRef();
- echo "Converted to OS Grid Ref: " . $os2w->toString() . " - " . $os2w->toSixFigureString();
- ?>
+ $ll2w = new LatLng(52.657570301933, 1.7179215806451);
+ echo "Latitude/Longitude: " . $ll2->toString() . "<br />";
+ $ll2w->WGS84ToOSGB36();
+ $os2w = $ll2w->toOSRef();
+ echo "Converted to OS Grid Ref: " . $os2w->toString() . " - " . $os2w->toSixFigureString();
+ ?>
</p>
<h2>Convert Six-Figure OS Grid Reference String to an OSRef Object</h2>
@@ -150,11 +149,11 @@ $os6x = getOSRefFromSixFigureReference($os6);
echo "Converted to OS Grid Ref: " . $os6x->toString() . " - " . $os6x->toSixFigureString();</pre>
<?php
- $os6 = "TG514131";
- echo "Six figure string: " . $os6 . "<br />";
- $os6x = getOSRefFromSixFigureReference($os6);
- echo "Converted to OS Grid Ref: " . $os6x->toString() . " - " . $os6x->toSixFigureString();
- ?>
+ $os6 = "TG514131";
+ echo "Six figure string: " . $os6 . "<br />";
+ $os6x = getOSRefFromSixFigureReference($os6);
+ echo "Converted to OS Grid Ref: " . $os6x->toString() . " - " . $os6x->toSixFigureString();
+ ?>
</p>
<h2>Convert UTM Reference to Latitude/Longitude</h2>
@@ -166,11 +165,11 @@ $ll3 = $utm1->toLatLng();
echo "Converted to Lat/Long: " . $ll3->toString();</pre>
<?php
- $utm1 = new UTMRef(456463.99, 3335334.05, "E", 12);
- echo "UTM Reference: " . $utm1->toString() . "<br />";
- $ll3 = $utm1->toLatLng();
- echo "Converted to Lat/Long: " . $ll3->toString();
- ?>
+ $utm1 = new UTMRef(456463.99, 3335334.05, "E", 12);
+ echo "UTM Reference: " . $utm1->toString() . "<br />";
+ $ll3 = $utm1->toLatLng();
+ echo "Converted to Lat/Long: " . $ll3->toString();
+ ?>
</p>
<h2>Convert Latitude/Longitude to UTM Reference</h2>
@@ -182,11 +181,11 @@ $utm2 = $ll4->toUTMRef();
echo "Converted to UTM Ref: " . $utm2->toString() ;</pre>
<?php
- $ll4 = new LatLng(-60.1167, -111.7833);
- echo "Latitude/Longitude: " . $ll4->toString() . "<br />";
- $utm2 = $ll4->toUTMRef();
- echo "Converted to UTM Ref: " . $utm2->toString() ;
- ?>
+ $ll4 = new LatLng(-60.1167, -111.7833);
+ echo "Latitude/Longitude: " . $ll4->toString() . "<br />";
+ $utm2 = $ll4->toUTMRef();
+ echo "Converted to UTM Ref: " . $utm2->toString() ;
+ ?>
</p>
<p>