Public officials and homeless advocates reached an agreement Tuesday on providing for homeless people who are being evicted from an encampment in a Southern California riverbed.

Orange County officials said they would use motels and other means to get 700 to 800 beds for the homeless driven from the encampment in Anaheim.

"We pledge up to 400 motel rooms, immediately," County Supervisor Andrew Do told the court, adding that the county would also add beds to other facilities and could put up a tent on a county-owned parking lot if space was needed.

Brooke Weitzman, an attorney for the plaintiffs seeking to stop the eviction, said she was concerned that the tent dwellers would not trust county officials' offer of help on such short notice, but U.S. District Court Judge David O. Carter told her notices would go up as soon as Wednesday and he trusted their word.

He said he suspected homeless residents who don't want help, and want to wander, will move elsewhere.

"If you want to solve this, this is the one opportunity we really have, all the county leaders and the city leaders in one place," Carter said, after officials emerged from four hours of talks.

The sides agreed that social workers would help the homeless find longer term housing after the initial relocation, which will take place in a week.

The deal came at the demand of Carter, who called the sides in for the unusual hearing on Tuesday and is known for summoning public officials for questioning.

He called on Orange County officials, veterans, women's advocates and others to step up and offer solutions for those living on the two-mile (3.2 kilometer) stretch of riverbed trail once popular with joggers and bikers that has been overrun by tents, trash and human waste.

Carter said he plans to visit the encampment on Wednesday morning.

Early in the hearing, he asked why temporary housing couldn't be built quickly, when he has seen villages built overnight with U.S. funding in Afghanistan.

"Where is the leadership to get this done in this county potentially? Where is the long-term solution here?" he asked.

The case is being watched by homeless advocates along the West Coast and elsewhere grappling with a rise in homelessness caused in part by soaring housing costs, rock-bottom vacancy rates and a roaring economy.

The ruling will only cover people living in the encampment near the stadium that hosts the Los Angeles Angels of Anaheim, but homeless advocates elsewhere might look to the case to make similar claims, experts said.

Orange County, home to 3.2 million people between Los Angeles and San Diego, started telling the homeless last month officials were closing the encampment of tents and tarps and offering to store belongings and help find shelter.

Homeless advocates sued and sought protection from the courts when they heard authorities were going to start citing or arresting people who refused to budge.

Carter temporarily blocked officials from making arrests.

During Tuesday's hearing, he peppered advocates and county workers with questions about programs, policies and budgets.

He said he believes Orange County has enough money to find a fix and should be spending it.

He also said a cluster of cities near the riverbed should help after pushing the homeless off their streets and sidewalks to the county-owned trail.