Java Code Examples for gov.nasa.worldwind.avlist.AVKey#SOUTH

The following examples show how to use gov.nasa.worldwind.avlist.AVKey#SOUTH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoordinatesParser.java    From trekarta with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
private static GeoPoint parseUtmTokens(List<Token> tokens) throws IllegalArgumentException {
    int zone = 0;
    String hemisphere = null;
    double easting = Double.NaN;
    double northing = Double.NaN;
    for (Token token : tokens) {
        if (token.t == Type.UTM_ZONE) {
            zone = Integer.valueOf(token.c.substring(0, token.c.length() - 1));
            hemisphere = token.c.substring(token.c.length() - 1, token.c.length());
            if ("N".equals(hemisphere))
                hemisphere = AVKey.NORTH;
            if ("S".equals(hemisphere))
                hemisphere = AVKey.SOUTH;
        }
        if (token.t == Type.UTM_EASTING) {
            easting = Double.valueOf(token.c);
        }
        if (token.t == Type.UTM_NORTHING) {
            northing = Double.valueOf(token.c);
        }
    }
    if (zone == 0 || Double.isNaN(easting) || Double.isNaN(northing))
        throw new IllegalArgumentException("Wrong UTM coordinates format");

    UTMCoord coord = UTMCoord.fromUTM(zone, hemisphere, easting, northing);
    return new GeoPoint(coord.getLatitude().degrees, coord.getLongitude().degrees);
}
 
Example 2
Source File: UPSCoordConverter.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * The function convertGeodeticToUPS converts geodetic (latitude and longitude) coordinates to UPS (hemisphere,
 * easting, and northing) coordinates, according to the current ellipsoid parameters. If any errors occur, the error
 * code(s) are returned by the function, otherwide UPS_NO_ERROR is returned.
 *
 * @param latitude  Latitude in radians
 * @param longitude Longitude in radians
 *
 * @return error code
 */
public long convertGeodeticToUPS(double latitude, double longitude)
{
    if ((latitude < -MAX_LAT) || (latitude > MAX_LAT))
    {   /* latitude out of range */
        return UPS_LAT_ERROR;
    }
    if ((latitude < 0) && (latitude > MIN_SOUTH_LAT))
        return UPS_LAT_ERROR;
    if ((latitude >= 0) && (latitude < MIN_NORTH_LAT))
        return UPS_LAT_ERROR;

    if ((longitude < -PI) || (longitude > (2 * PI)))
    {  /* slam out of range */
        return UPS_LON_ERROR;
    }

    if (latitude < 0)
    {
        UPS_Origin_Latitude = -MAX_ORIGIN_LAT;
        Hemisphere = AVKey.SOUTH;
    }
    else
    {
        UPS_Origin_Latitude = MAX_ORIGIN_LAT;
        Hemisphere = AVKey.NORTH;
    }

    polarConverter.setPolarStereographicParameters(UPS_a, UPS_f,
        UPS_Origin_Latitude, UPS_Origin_Longitude,
        false_easting, false_northing);

    polarConverter.convertGeodeticToPolarStereographic(latitude, longitude);

    UPS_Easting = UPS_False_Easting + polarConverter.getEasting();
    UPS_Northing = UPS_False_Northing + polarConverter.getNorthing();
    if (AVKey.SOUTH.equals(Hemisphere))
        UPS_Northing = UPS_False_Northing - polarConverter.getNorthing();

    Easting = UPS_Easting;
    Northing = UPS_Northing;

    return UPS_NO_ERROR;
}