The sensor geometry design problem of time difference of arrival (TDOA) localisation systems based on Cramer-Rao bound is studied. Sensor placement constraints are considered, which means the available placement area is limited. This makes sensor geometry design a sensor selection problem. In two-dimensional (2D) TDOA localisation or 3D TDOA localisation on the earth surface, sensor selection can be implemented through solving a fractional integer programming problem. However, traditional fractional integer programming methods are either suboptimal or too time consuming. For this reason, a new method named path-varying sphere decoding is proposed in two steps. In step one, the programming problem is relaxed into two sphere decoding (SD) subproblems. Solving these subproblems leads to the optimal solution, and the required computational complexity is much less than those of traditional optimal methods. In step two, the structure of the cost function is explored. This makes it possible to calculate the path-varying upper-bound of a quadratic function. Thus the quadratic function constraint used in one SD subproblem becomes tighter and the calculation speed is enhanced. Theory analyses and simulation results show that the proposed method is not only optimal but also much faster than traditional optimal methods when solving large-scale programming problems.