protected boolean checkFormatDescriptor(ByteBuffer buffer) throws IOException {
buffer.order(LITTLE_ENDIAN);
buffer.position(0);
// read first positions and validate the data
BaseNavigationPosition previousPosition = null;
while ((buffer.position() + 16) < buffer.capacity()) { //16: one Record
/*short trackFlag*/
buffer.getShort();
int time = buffer.getInt();
int latitude = buffer.getInt();
int longitude = buffer.getInt();
short altitude = buffer.getShort();
BaseNavigationPosition position = createWaypoint(time, latitude, longitude, altitude, 1, false);
boolean valid = position.getLatitude() < 90.0 && position.getLatitude() > -90.0 &&
position.getLongitude() < 180.0 && position.getLongitude() > -180.0 &&
position.getElevation() < 15000.0 &&
abs(position.getLatitude()) > 0.00001 &&
abs(position.getLongitude()) > 0.00001 &&
position.getTime().getCalendar().get(YEAR) > 1990;
if (valid && previousPosition != null) {
Double speed = position.calculateSpeed(previousPosition);
valid = speed != null && speed < 1500.0 &&
previousPosition.getTime().getTimeInMillis() < position.getTime().getTimeInMillis();
}
if (!valid)
return false;