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

org.openlr.binary.writer.LocationReferenceWriter Maven / Gradle / Ivy

The newest version!
package org.openlr.binary.writer;

import org.openlr.locationreference.*;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class LocationReferenceWriter {
    private final LineLocationReferenceWriter lineLocationReferenceWriter;
    private final GeoCoordinateLocationReferenceWriter geoCoordinateLocationReferenceWriter;
    private final PointAlongLineLocationReferenceWriter pointAlongLineLocationReferenceWriter;
    private final PointOfInterestWithAccessPointLocationReferenceWriter pointOfInterestWithAccessPointLocationReferenceWriter;
    private final CircleLocationReferenceWriter circleLocationReferenceWriter;
    private final PolygonLocationReferenceWriter polygonLocationReferenceWriter;
    private final RectangleLocationReferenceWriter rectangleLocationReferenceWriter;
    private final GridLocationReferenceWriter gridLocationReferenceWriter;
    private final ClosedLineLocationReferenceWriter closedLineLocationReferenceWriter;

    LocationReferenceWriter(LineLocationReferenceWriter lineLocationReferenceWriter, GeoCoordinateLocationReferenceWriter geoCoordinateLocationReferenceWriter, PointAlongLineLocationReferenceWriter pointAlongLineLocationReferenceWriter, PointOfInterestWithAccessPointLocationReferenceWriter pointOfInterestWithAccessPointLocationReferenceWriter, CircleLocationReferenceWriter circleLocationReferenceWriter, PolygonLocationReferenceWriter polygonLocationReferenceWriter, RectangleLocationReferenceWriter rectangleLocationReferenceWriter, GridLocationReferenceWriter gridLocationReferenceWriter, ClosedLineLocationReferenceWriter closedLineLocationReferenceWriter) {
        this.lineLocationReferenceWriter = lineLocationReferenceWriter;
        this.geoCoordinateLocationReferenceWriter = geoCoordinateLocationReferenceWriter;
        this.pointAlongLineLocationReferenceWriter = pointAlongLineLocationReferenceWriter;
        this.pointOfInterestWithAccessPointLocationReferenceWriter = pointOfInterestWithAccessPointLocationReferenceWriter;
        this.circleLocationReferenceWriter = circleLocationReferenceWriter;
        this.polygonLocationReferenceWriter = polygonLocationReferenceWriter;
        this.rectangleLocationReferenceWriter = rectangleLocationReferenceWriter;
        this.gridLocationReferenceWriter = gridLocationReferenceWriter;
        this.closedLineLocationReferenceWriter = closedLineLocationReferenceWriter;
    }

    public void write(LocationReference locationReference, ByteArrayOutputStream outputStream) throws IOException {
        if (locationReference instanceof LineLocationReference) {
            lineLocationReferenceWriter.write((LineLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof GeoCoordinateLocationReference) {
            geoCoordinateLocationReferenceWriter.write((GeoCoordinateLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof PointAlongLineLocationReference) {
            pointAlongLineLocationReferenceWriter.write((PointAlongLineLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof PointOfInterestWithAccessPointLocationReference) {
            pointOfInterestWithAccessPointLocationReferenceWriter.write((PointOfInterestWithAccessPointLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof CircleLocationReference) {
            circleLocationReferenceWriter.write((CircleLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof PolygonLocationReference) {
            polygonLocationReferenceWriter.write((PolygonLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof RectangleLocationReference) {
            rectangleLocationReferenceWriter.write((RectangleLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof GridLocationReference) {
            gridLocationReferenceWriter.write((GridLocationReference) locationReference, outputStream);
        }
        else if (locationReference instanceof ClosedLineLocationReference) {
            closedLineLocationReferenceWriter.write((ClosedLineLocationReference) locationReference, outputStream);
        }
        else {
            throw new IllegalArgumentException("Unknown location reference type");
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy