Environmental groups have welcomed a decision by a German court which rules that cities can ban the most heavily polluting diesel cars from their streets.