The invention discloses an electronic fence, which comprises a dot line judgment method. According to the dot line judgment method, firstly, each edge of a polygon is taken as a directed line segmentwhich is connected in an end-to-end mode. If the direction of a certain point relative to each edge of the polygon is the same, the certain point is located in the polygon. The core step of the electronic fence is to figure out the values of two points (x1, y1) and (x2, y2) closest to a point (x, y), and is applied to a convex polygon. According to the electronic fence provided by the invention, the optimized algorithm of the electronic fence is achieved, so that the efficiency in searching motorcycles which drive in and out of the e electronic fence is improved. The software structure and thedatabase structure of the electronic fence are designed to realize the electronic fence. According to the design of the electronic fence, the polygon is directly drawn on a map, which has a great error with an actual geographical longitude and an actual geographical latitude. During the drawing of the electronic fence, the longitudes and the latitudes of a plurality of corners are determined as much as possible. After that, adjacent corners are connected. Meanwhile, the map is ensured at a maximum multiple, and the error can be guaranteed to be the minimum.