MgGeometry::Buffer() and MgGeometry::Distance() accept a measurement parameter that defines the great circle to be used. If the measurement parameter is null, the calculation is done using a linear algorithm.
Measuring distance in geographic or projected coordinate systems requires great circle calculations. BothMgCoordinateSystemMeasure object, from the MgCoordinateSystem object.
Create the measurement parameter, anMgCoordinateSystem includes two methods, ConvertCoordinateSystemUnitsToMeters() and ConvertMetersToCoordinateSystemUnits() to convert to and from linear distances.
Distance is calculated in the units of the SRS.MgGeometry objects $a and $b, using the coordinate system $srs, perform the following steps:
For example, to calculate the distance between two$measure = new MgCoordinateSystemMeasure($srs);
$distInMapUnits = $a->Distance($b, $measure);
$distInMeters = $srs->ConvertCoordinateSystemUnitsToMeters(
$distInMapUnits);
MgCoordinateSystemMeasure::GetDistance(), as in the following:
Another way to calculate the distance is to use$distInMapUnits = $measure->GetDistance($a, $b);