![JAR search and dependency download from the Maven repository](/logo.png)
org.openlr.binary.writer.PointOfInterestWithAccessPointLocationReferenceWriter Maven / Gradle / Ivy
The newest version!
package org.openlr.binary.writer;
import org.locationtech.jts.geom.Coordinate;
import org.openlr.binary.format.*;
import org.openlr.locationreference.LocationReferencePoint;
import org.openlr.locationreference.PathAttributes;
import org.openlr.locationreference.PointOfInterestWithAccessPointLocationReference;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
class PointOfInterestWithAccessPointLocationReferenceWriter {
private final StatusWriter statusWriter;
private final CoordinateWriter coordinateWriter;
private final AttributesWriter attributesWriter;
private final OffsetWriter offsetWriter;
PointOfInterestWithAccessPointLocationReferenceWriter(StatusWriter statusWriter, CoordinateWriter coordinateWriter, AttributesWriter attributesWriter, OffsetWriter offsetWriter) {
this.statusWriter = statusWriter;
this.coordinateWriter = coordinateWriter;
this.attributesWriter = attributesWriter;
this.offsetWriter = offsetWriter;
}
void write(PointOfInterestWithAccessPointLocationReference pointOfInterestWithAccessPointLocationReference, ByteArrayOutputStream outputStream) throws IOException {
Status status = new Status(3, true, 0, true);
statusWriter.write(status, outputStream);
LocationReferencePoint firstLocationReferencePoint = pointOfInterestWithAccessPointLocationReference.getFirstLocationReferencePoint();
Coordinate firstCoordinate = firstLocationReferencePoint.getCoordinate();
coordinateWriter.writeAbsoluteCoordinate(firstCoordinate, outputStream);
Attributes5 firstAttributes5 = new Attributes5(pointOfInterestWithAccessPointLocationReference.getOrientation(), firstLocationReferencePoint.getFunctionalRoadClass(), firstLocationReferencePoint.getFormOfWay());
attributesWriter.writeAttributes5(firstAttributes5, outputStream);
PathAttributes firstPathAttributes = firstLocationReferencePoint.getPathAttributes().orElseThrow(() -> new IllegalArgumentException());
Attributes2 firstAttributes2 = new Attributes2(firstPathAttributes.getLowestFunctionalRoadClass(), firstLocationReferencePoint.getBearing());
attributesWriter.writeAttributes2(firstAttributes2, outputStream);
Attributes3 firstAttributes3 = new Attributes3(firstPathAttributes.getDistance());
attributesWriter.writeAttributes3(firstAttributes3, outputStream);
LocationReferencePoint lastLocationReferencePoint = pointOfInterestWithAccessPointLocationReference.getLastLocationReferencePoint();
Coordinate lastCoordinate = lastLocationReferencePoint.getCoordinate();
coordinateWriter.writeRelativeCoordinate(lastCoordinate, firstCoordinate, outputStream);
Attributes6 lastAttributes6 = new Attributes6(pointOfInterestWithAccessPointLocationReference.getSideOfRoad(), lastLocationReferencePoint.getFunctionalRoadClass(), lastLocationReferencePoint.getFormOfWay());
attributesWriter.writeAttributes6(lastAttributes6, outputStream);
boolean positiveOffset = pointOfInterestWithAccessPointLocationReference.getRelativePositiveOffset() > 0;
Attributes4 lastAttributes4 = new Attributes4(positiveOffset, false, lastLocationReferencePoint.getBearing());
attributesWriter.writeAttributes4(lastAttributes4, outputStream);
if (positiveOffset) {
offsetWriter.write(pointOfInterestWithAccessPointLocationReference.getRelativePositiveOffset(), outputStream);
}
coordinateWriter.writeRelativeCoordinate(pointOfInterestWithAccessPointLocationReference.getCoordinate(), firstCoordinate, outputStream);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy