Make sure also the geometry you compare with is valid, and ignore errors