Prosecuting homeless people for sleeping on the streets when there is no shelter available is a form of cruel and unusual punishment that violates the Constitution, a federal appeals court said this week.

The case stems from two ordinances in Boise, Idaho, that make it a crime to sleep or camp in buildings, streets and other public places. Six homeless people who had been convicted under the laws sued the city in 2009, saying their constitutional rights had been violated.

After years of legal wrangling, a three-judge panel of the Ninth U.S. Circuit Court of Appeals said in a 32-page opinion Tuesday that Boise's ordinances "criminalize the simple act of sleeping outside on public property, whether bare or with a blanket or other basic bedding." The panel added that "a municipality cannot criminalize such behavior consistently with the Eighth Amendment when no sleeping space is practically available in any shelter."

In their summary of the opinion, the judges wrote, "As long as there is no option of sleeping indoors, the government cannot criminalize indigent, homeless people for sleeping outdoors, on public property, on the false premise they had a choice in the matter."

The ruling was a victory for homeless advocates, who have long said that laws like the city of Boise's waste public money, do not alleviate root causes of homelessness like shortages of affordable housing and punish people simply for being poor.

These issues have taken on increased significance as urban neighborhoods gentrify, said Maria Foscarinis, executive director of the National Law Center on Homelessness and Poverty, a Washington nonprofit that helped argue the Boise case.

A survey of 187 cities by the group found that from 2006 to 2016, the number of bans on camping in public increased by 69 percent. Bans on sleeping in public places increased by 31 percent.

In December, the Department of Housing and Urban Development said homelessness had increased in 2017 for the first time in seven years, according to an annual count.

"Gentrification means less affordable housing," Foscarinis said. "It also means a lot of pressure to remove people who are visibly poor from prominent city areas. These trends are promoting criminalization and promoting these kinds of clashes."

The Boise ruling would apply to all areas covered by the Ninth Circuit, which is based in San Francisco and includes the western portion of the country.

Cities had already been reviewing the homelessness laws they had on the books. John Coté, a spokesman for the San Francisco city attorney's office, said Wednesday that the office was reviewing the city's laws to make sure they did not run afoul of the Ninth Circuit ruling.

San Francisco voters passed a law in 2016 that prohibits tents on sidewalks, but the tents can be removed only if the city offers placement in shelters or other options for housing. The city must also offer to transport people to the homes of friends or family who could take them in and give 24-hour notice before removing the tents.

"Our approach is different than Boise's, but we're analyzing the ruling to see if it may have implications for San Francisco," Coté said.