class LocationReferencePointEncoder {

    public openlr.proto.schema.LocationReferencePoint encode(LocationReferencePoint locationReferencePoint) {
        openlr.proto.schema.LocationReferencePoint.Builder builder = openlr.proto.schema.LocationReferencePoint.newBuilder();

        Coordinates coordinates = Coordinates.newBuilder()
                .setLongitude(locationReferencePoint.getLongitudeDeg())
                .setLatitude(locationReferencePoint.getLatitudeDeg())
                .build();
        builder.setCoordinates(coordinates);

        LineAttributes lineAttributes = LineAttributes.newBuilder()
                .setBearing((int) locationReferencePoint.getBearing())
                .setFrc(encode(locationReferencePoint.getFRC()))
                .setFow(encode(locationReferencePoint.getFOW()))
                .build();
        builder.setLineAttributes(lineAttributes);

        if (!locationReferencePoint.isLastLRP()) {
            PathAttributes pathAttributes = PathAttributes.newBuilder()
                    .setDistanceToNext(locationReferencePoint.getDistanceToNext())
                    .setLowestFrcAlongPath(encode(locationReferencePoint.getLfrc()))
                    .build();
            builder.setPathAttributes(pathAttributes);
        }

        return builder.build();
    }

}