A Berlin school finished building a 1.8-meter (5-feet-11-inch) fence to keep street prostitutes out of its campus, local media reported on Tuesday.

The Französisches Gymnasium highschool lies on a sidestreet of the German capital's notorious Kurfürstenstraße. The street is a relatively major thoroughfare through Berlin's inner west, but is also the center of the city's street prostitution scene.

Prostitutes can be seen soliciting clients at all hours of the day there. A build-up of discarded condoms and syringes, as well as excrement, were evidence that the school grounds were being used in unsavory ways.

"There were always complaints about unscrupulous characters including prostitutes walking shamelessly and illegally into school grounds even during the day," the district school inspector Carsten Spallek told the daily Berliner Zeitung.

Read more: Disappointed refugees driven to prostitution

Watch video 01:59 Germany: Male refugees turning to prostitution in Berlin

City officials spent 57,000 euros ($67,000) to build a fence to keep such characters off school grounds, rival daily B.Z and national tabloid Bild later reported.

Residential developments are increasingly pushing sex workers out of the areas they used to ply their trade, forcing the business into the sidestreets and onto the door step of the school.

"The prostitutes eat, stand, drink and litter. It looks filthy in the late evening," district coordinator Michael Klinnert told Berliner Zeitung.

"The women have no stations to wash themselves or to get themselves ready. And they relieve themselves wherever they please."

Read more: British police crack down on realistic child sex dolls

The Französisches Gymnasium had complained of unsavory characters blatantly walking on its grounds

Vans drop women off outside the school

Klinnert said each morning women are driven to the area in vans often right to the front of the school. Other schools in the area have complained of the same problem.

The fence is 125 meters long and has been largely welcomed by locals.

Prostitution has long been tolerated in Germany and was more officially regulated by the Prostitution Act of 2002 (PDF). The act gave legal protections to prostitutes to reduce their dependency on pimps, improve health and hygiene conditions at work, make their renumeration legally enforcable, reduce human trafficking crimes, reduce associated crimes, and to make it easier to leave the industry. The act removed the judgement that prostitution was immoral, a designation that had deprived prostitutes of many legal protections.

Most sex workers work inside brothels but a portion ply their trade on the streets, avoiding costly rates for rooms. Most cities restrict areas in which prostitutes can work but Berlin lacks such areas.

In 2016 the German parliament, the Bundestag, passed legislation that further regulated sex work in a bid to crack down on sexual enslavement.

Read more: Germany introduces unpopular prostitution law

It required all sex workers to register with authorities, excluding porn actors, lap dancers, peepshow performers, phone sex operators and webcam models. Under the new law workers are required to undergo regular health checks and to always use a condom. The laws, which came into effect in July 2017, introduced licensing requirements for brothels and outlawed gang-bang parties and flat-rate deals.

Correction: A previous version of this article stated that prostitution was legalized in Germany in 2002. In fact it was already legal and the Prostitution Act of 2002 sought to improve conditions under which prostitutes work.