示例#1
0
  /**
   * 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());
  }