org.openlr.binary.writer.GridLocationReferenceWriter Maven / Gradle / Ivy
The newest version!
package org.openlr.binary.writer;
import org.openlr.binary.format.Status;
import org.openlr.locationreference.GridLocationReference;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
class GridLocationReferenceWriter {
private final StatusWriter statusWriter;
private final CoordinateWriter coordinateWriter;
private final IntegerWriter integerWriter;
GridLocationReferenceWriter(StatusWriter statusWriter, CoordinateWriter coordinateWriter, IntegerWriter integerWriter) {
this.statusWriter = statusWriter;
this.coordinateWriter = coordinateWriter;
this.integerWriter = integerWriter;
}
void write(GridLocationReference gridLocationReference, ByteArrayOutputStream outputStream) throws IOException {
Status status = new Status(3, false, 2, false);
statusWriter.write(status, outputStream);
coordinateWriter.writeAbsoluteCoordinate(gridLocationReference.getLowerLeft(), outputStream);
coordinateWriter.writeRelativeCoordinate(gridLocationReference.getUpperRight(), gridLocationReference.getLowerLeft(), outputStream);
integerWriter.write(gridLocationReference.getNumberOfColumns(), 2, outputStream);
integerWriter.write(gridLocationReference.getNumberOfRows(), 2, outputStream);
}
}