All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy