Saturday, February 11, 2017

Introducing JWindRose

Update JWindRose has been changed to JCompassRose.

JWindRose is a Java utility class that determines compass rose points for 4, 8, 16 and 32 point windroses from a given (or generated) true heading (relative bearing).  Note that this is true heading and not magnetic heading.
Traveling from Ocean City, NJ to New Orleans, LA
Relative Bearing:       238 degrees
4-point compass point:  West
8-point compass point:  Southwest
16-point compass point: West-southwest
32-point compass point: Southwest by west




You simply provide the utility class two locations as strings, or your specific latitude and longitude coordinates as well as the orientation identifier (set of points) of your desired windrose... and 'voila', your compass rose point is established.

For example here (again) is the output and source code for determining the compass points between Ocean City, NJ and New Orleans, LA.


Traveling from Ocean City, NJ to New Orleans, LA
Relative Bearing:       238 degrees
4-point compass point:  West
8-point compass point:  Southwest
16-point compass point: West-southwest
32-point compass point: Southwest by west
public class WindroseTester {

    public static void main(String[] args) {

        String currentLocation = "Ocean City, NJ";
        String targetLocation  = "New Orleans, LA";
        Float[] location1 = WindroseUtils.performGeoCoding(currentLocation);
        Float[] location2 = WindroseUtils.performGeoCoding(targetLocation);

        System.out.println("Traveling from "+ currentLocation + " to " + targetLocation);

        System.out.println("True Bearing/Heading:   " + WindroseUtils.queryWindRose(location1[0], location1[1], location2[0], location2[1]) + " degrees");
        System.out.println("4-point compass point:  " + WindroseUtils.queryWindRose(WindrosePoints.FOUR, location1[0], location1[1], location2[0], location2[1]));
        System.out.println("8-point compass point:  " + WindroseUtils.queryWindRose(WindrosePoints.EIGHT, location1[0], location1[1], location2[0], location2[1]));
        System.out.println("16-point compass point: " + WindroseUtils.queryWindRose(WindrosePoints.SIXTEEN, location1[0], location1[1], location2[0], location2[1]));
        System.out.println("32-point compass point: " + WindroseUtils.queryWindRose(WindrosePoints.THIRTY_TWO, location1[0], location1[1], location2[0], location2[1]));

    }
}

No comments:

Post a Comment

Landing Spicoli in the Wind

Many know by now that I have three Blade 200 S RC helicopters in my fleet: Speck - for training Spot - for maintenance exercises Spicol...