byte[] header = new byte[HEADER_SIZE];
if ((source.read(header) == HEADER_SIZE) && checkHeader(header)) {
ByteBuffer sbpRecordByteBuffer = ByteBuffer.allocate(SBP_RECORD_LENGTH);
sbpRecordByteBuffer.order(ByteOrder.LITTLE_ENDIAN);
Wgs84Route activeRoute = null;
byte[] record = new byte[SBP_RECORD_LENGTH];
while (source.read(record) == SBP_RECORD_LENGTH) {
sbpRecordByteBuffer.position(0);
sbpRecordByteBuffer.put(record);
Wgs84Position position = decodePosition(sbpRecordByteBuffer);
if ((activeRoute == null) || (isTrackStart(sbpRecordByteBuffer))) {
activeRoute = createRoute(Track,
createDateFormat(TRACK_NAME_DATE_FORMAT).format(position.getTime().getTime()),
new ArrayList<BaseNavigationPosition>());
context.appendRoute(activeRoute);
}
activeRoute.getPositions().add(position);
}
}
}