I feel like it would make sense to have a "preprocessing" method in LocationMode, so that this code could be removed from here, and more easily extended for the other location modes.