Quintiq file version 2.0
|
#parent: #root
|
Function CalcATCFDistance
|
{
|
TextBody:
|
[*
|
// tyg2 Mar-31-2016 (created)
|
|
/*
|
see http://mathworld.wolfram.com/GreatCircle.html
|
*/
|
value := 0.0;
|
|
earthRadius := 6378
|
|
orileg := guard( this.AsOriginStockingPointLeg().StockingPoint_MP().GIS_StockingPointAddress().GIS_StockingPointGeocodeResult().Selected(), null( LibGIS_GeocodedAddress ) );
|
destleg := guard( this.AsDestinationStockingPointLeg().StockingPoint_MP().GIS_StockingPointAddress().GIS_StockingPointGeocodeResult().Selected(), null( LibGIS_GeocodedAddress ) );
|
|
if( not ( isnull( orileg ) or isnull( destleg ) ) )
|
{
|
|
unitlat := pi * orileg.Y() / 180.0
|
unitlong := pi * orileg.X() / 180.0
|
splat := pi * destleg.Y() / 180.0
|
splong := pi * destleg.X() / 180.0
|
|
theCos := cos( splat ) * cos( unitlat )* cos( splong - unitlong ) + sin( splat ) * sin ( unitlat )
|
|
// round-off errors.
|
// M AF Putting the 1.0 as the first parameter causes trouble, submited rfc
|
theCos := maxvalue( theCos, -1.0 )
|
theCos := minvalue( theCos, 1.0 )
|
|
angle := acos( theCos )
|
|
value := angle * earthRadius;
|
}
|
|
this.ATCFDistance( value );
|
*]
|
}
|