/** * Create a set of UPS coordinates for the given <code>Globe</code>. * * @param hemisphere the hemisphere, either {@link gov.nasa.worldwind.avlist.AVKey#NORTH} or {@link * gov.nasa.worldwind.avlist.AVKey#SOUTH}. * @param easting the easting distance in meters * @param northing the northing distance in meters. * @param globe the <code>Globe</code> - can be null (will use WGS84). * * @return the corresponding <code>UPSCoord</code>. * * @throws ArgumentException if the conversion to UPS coordinates fails. */ public static UPSCoord FromUPS(string hemisphere, double easting, double northing) { UPSCoordConverter converter = new UPSCoordConverter(); long err = converter.ConvertUPSToGeodetic(hemisphere, easting, northing); if (err != UTMCoordConverter.UTM_NO_ERROR) { throw new ArgumentException("UTM Conversion Error"); } return new UPSCoord(Angle.FromRadians(converter.Latitude), Angle.FromRadians(converter.Longitude), hemisphere, easting, northing); }
/** * Create a set of UPS coordinates from a pair of latitude and longitude for the given <code>Globe</code>. * * @param latitude the latitude <code>Angle</code>. * @param longitude the longitude <code>Angle</code>. * @param globe the <code>Globe</code> - can be null (will use WGS84). * * @return the corresponding <code>UPSCoord</code>. * * @throws IllegalArgumentException if <code>latitude</code> or <code>longitude</code> is null, or the conversion to * UPS coordinates fails. */ public static UPSCoord FromLatLon(Angle latitude, Angle longitude) { if (latitude == null || longitude == null) { throw new ArgumentException("Latitude Or Longitude Is Null"); } UPSCoordConverter converter = new UPSCoordConverter(); long err = converter.ConvertGeodeticToUPS(latitude.radians, longitude.radians); if (err != UPSCoordConverter.UPS_NO_ERROR) { throw new ArgumentException("UPS Conversion Error"); } return new UPSCoord(latitude, longitude, converter.Hemisphere, converter.Easting, converter.Northing); }