Search in sources :

Example 1 with CompassPoint

use of net.sf.marineapi.nmea.util.CompassPoint in project marine-api by ktuukkan.

the class HDGParser method getDeviation.

/*
	 * (non-Javadoc)
	 * @see net.sf.marineapi.nmea.sentence.HDGSentence#getDeviation()
	 */
public double getDeviation() {
    double dev = getDoubleValue(DEVIATION);
    if (dev == 0) {
        return dev;
    }
    CompassPoint dir = CompassPoint.valueOf(getCharValue(DEV_DIRECTION));
    return dir == CompassPoint.WEST ? -dev : dev;
}
Also used : CompassPoint(net.sf.marineapi.nmea.util.CompassPoint)

Example 2 with CompassPoint

use of net.sf.marineapi.nmea.util.CompassPoint in project marine-api by ktuukkan.

the class HDGParser method getVariation.

/*
	 * (non-Javadoc)
	 * @see net.sf.marineapi.nmea.sentence.HDGSentence#getVariation()
	 */
public double getVariation() {
    double var = getDoubleValue(VARIATION);
    if (var == 0) {
        return var;
    }
    CompassPoint dir = CompassPoint.valueOf(getCharValue(VAR_DIRECTION));
    return dir == CompassPoint.WEST ? -var : var;
}
Also used : CompassPoint(net.sf.marineapi.nmea.util.CompassPoint)

Example 3 with CompassPoint

use of net.sf.marineapi.nmea.util.CompassPoint in project marine-api by ktuukkan.

the class PositionParser method parsePosition.

/**
	 * Parses a <code>Position</code> from specified fields.
	 * 
	 * @param latIndex Latitude field index
	 * @param latHemIndex Latitude hemisphere field index
	 * @param lonIndex Longitude field index
	 * @param lonHemIndex Longitude hemisphere field index
	 * @return Position object
	 */
protected Position parsePosition(int latIndex, int latHemIndex, int lonIndex, int lonHemIndex) {
    double lat = parseLatitude(latIndex);
    double lon = parseLongitude(lonIndex);
    CompassPoint lath = parseHemisphereLat(latHemIndex);
    CompassPoint lonh = parseHemisphereLon(lonHemIndex);
    if (lath.equals(CompassPoint.SOUTH)) {
        lat = -lat;
    }
    if (lonh.equals(CompassPoint.WEST)) {
        lon = -lon;
    }
    return new Position(lat, lon);
}
Also used : Position(net.sf.marineapi.nmea.util.Position) CompassPoint(net.sf.marineapi.nmea.util.CompassPoint)

Example 4 with CompassPoint

use of net.sf.marineapi.nmea.util.CompassPoint in project marine-api by ktuukkan.

the class PositionParser method parseHemisphereLon.

/**
	 * Parses the hemisphere of longitude from the specified field.
	 * 
	 * @param index Field index for longitude hemisphere indicator
	 * @return Hemisphere of longitude
	 */
protected CompassPoint parseHemisphereLon(int index) {
    char ch = getCharValue(index);
    CompassPoint d = CompassPoint.valueOf(ch);
    if (d != CompassPoint.EAST && d != CompassPoint.WEST) {
        throw new ParseException("Invalid longitude hemisphere " + ch + "'");
    }
    return d;
}
Also used : CompassPoint(net.sf.marineapi.nmea.util.CompassPoint)

Example 5 with CompassPoint

use of net.sf.marineapi.nmea.util.CompassPoint in project marine-api by ktuukkan.

the class PositionParser method parseHemisphereLat.

/**
	 * Parses the hemisphere of latitude from specified field.
	 * 
	 * @param index Index of field that contains the latitude hemisphere value.
	 * @return Hemisphere of latitude
	 */
protected CompassPoint parseHemisphereLat(int index) {
    char ch = getCharValue(index);
    CompassPoint d = CompassPoint.valueOf(ch);
    if (d != CompassPoint.NORTH && d != CompassPoint.SOUTH) {
        throw new ParseException("Invalid latitude hemisphere '" + ch + "'");
    }
    return d;
}
Also used : CompassPoint(net.sf.marineapi.nmea.util.CompassPoint)

Aggregations

CompassPoint (net.sf.marineapi.nmea.util.CompassPoint)5 Position (net.sf.marineapi.nmea.util.Position)1