Geometrical and topological study of the Kosterlitz–Thouless phase transition in the XY model in two dimensions