/** * 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 IllegalArgumentException if the conversion to UPS coordinates fails. */ public static UPSCoord fromUPS(String hemisphere, double easting, double northing, Globe globe) { final UPSCoordConverter converter = new UPSCoordConverter(globe); long err = converter.convertUPSToGeodetic(hemisphere, easting, northing); if (err != UTMCoordConverter.UTM_NO_ERROR) { String message = Logging.getMessage("Coord.UTMConversionError"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } return new UPSCoord( Angle.fromRadians(converter.getLatitude()), Angle.fromRadians(converter.getLongitude()), 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, Globe globe) { if (latitude == null || longitude == null) { String message = Logging.getMessage("nullValue.LatitudeOrLongitudeIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } final UPSCoordConverter converter = new UPSCoordConverter(globe); long err = converter.convertGeodeticToUPS(latitude.radians, longitude.radians); if (err != UPSCoordConverter.UPS_NO_ERROR) { String message = Logging.getMessage("Coord.UPSConversionError"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } return new UPSCoord( latitude, longitude, converter.getHemisphere(), converter.getEasting(), converter.getNorthing()); }