Treating city wastewater as a resource