FILE - in this Jan. 22, 2018, file photo, Denise Lindstrom, a 49-year-old homeless woman, sits in a wheelchair with tearful eyes in front of a moving truck in an homeless encampment on the Santa Ana River trail in Anaheim, Calif. The truck was provided by a nonprofit organization to help homeless people recycle to pay for their storage as the city plans to shut down the encampment. Homeless residents and their advocates are expected to argue in U.S. court Tuesday, Feb. 13, that Orange County can't remove them from a riverbed bike trail without adequate housing options. Officials say they've offered shelter beds and housing. (AP Photo/Jae C. Hong, File)

FILE - In this Dec. 19, 2017, file photo, two police officers, Eric Meier, right, and Curtis Bynum from the Anaheim Police Department's homeless outreach team walk through a homeless encampment set up outside Angel Stadium to hand out flyers about the community outreach day in Anaheim, Calif. Homeless residents and their advocates are expected to argue in U.S. court Tuesday, Feb. 13, that Orange County can't remove them from a riverbed bike trail without adequate housing options. Officials say they've offered shelter beds and housing. (AP Photo/Jae C. Hong, File)

FILE - In this Jan 22, 2018, file photo, Orange County Sheriff's deputies tell people they need to begin he process of packing up along the Santa Ana riverbed in Anaheim, Calif. Homeless residents and their advocates are expected to argue in U.S. court Tuesday, Feb. 13, that Orange County can't remove them from a riverbed bike trail without adequate housing options. Officials say they've offered shelter beds and housing. (Bill Alkofer/The Orange County Register via AP, File)

FILE - In this Jan. 8, 2018 file photo, signs warning homeless residents they'll need to move out of a two-mile long encampment are posted in Anaheim, Calif. A long-running dispute over a Southern California county's plans to shut down the massive homeless encampment faces a key day in court. Homeless residents and their advocates are expected to argue in U.S. court Tuesday, Feb. 13, that Orange County can't remove them from a riverbed bike trail without adequate housing options. Officials say they've offered shelter beds and housing. The lawsuit is being watched by homeless advocates nationwide amid a rise in encampments. (AP Photo/Amy Taxin, File)

SANTA ANA, Calif. (AP) — 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.