How to calculate rhumb line distance


Summary This topic shows how to determine the rhumb line distance between two points using IMeasurementTool. A rhumb line, also known as a loxodrome, is defined as a line of constant azimuth as measured on a spheroid. Since the lines are spheroid-aware, the distance and azimuth are dependent on the spatial reference of the line.

Many of the ArcGIS Military Analyst and MOLE extension application programming interface (API) objects you have used in the past have equivalent or near equivalent objects in the ArcGIS 10 ArcObjects API. These new objects should now be used and do not require a Military Analyst extension or MOLE extension license. See Migrating from Military Analyst and MOLE for information on how to accomplish tasks in ArcGIS 10 that previously required the Military Analyst and MOLE APIs.
Instructions:
  1. Import the defensesolutions package.
  2. Copy and paste the function code into your project.
  3. Call the function from your code.
[Java]
public static void calcRhumblineDist(){
    try{
        // Define the spatial reference of the rhumb line.
        ISpatialReferenceFactory2 spatRefFact = new SpatialReferenceEnvironment();
        ISpatialReference spatRef = spatRefFact.createSpatialReference
            (esriSRGeoCSType.esriSRGeoCS_WGS1984);

        // Define the points to be used as the start and end points of the rhumb line.
        IPoint start = new Point();
        IPoint end = new Point();
        start.putCoords( - 116, 33);
        end.putCoords(25, 61);

        // These properties include the line type, which is a rhumb line in this case, and the 
        // spatial reference of the line.
        IMeasurementTool mTool = new MeasurementTool();
        mTool.setSpecialGeolineType(cjmtkSGType.cjmtkSGTRhumbLine);
        mTool.setSpecialSpatialReferenceByRef(spatRef);

        // Determine the distance and azimuth of the rhumb line based on the 
        // start and end point coordinates.
        mTool.constructByPoints(start, end);
        System.out.println("Distance = " + mTool.getDistance() + " meters");
        System.out.println("Azimuth = " + mTool.getAngle() + " degrees");
    }
    catch (Exception ex){
        ex.printStackTrace();
    }
}


See Also:

Defense Solutions Library Reference - Creating geodetically correct geometric objects




Development licensing Deployment licensing
Engine Developer Kit: Military Analyst Engine Runtime: Military Analyst