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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations