Part of the problem in NYC is any time you offer any kind of community utility/service it invariably gets taken over by the homeless population. Benches become beds, libraries become bedrooms, cell phone charging stations become encampments.
But you're right, it invariably gets taken over and becomes disgusting. And all the solutions I can think of are quite dystopian, like having a video camera that watches you in the bathroom so it can detect any kind of foul play.