AutoCAD Map 3D 2009 Geospatial Platform Reference

AutoCAD Map 3D Geospatial Platform API

virtual double MgCoordinateSystemMeasure::GetAzimuth ( MgCoordinate coord1,
MgCoordinate coord2 
) [pure virtual]

Computes the angle with respect to north of a vector formed by two coordinates.

Remarks:
A positive angle represents a measurement from north in a clockwise direction towards the vector. A negative angle represents a measurement from north in a counterclockwise direction towards the vector.
.NET Syntax
virtual double GetAzimuth(MgCoordinate coord1, MgCoordinate coord2);
Java Syntax
virtual double GetAzimuth(MgCoordinate coord1, MgCoordinate coord2);
PHP Syntax
virtual double GetAzimuth(MgCoordinate coord1, MgCoordinate coord2);

Parameters:
coord1 (MgCoordinate) An MgCoordinate in coordinate system units that specifies the first coordinate.
coord2 (MgCoordinate) An MgCoordinate in coordinate system units that specifies the second coordinate.
Returns:
Returns the azimuth (Angle with respect to North) of the vector formed by coord1 and coord2.
Example (PHP) $coord1 is New York City, and $coord2 is Boston, Massachusetts. $azimuth12 is 58.507421025167, and $azimuth21 = -119.00856518347.
 $geometryFactory = new MgGeometryFactory();
 $coord1 = $geometryFactory->CreateCoordinateXY(-74.806394, 40.714169);
 $coord2 = $geometryFactory->CreateCoordinateXY(-71.061342, 42.355892);
 $azimuth12 = $coordSysMeasure->GetAzimuth($coord1, $coord2);
 $azimuth21 = $coordSysMeasure->GetAzimuth($coord2, $coord1);

Example (C#)
 using OSGeo.MapGuide;
 private MgCoordinateSystemMeasure geogCSMeasure;
 private MgGeometryFactory geometryFactory;
 private MgCoordinate geogCSXYCoord;
 private MgCoordinate geogCSX1Y1Coord;
 private double geogCSX = -160.101421317;
 private double geogCSY = 22.0234263273;
 private double geogCSX1 = -159.721535121256;
 private double geogCSY1 = 24.0028259520524;
 private double geogCSAzimuth = 10.0;
 private double azimuth;
 private double tolerance = 0.001;
 private Boolean isEquivalent;

 geometryFactory = new MgGeometryFactory();
 geogCSXYCoord = geometryFactory.CreateCoordinateXY(geogCSX, geogCSY);
 geogCSX1Y1Coord = geometryFactory.CreateCoordinateXY(geogCSX1, geogCSY1);
 azimuth = geogCSMeasure.GetAzimuth(geogCSXYCoord, geogCSX1Y1Coord);
 // azimuth has the value of geogCSAzimuth
 isEquivalent = Math.Abs(azimuth - geogCSAzimuth) < tolerance;

Exceptions:
MgCoordinateSystemMeasureFailedException 

Implements MgMeasure.