- Notifications
You must be signed in to change notification settings - Fork 3
Home
Jason Mathews edited this page May 7, 2014 · 1 revision
'''geodesy''' provides the core geospatial representations used in opensextant project which include points, ellipses, arcs, bounding boxes, etc. most of which support an elevation component.
// 1. create some points // create point using Degrees, minutes, seconds Geodetic2DPoint a = new Geodetic2DPoint( new Longitude(-71, 3, 49), new Latitude(42, 21, 29)); // Boston, MA // create point using decimal degrees Geodetic2DPoint b = new Geodetic2DPoint( new Longitude(new Angle(-74.0059, Angle.DEGREES)), new Latitude(new Angle(40.7127, Angle.DEGREES))); // New York, NY // 2. calculate distance between two points Geodetic2DArc arc = new Geodetic2DArc(b, a); double dist = arc.getDistanceInMeters() / 1000.0; System.out.printf("Distance btwn Boston -> New York is %,.0f km (%.0f miles) azimuth=%.1f degrees%n", dist, dist * 0.621371, arc.getForwardAzimuth().inDegrees()); // outputs: Distance btwn Boston -> New York is 306 km (190 miles) azimuth=52.4 degrees // 3. create bounding box Geodetic2DBounds bbox = new Geodetic2DBounds(b, a); dist = bbox.getDiagonal() / 1000.0; System.out.printf("Distance as diagonal length in bounding box is %,.0f km (%,.0f miles)%n", dist, dist *0.621371 ); // outputs: Distance as diagonal length in bounding box is 306 km (190 miles) assert(bbox.contains(a)); assert(bbox.contains(b)); System.out.println("Center btwn Boston and New York is at " + bbox.getCenter()); // East Hampton, CT // outputs: Center btwn Boston and New York is at (72°32' 5" W, 41°32' 7" N)