At present, the drawing of power lines is still in the state of semi-manual design, mainly completed by AutoCAD, which not only consumes human resources, but also has low efficiency. Therefore, this paper designs an automatic drawing software for power lines. It integrates drawing and data management. Based on the basic information of power lines, this software imports and automatically converts the basic power data (latitude and longitude data) containing GPS/BeidDou positioning information into the distance, direction, angle and other information of poles and cables. Then, it realizes the function of automatically drawing the power line graph according to the scale by multiple tree traversal algorithm. This software is easy to operate and reliable, and has achieved good results in practice.

The power grid is directly facing the end users and is closely related to the production and life of the people. It is an important public infrastructure to serve the people’s livelihood. In recent years, with the development of new-type urbanization, China has been committed to the construction and renovation of power grid, so as to realize reliable power supply, high-quality service and improve supply efficiency. Power grid construction and reconstruction has become an urgent task of the current power industry. After the completion of the power grid transformation, the power supply enterprises need to draw and archive the power line diagram, which is usually drawn semi-manually by AutoCAD. However, AutoCAD requires professionals to use different drawing tools to draw on the software when drawing, and if it is necessary to change the position of a pole or change the information of a power line, it needs to be redrawn. Therefore, this kind of design method’s shortcoming is obvious, not only the design workload is big, time-consuming, laborious, the efficiency is low, moreover has not been able to adapt to the electronic age development demand[

In order to realize the convenient drawing function, this paper designs and implements an automatic drawing software for power lines. The system can calculate various parameter information in the line through GPS data (longitude and latitude data) and store it in the database. Then it will automatically generate a standard and beautiful power circuit diagram according to the information stored in the database. If some information needs to be changed after the completion of power grid construction and reconstruction, only the corresponding data need to be changed to automatically draw again. This software provides a strong guarantee for reducing labor intensity, improving work efficiency and plotting quality, and shortening plotting cycle.

Power equipment mainly includes generator set, power distribution device, lighthouse bridge column, fuse, transformer, transformer table, automatic control device, watt-hour meter, high-voltage switch, high-voltage circuit breaker, capacitor, lightning arrester, current transformer, voltage transformer, cable line, power line, etc. Since the generator set is not fixed on the power line, the power line mentioned in this system mainly refers to the line composed of outdoor poles, cables and transformer stations (including box transformers).

Due to the wide coverage area of outdoor lines, the complex and changeable environment, and the diversified routing modes of the lines, the factors to be considered in drawing are also relatively complex. However, no matter how complicated and diverse the actual power lines are, all power lines are connected to the user end through transformer outgoing lines and several poles, so the power lines are essentially standard multi-branch tree structures. As shown in fig.

Schematic diagram of power line multi-branch tree structure

In the actual drawing process, whether manual drawing or automatic drawing, transformer is generally selected as the starting point. The process is: starting from the starting point to find the next pole connected to it through the relationship between the nodes, get the parameters of the node and the parent node, such as the distance, rotation angle, steering and other parameters, and then calculate the relative coordinates of the node. This drawing process is also very similar to the traversal process of a multi-fork tree, which provides the possibility for the realization of automatic power drawing. In the actual circuit drawing process, the four basic data sources of gear length, angle, steering, and pole number can be obtained during power grid reconstruction or power grid construction, or GPS can be used to obtain the latitude and longitude information of the pole and then converted to span, veer and angle. The automatic drawing of power lines can be realized by processing the four parameters in the database while traversing each node, calculating the relative coordinates of each node and converting them into absolute coordinates.

Since the relationship between transformer and pole is tree structure, when drawing circuit diagram, this multi-branch tree can be constructed by traversing power lines and all nodes in the tree can be processed one by one. Therefore, it has the possibility to realize the automatic drawing of power line graphics.

Common multi-tree traversal can be divided into two types: level-first traversal and depth-first traversal. Depth first traversal can be divided into: first order traversal, middle order traversal, and second order traversal. Its principle is to traverse the nodes of the tree along its depth and search the branches of the tree as deep as possible. Hierarchy priority traversal is to traverse the nodes of the tree according to hierarchy. Its principle is to first visit the root node and find all its children. These sub-nodes are also the root nodes of the sub-tree, so these nodes are accessed again, and so on and so forth, in order of first, second, third, etc[

Although the power line graph has a multi-branch tree structure, there are many problems in the actual traversal operation. In the past multi-tree applications, whether it is depth traversal or hierarchical traversal, the node stores the node’s sub-node information when it is stored, so its sub-nodes can be directly found by accessing the node, and traversal can be completed from top to bottom. However, in power lines, because each pole node only knows its parent node but not its child node and has no other relationship information, it is difficult to determine the location of other nodes except the root node, so the traditional traversal algorithm is not applicable.

In order to solve this problem, this research has made some improvements on the basis of the hierarchical traversal algorithm. Because the information of each node’s parent node is clear, we can easily find all the nodes with the same parent node. This research is based on this point to achieve top-down traversal. First, create an instance class object “Tree”, which represents that each row of data in the database is an instance object in java, and create an attribute “children” in the instance object Tree to save all child nodes of the current node. Second, get the data in the database to the instance object, and save all the instance objects in the list collection. The specific traversal algorithm is to find the root node and put it into the result, and use the children attribute to find all the child nodes of the current layer from top to bottom through recursion, and save them in the result. Recursive traversal code is as follows.

//Store all node data information object collection

List<Tree> result = new ArrayList<Tree>();

//Query node data information

List<Tree> lists = new TestJDBC().queryAll();

//Traverse to determine whether it is the root node

for (Tree tree : lists) {

if(null == tree.getPid()) {

result.add(tree);

}

}

// Recursive call judgment function

for (Tree parent : result){

parent = recursiveTree(parent, lists);

}

//Judgment function adds an object to the child

attribute of the parent node object

public static Tree recursiveTree(Tree parent, List<Tree> list) {

for (Tree tree : list) {

if(parent.getId().equals(tree.getPid()))

{

tree = recursiveTree(tree, list);

parent.getChildren().add(tree);

}

}

return parent;

}

The purpose of traversal is not only to construct the multi tree, but also to locate the coordinates of the traversal nodes. It is very important to convert the latitude and longitude data of the pole to the coordinate points in the plane rectangular coordinate system because it is impossible to draw the figure directly by GPS. In order to draw the figure accurately in the plane coordinate, first we must convert the longitude and latitude data into the plane coordinate data, and calculate the angle and the distance between the two points through the longitude and latitude data[

Among them, θ is the angle (degree) between A and B, JA is the longitude of point a, JB is the longitude of point B, WA is the latitude of point A, WB is the latitude of point B.

Among them, L is the distance between points A and B (m), R is the earth radius (6371km), JA is the longitude of point A, JB is the longitude of point B, WA is the latitude of point A, WB is the latitude of point B.

According to the calculation results of formulas

Storage in a database

During traversal, the coordinates are located from the starting point, and then each child node of the node is found by traversal algorithm. The relative coordinates of the nodes are calculated by the span, rotation angle and steering parameters between the child node and the parent node. Due to the need to modify the relevant information of the pole during the traverse process, in order to ensure the integrity and reliability of the original database and improve the speed of database traversal, the information of relevant substation should be saved in the temporary database before the actual traversal[

_{0}, _{0}] according to the actual position of the transformer in the transformer.

_{0}, _{0}] of the distribution board according to the distance between the distribution board and the transformer, the steering and the steering angle, mark in the temporary database that the relative position coordinates of the node and the parent node have been calculated, and mark in the parent node that the child node coordinates of the parent node have been calculated.

In the process of traversal, every record in the database must participate in multiple operations. If there are many poles in a substation, the cycle of traversal operation may be too long. Therefore, in the actual traversal operation, it may be faster to use the stored procedure of the database to complete this work.

After traversal calculation and plane coordinate positioning, the actual drawing results also need to display other relevant information for users. Therefore, the following work should be completed before automatically generating circuit drawing.

A multi-fork tree structure with transformer as the root node line as the path and pole as the node is established by analyzing the demand of power supply enterprises for the drawing and archiving of power circuit diagrams and combining with the characteristics of power lines. After identifying the information stored in the database, a hierarchical traversal algorithm based on multi-tree is proposed. In the process of drawing, only four parameters of node need to be processed : span, veer, angle and Id number. and then the relative coordinates of each node are calculated and converted into absolute coordinates by using a multi-tree layer traversal algorithm, so that the automatic drawing of power lines can be realized. Then, the relative coordinates of each node are calculated and converted into absolute coordinates by using a multi-tree layer traversal algorithm, so that the automatic drawing of power lines can be realized. The drawing method discussed in this paper has been successfully applied to many power supply enterprises in our country. Figure

Circuit diagram of a transformer station automatically generated

The system manages power line parameter data through a database, and realizes the function of automatically drawing power graphs according to the proportion set by users, thus saving human resources. It can quickly change the information in the database when the information about a power line is changed. Therefore, it can well meet the needs of China’s power grid reconstruction with short drawing cycle and high working efficiency. This system has achieved good results in the practical application of power supply enterprises in many places.