menu

Questions & Answers

PHPCoord, MAMP Pro and Uncaught Error: Class

I am trying to use PHPCoord to eventually convert coordinates stored in the Ordnance Survey National Grid reference system (OSGB) to Latitude and Longitude.

It looks like PHPCoord can do this, but I'm struggling to get it working.

I have successfully installed it within my local project using Composer.

However when I try and run the following example bit of code (taken from the official docs):

use PHPCoord\CoordinateReferenceSystem\Geographic2D;
use PHPCoord\CoordinateReferenceSystem\Projected;
use PHPCoord\GeographicPoint;
use PHPCoord\UnitOfMeasure\Angle\Degree;
$from = GeographicPoint::create(
    Geographic2D::fromSRID(Geographic2D::EPSG_NAD83),
    new Degree(28.46),
    new Degree(-80.53),
    null
);
$toCRS = Projected::fromSRID(Projected::EPSG_NAD83_FLORIDA_EAST);
$to = $from->convert($toCRS); // $to instanceof ProjectedPoint

I get the following errors:

Fatal error: Uncaught Error: Class 'GeographicPoint' not found...

Error: Class 'GeographicPoint' not found

I'm using MAMP Pro and using the MAMP PHP (Version 7.4.12), composer is installed globally and php-coord has installed as expected within the local project in /vendor/php-coord.

Any help would be much appreciated.

Comments:
2023-01-18 23:01:17
Have you included the autoloader?
Answers(0) :