The full coverage of 5G signals in coal mine tunnels not only improves safety, and management level, but also one of the necessary foundations for the intelligent development of coal mines. However, the narrow and multi branched structural characteristics of coal mine tunnels make it difficult to achieve comprehensive coverage of 5G signals. The high path loss in the tunnel limits wireless signal transmission, therefore, careful consideration of network planning is needed to ensure comprehensive coverage of 5G signals. This article proposes a ray tracing path loss model to determine the base station coverage radius of rectangular cross-section tunnels. And propose a discrete programming method based on geometric framework to achieve optimal coverage by minimizing the number and location optimization of base stations. To verify the effectiveness of the proposed method, a three-dimensional tunnel model was constructed and numerical simulations were conducted for validation. Under this model, using 14 base stations can achieve a coverage rate of 91.2% with an error of only 2.4%. In addition, the accuracy of the loss model was verified through measured data from coal mine tunnels. Therefore, the proposed method has practical application value for solving base station location selection in network planning.