enhancement: make the distance comparator work with approximate distance

Part of work on #2733.