use of net.sf.marineapi.nmea.util.GpsFixQuality in project marine-api by ktuukkan.
the class PositionProvider method isValid.
/*
* (non-Javadoc)
* @see net.sf.marineapi.provider.AbstractProvider#isValid()
*/
@Override
protected boolean isValid() {
for (Sentence s : getSentences()) {
if (s instanceof RMCSentence) {
RMCSentence rmc = (RMCSentence) s;
DataStatus ds = rmc.getStatus();
if (DataStatus.VOID.equals(ds) || (rmc.getFieldCount() > 11 && FaaMode.NONE.equals(rmc.getMode()))) {
return false;
}
} else if (s instanceof GGASentence) {
GpsFixQuality fq = ((GGASentence) s).getFixQuality();
if (GpsFixQuality.INVALID.equals(fq)) {
return false;
}
} else if (s instanceof GLLSentence) {
DataStatus ds = ((GLLSentence) s).getStatus();
if (DataStatus.VOID.equals(ds)) {
return false;
}
}
}
return true;
}
use of net.sf.marineapi.nmea.util.GpsFixQuality in project marine-api by ktuukkan.
the class PositionProvider method createProviderEvent.
/*
* (non-Javadoc)
* @see net.sf.marineapi.provider.AbstractProvider#createProviderEvent()
*/
@Override
protected PositionEvent createProviderEvent() {
Position p = null;
Double sog = null;
Double cog = null;
Date d = null;
Time t = null;
FaaMode mode = null;
GpsFixQuality fix = null;
for (Sentence s : getSentences()) {
if (s instanceof RMCSentence) {
RMCSentence rmc = (RMCSentence) s;
sog = rmc.getSpeed();
try {
cog = rmc.getCourse();
} catch (DataNotAvailableException e) {
// If we are not moving, cource can be undefined. Leave null in that case.
}
d = rmc.getDate();
t = rmc.getTime();
if (p == null) {
p = rmc.getPosition();
if (rmc.getFieldCount() > 11) {
mode = rmc.getMode();
}
}
} else if (s instanceof VTGSentence) {
VTGSentence vtg = (VTGSentence) s;
sog = vtg.getSpeedKnots();
try {
cog = vtg.getTrueCourse();
} catch (DataNotAvailableException e) {
// If we are not moving, cource can be undefined. Leave null in that case.
}
} else if (s instanceof GGASentence) {
// Using GGA as primary position source as it contains both
// position and altitude
GGASentence gga = (GGASentence) s;
p = gga.getPosition();
fix = gga.getFixQuality();
// Some receivers do not provide RMC message
if (t == null) {
t = gga.getTime();
}
} else if (s instanceof GLLSentence && p == null) {
GLLSentence gll = (GLLSentence) s;
p = gll.getPosition();
}
}
// Ag-Star reciever does not provide RMC sentence. So we have to guess what date it is
if (d == null) {
d = new Date();
}
return new PositionEvent(this, p, sog, cog, d, t, mode, fix);
}
Aggregations