class OpenLRProtoEncoder implements PhysicalEncoder {

    @Override
    public LocationReference encodeData(RawLocationReference rawLocRef) {
        LocationReferenceEncoder locationReferenceEncoder = locationTypeEncoderRegistry.getEncoder(rawLocRef.getLocationType());

        if (locationReferenceEncoder == null) {
            return new LocationReferenceProtoImpl(
                    rawLocRef.getID(),
                    rawLocRef.getLocationType(),
                    OpenLRProtoStatusCode.UNSUPPORTED_LOCATION_TYPE);
        }

        try {
            return locationReferenceEncoder.encode(rawLocRef);
        }
        catch (OpenLRProtoException e) {
            return new LocationReferenceProtoImpl(
                    rawLocRef.getID(),
                    rawLocRef.getLocationType(),
                    e.getErrorCode());
        }
    }

}