Unmanned aerial vehicles (UAVs) have been widely used in communication systems due to excellent maneuverability and mobility. The ultra-high speed, ultra-low latency, and ultra-high reliability of 5th generation wireless systems (5G) have further promoted vigorous development of UAVs. Compared with traditional means of communication, UAV can provide services for ground terminal without time and space constraints, so it is often used as air base station (BS). Especially in emergency communications and rescue, it provides temporary communication signal coverage service for disaster areas. In the face of large-scale and scattered user coverage tasks, UAV's trajectory is an important factor affecting its energy consumption and communication performance. In this paper, we consider a UAV emergency communication network where UAV aims to achieve complete coverage of potential underlying D2D users (DUs). The trajectory planning problem is transformed into the deployment and connection problem of stop points (SPs). Aiming at trajectory length and sum throughput, two trajectory planning algorithms based on K-means are proposed. Due to the non-convexity of sum throughput optimization, we present a sub-optimal solution by using the successive convex approximation (SCA) method. In order to balance the relationship between trajectory length and sum throughput, we propose a joint evaluation index which is used as an objective function to further optimize trajectory. Simulation results show the validity of the proposed algorithms which have advantages over the well-known benchmark scheme in terms of trajectory length and sum throughput.