Optimally weighted L2 distances for spatially dependent functional data