Police do not have to reveal the location of a surveillance post in a criminal trial unless a judge determines that the defendant's need for that information outweighs other reasons for keeping it secret, such as police safety, the U.S. Court of Appeals ruled yesterday.

The court acted in the case of Stanley Harley of Southeast Washington who was convicted of heroin distribution after a trial in U.S. District Court in 1981, after he sold $50 worth of heroin to an undercover police detective.

The transaction was videotaped by police from a surveillance point in an apartment about 30 yards from a courtyard on Wheeler Road SE, where the sale occurred.

Harley had contended in the appeals court that his constitutional right to confront the evidence against him was violated when the trial court said that the police did not have to disclose the floor in the building on which the apartment was located.

Judge Robert Bork, writing for the appeals court yesterday, noted that at his trial Harley "offered no reason why the information was important," although he suggested that the safety of the police was not a question since the surveillance post had been abandoned.

Bork noted, however, that the safety of the apartment owner who cooperated with the police or tenants in the building as well as the willingness of other citizens to cooperate with the police in the future remained important factors in any decision to disclose the location of the apartment.

Harley contended on appeal that he wanted to know where the apartment was located so that he could show that the police would have had trouble identifying anyone from that vantage point, but Bork said that the videotape shown at Harley's trial clearly depicted the officers' viewpoint.

Bork said it was "difficult to believe" that Harley would have gained anything by learning the location of the apartment.

Bork was joined in upholding Harley's conviction by Senior Judge Roger Robb and Senior Judge James Gordon of the Western District of Kentucky, sitting in Washington by special designation.