Method and apparatus for determining power equipment in target area
By using grid division and Mercator projection, the location of electrical equipment in irregular plots can be quickly and accurately determined, solving the problem of low efficiency in existing technologies. This method is applicable to the identification of electrical equipment in complex polygons and with large amounts of data.
Patent Information
- Application Number
- CN202211116686.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-14
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2042-09-14
AI Technical Summary
Existing technologies cannot quickly and accurately identify power equipment located in irregular plots, especially in cases of complex boundaries or large amounts of data, where the computational load is high and the efficiency is low.
By collecting the latitude and longitude data of the vertices of the target area and the power equipment, multiple grids are generated using a grid division method, and the largest rectangle is determined. The location of the power equipment within the target area is determined by combining the coordinates of the power equipment. The Mercator projection is used to project the irregular plots and measurement points onto a two-dimensional plane. Orthogonal rectangles are used to determine whether the measurement points are inside the irregular plots.
It enables the rapid and accurate determination of the location of power equipment in irregular plots, improving processing efficiency and accuracy, and is suitable for complex polygons and large data volumes.
Smart Images

Figure CN115471630B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power systems, and more specifically, to a method and apparatus for determining power equipment within a target area. Background Technology
[0002] With the widespread application of geographic information data, the demand for power data analysis at different granularities is becoming increasingly strong in power systems, making the effective acquisition of power data within irregular plots particularly important. A core step in extracting power data from irregular plots is determining whether the metering points corresponding to the power equipment are located within the irregular plots.
[0003] In related technologies, each point is typically compared with all vertices or edges of a polygon. However, this method is computationally intensive and inefficient when dealing with complex irregular plot boundaries or large datasets. In other words, related technologies suffer from the inability to quickly and accurately identify power equipment located within irregular plots.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a method for determining power equipment within a target area, thereby at least addressing the technical problem in related technologies that it is impossible to quickly and accurately determine power equipment located in irregular plots of land.
[0006] According to one aspect of the present invention, a method for determining electrical equipment within a target area is provided, comprising: collecting latitude and longitude data of multiple vertices of the target area and latitude and longitude data of multiple target electrical equipment; obtaining, in a target coordinate system, the coordinates of multiple vertices of the target area and the coordinates of multiple first electrical equipment, wherein the multiple first electrical equipment are devices among the multiple target electrical equipment; dividing the initial area into multiple grids based on multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system, using the target area as an initial area, obtaining multiple first grids; determining multiple second grids located within the target area from the multiple first grids; and based on the multiple... A second grid determines the largest rectangle corresponding to the grid division result within the initial region. The region outside the largest rectangle in the initial region is divided into a first predetermined number of sub-regions. Each of the first predetermined number of sub-regions is then gridded, and the largest rectangle resulting from the grid division within each of the first predetermined number of sub-regions is determined. This process continues, dividing each sub-region outside the largest rectangle into a second predetermined number of sub-regions, performing grid division, and determining the largest rectangle corresponding to the grid division result, until a predetermined division condition is met, resulting in multiple largest rectangles. Based on the coordinates of the multiple first power devices and the determined multiple largest rectangles, multiple second power devices located within the multiple largest rectangles are determined. Based on the coordinates of the multiple second power devices, the target power device located within the target region is determined.
[0007] Optionally, determining the target power device located within the target area based on the coordinates of the plurality of second power devices includes: determining a plurality of third power devices located outside the plurality of largest rectangles among the first power devices; determining a fourth power device located within the target area among the plurality of third power devices based on the coordinates of a plurality of vertices of the target area and the coordinates of the plurality of third power devices; and determining the target power device located within the target area based on the second power devices and the fourth power device.
[0008] Optionally, the step of further dividing the area outside the largest rectangle in the sub-region into a second predetermined number of sub-regions, performing grid division, and determining the largest rectangle of the corresponding grid division result until a predetermined division condition is met to obtain multiple largest rectangles includes: when the predetermined division condition is that the area of the remaining area outside the corresponding largest rectangle in the region is less than a predetermined area threshold, and the grid division of the remaining area outside the corresponding largest rectangle in the region is stopped, determining whether the area of the remaining area outside the corresponding largest rectangle in the second predetermined number of sub-regions is less than the predetermined area threshold; and when the area of the remaining area outside the corresponding largest rectangle in the second predetermined number of sub-regions is less than the predetermined area threshold, stopping the grid division of the remaining area outside the corresponding largest rectangle in the sub-region.
[0009] Optionally, it includes: generating multiple first grid lines that pass through the multiple vertices of the target region and are parallel to the horizontal axis of the target coordinate system, based on the multiple vertices of the target region; and generating multiple second grid lines that pass through the multiple vertices and are parallel to the vertical axis of the target coordinate system, based on the multiple vertices of the target region.
[0010] Optionally, determining the plurality of second grids located within the target region from the plurality of first grids includes: for each of the plurality of first grids: determining whether all grid vertices of the first grid are vertices located within the target region; if all grid vertices of the first grid are vertices located within the target region, determining the first grid as a second grid located within the target region; wherein, determining whether all grid vertices of the first grid are vertices located within the target region includes: for each grid vertex of the first grid, drawing a ray from the grid vertex in a direction parallel to the horizontal or vertical axis of the target coordinate system, obtaining the number of intersection points between the ray and multiple edges of the target region, determining whether the number of intersection points is odd, and if the number is odd, determining the grid vertex as a grid vertex located within the target region.
[0011] Optionally, determining the largest rectangle corresponding to the grid division result within the initial region based on the plurality of second grids includes: for each of the plurality of second grids: marking the second grid as a target grid; determining a plurality of first adjacent grids among the plurality of second grids, wherein the plurality of first adjacent grids are grids whose first sides are collinear with the first side of the target grid and located on a predetermined side of the target grid; obtaining a first rectangle formed by the line segment jointly formed by the first sides of the plurality of first adjacent grids and the first side of the target grid as one side, and composed of the second grids among the plurality of second grids; obtaining the area of the plurality of first rectangles corresponding to the plurality of second grids respectively; and determining the first rectangle with the largest area among the plurality of first rectangles corresponding to the plurality of second grids as the largest rectangle corresponding to the grid division result.
[0012] Optionally, determining the plurality of second power devices located within the plurality of maximum rectangles based on the coordinates of the plurality of first power devices and the determined plurality of maximum rectangles includes: for each of the plurality of first power devices: comparing the coordinates of the first power device with the vertex coordinates of each of the plurality of maximum rectangles; if the x-coordinate of the first power device is between the x-coordinates of two first adjacent vertices of any maximum rectangle, and the y-coordinate of the first power device is between the y-coordinates of two second adjacent vertices of the corresponding maximum rectangle, then the first power device is determined to be a second power device located within the plurality of maximum rectangles.
[0013] Optionally, acquiring the plurality of first power devices includes: determining the circumscribed rectangle of the target region based on the coordinates of multiple vertices of the target region; acquiring the coordinates of the plurality of target power devices based on the latitude and longitude data of the plurality of target power devices; determining whether a target power device among the plurality of target power devices is located inside the circumscribed rectangle based on the coordinates of the plurality of target power devices and the coordinates of multiple vertices of the circumscribed rectangle; and acquiring the coordinates of the plurality of first power devices based on the coordinates of the target power devices located inside the circumscribed rectangle.
[0014] Optionally, determining the circumscribed rectangle of the target region based on the coordinates of multiple vertices of the target region includes: determining a first vertex with the largest x-coordinate, a second vertex with the smallest x-coordinate, a third vertex with the largest y-coordinate, and a fourth vertex with the smallest y-coordinate among the multiple vertices of the target region; a first target line passing through the first vertex and parallel to the y-axis of the target coordinate system, a second target line passing through the second vertex and parallel to the y-axis of the target coordinate system, a third target line passing through the third vertex and parallel to the x-axis of the target coordinate system, and a fourth target line passing through the fourth vertex and parallel to the x-axis of the target coordinate system; and generating the circumscribed rectangle of the target region based on the first target line, the second target line, the third target line, and the fourth target line.
[0015] According to another aspect of the present invention, an apparatus for determining electrical equipment within a target area is also provided, comprising: a data acquisition module, configured to acquire latitude and longitude data of multiple vertices of the target area and latitude and longitude data of multiple target electrical equipment; a first acquisition module, configured to acquire, based on the latitude and longitude data of the multiple vertices and the latitude and longitude data of the multiple target electrical equipment, the coordinates of multiple vertices of the target area and the coordinates of multiple first electrical equipment in a target coordinate system, wherein the multiple first electrical equipment are devices among the multiple target electrical equipment; and a second acquisition module, configured to, using the target area as an initial area, divide the initial area into multiple first grids based on multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system, thereby obtaining multiple first grids, and determining multiple second grids located within the target area from the multiple first grids. The first determination module is used to determine the largest rectangle corresponding to the grid division result within the initial region in the plurality of second grids. The region outside the largest rectangle in the initial region is divided into a first predetermined number of sub-regions. Each of the first predetermined number of sub-regions is then grid-divided, and the largest rectangle of the grid division result within each of the first predetermined number of sub-regions is determined. This process continues, dividing the region outside the largest rectangle in each of the sub-regions into a second predetermined number of sub-regions, performing grid division, and determining the largest rectangle of the corresponding grid division result, until a predetermined division condition is met, resulting in a plurality of largest rectangles. The second determination module is used to determine a plurality of second power devices located within the plurality of largest rectangles based on the coordinates of the plurality of first power devices and the determined plurality of largest rectangles.
[0016] In this embodiment of the invention, latitude and longitude data of multiple vertices in a target area and latitude and longitude data of multiple target power devices are collected. Based on the latitude and longitude data of the multiple vertices and the multiple target power devices, the coordinates of multiple vertices in the target area and the coordinates of multiple first power devices in the target coordinate system are obtained, wherein the multiple first power devices are devices among the multiple target power devices. Taking the target area as an initial area, the initial area is divided into multiple grids based on multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system, resulting in multiple first grids. Multiple second grids located within the target area are determined from the multiple first grids, and the locations of the first grids within the target area are determined based on the multiple second grids. The region within the initial area, excluding the largest rectangle corresponding to the grid division result, is divided into a first predetermined number of sub-regions. Each of these sub-regions is then gridded, and the largest rectangle resulting from the grid division within each sub-region is determined. This process is repeated, dividing each sub-region (excluding the largest rectangle) into a second predetermined number of sub-regions, performing grid division, and determining the largest rectangle for each grid division result, until a predetermined division condition is met, resulting in multiple largest rectangles. Based on the coordinates of the multiple first power devices and the determined multiple largest rectangles, multiple second power devices located within the multiple largest rectangles are identified. Finally, based on the coordinates of the multiple second power devices, the target power device located within the target area is determined. This solves the technical problem in related technologies where it is impossible to quickly and accurately determine power devices located in irregularly shaped plots. Attached Figure Description
[0017] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0018] Figure 1 This is a flowchart of an optional method for determining electrical equipment within a target area according to an embodiment of the present invention;
[0019] Figure 2 This is a flowchart of another optional method for determining electrical equipment within a target area according to an embodiment of the present invention;
[0020] Figure 3 A structural diagram of an optional device for determining electrical equipment within a target area according to an embodiment of the present invention. Detailed Implementation
[0021] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0022] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0023] Example 1
[0024] According to an embodiment of the present invention, a method embodiment for determining electrical equipment within a target area is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0025] Figure 1 This is a method for determining electrical equipment within a target area according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0026] Step S102: Collect latitude and longitude data of multiple vertices in the target area, as well as latitude and longitude data of multiple target power devices;
[0027] Step S104: Based on the latitude and longitude data of multiple vertices and multiple target power devices, obtain the coordinates of multiple vertices in the target area and the coordinates of multiple first power devices in the target coordinate system, wherein the multiple first power devices are devices among the multiple target power devices;
[0028] In some optional embodiments, obtaining multiple first power devices includes: determining the circumscribed rectangle of the target area based on the coordinates of multiple vertices of the target area; obtaining the coordinates of multiple target power devices based on their latitude and longitude data; determining whether a target power device among the multiple target power devices is located inside the circumscribed rectangle based on its coordinates and the coordinates of multiple vertices of the circumscribed rectangle; and obtaining the coordinates of the multiple first power devices based on the coordinates of the target power devices located inside the circumscribed rectangle. It is important to understand that a target power device located outside the circumscribed rectangle of the target area is necessarily a target power device located outside the target area. By determining whether a target power device among the multiple target power devices is located inside the circumscribed rectangle, target power devices located outside the target area can be quickly filtered out, improving processing efficiency and accuracy.
[0029] In some optional embodiments, determining the bounding rectangle of the target region based on the coordinates of multiple vertices of the target region includes: determining a first vertex with the largest x-coordinate, a second vertex with the smallest x-coordinate, a third vertex with the largest y-coordinate, and a fourth vertex with the smallest y-coordinate among the multiple vertices of the target region; establishing a first target line passing through the first vertex and parallel to the y-axis of the target coordinate system, a second target line passing through the second vertex and parallel to the y-axis of the target coordinate system, a third target line passing through the third vertex and parallel to the x-axis of the target coordinate system, and a fourth target line passing through the fourth vertex and parallel to the x-axis of the target coordinate system; and generating the bounding rectangle of the target region based on the first, second, third, and fourth target lines. Generating the bounding rectangle based on the corresponding target lines passing through multiple vertices of the target region is a simple and efficient method.
[0030] Step S106: Using the target area as the initial area, the initial area is divided into multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system to obtain multiple first grids. Multiple second grids located within the target area are determined from the multiple first grids. Based on the multiple second grids, the largest rectangle corresponding to the grid division result within the initial area is determined. The area in the initial area other than the largest rectangle is divided into a first predetermined number of sub-regions. The first predetermined number of sub-regions are divided into grids respectively, and the largest rectangle of the grid division result within the first predetermined number of sub-regions is determined for each sub-region. The area in the sub-regions other than the largest rectangle is divided into a second predetermined number of sub-regions, and the grids are divided and the largest rectangle of the corresponding grid division result is determined, until the predetermined division condition is met, resulting in multiple largest rectangles.
[0031] In some optional embodiments, multiple first grid lines are generated based on multiple vertices of the target region, passing through the vertices and parallel to the horizontal axis of the target coordinate system; multiple second grid lines are also generated based on the multiple vertices of the target region, passing through the vertices and parallel to the vertical axis of the target coordinate system. Since the first and second grid lines are parallel to the horizontal and vertical axes of the target coordinate system, respectively, they are perpendicular to each other. The first grid generated based on the first and second grid lines, and the second grid selected from the first grid, are rectangular. This optional embodiment method can quickly generate grid lines for constructing rectangular grids, and the method is simple.
[0032] In some optional embodiments, determining multiple second grids located within a target region from multiple first grids includes: for each of the multiple first grids, determining whether all vertices of the first grid are located within the target region; if all vertices of the first grid are located within the target region, determining the first grid as a second grid located within the target region. Specifically, determining whether all vertices of the first grid are located within the target region includes: for each vertex of the first grid, drawing a ray from the vertex in a direction parallel to the horizontal or vertical axis of the target coordinate system, obtaining the number of intersection points between the ray and multiple edges of the target region, and determining whether the number of intersection points is odd; if the number is odd, determining the vertex as a vertex located within the target region. This optional embodiment method can quickly and accurately determine the second grids located within the target region.
[0033] In some optional embodiments, determining the largest rectangle corresponding to the grid division result within the initial region based on multiple second grids includes: for each of the multiple second grids: marking the second grid as the target grid; determining multiple first adjacent grids among the multiple second grids, wherein the multiple first adjacent grids are grids whose first edges are collinear with the first edge of the target grid and located on a predetermined side of the target grid; obtaining a first rectangle formed by the line segment jointly formed by the first edges of the multiple first adjacent grids and the first edge of the target grid as one of its edges; obtaining the area of the multiple first rectangles corresponding to the multiple second grids respectively; and determining the first rectangle with the largest area among the multiple first rectangles corresponding to the multiple second grids as the largest rectangle corresponding to the grid division result. Through the method of this optional embodiment, multiple largest rectangles within the target region can be accurately and quickly determined.
[0034] In some optional embodiments, based on the coordinates of multiple first power devices and multiple determined maximum rectangles, multiple second power devices located within the multiple maximum rectangles are determined. This includes: for each first power device, comparing its coordinates with the vertex coordinates of each of the multiple maximum rectangles. If the x-coordinate of the first power device lies between the x-coordinates of two first adjacent vertices of any maximum rectangle, and the y-coordinate of the first power device lies between the y-coordinates of two second adjacent vertices of the corresponding maximum rectangle, then the first power device is determined to be a second power device located within the multiple maximum rectangles. By comparing the x-coordinates and y-coordinates of the first power devices with the coordinates of the vertices of the multiple maximum rectangles, the second power devices located within the multiple maximum rectangles can be quickly determined. It should be understood that a second power device located within any of the multiple maximum rectangles is necessarily a power device located within the target area. Thus, a portion of the power devices located within the target area can be quickly and accurately determined.
[0035] In some optional embodiments, the area outside the largest rectangle in the sub-region is further divided into a second predetermined number of sub-regions, and meshing is performed and the largest rectangle of the corresponding mesh division result is determined, until a predetermined division condition is met, resulting in multiple largest rectangles. This includes: if the area of the remaining area outside the corresponding largest rectangle in the region is less than a predetermined area threshold, and meshing of the remaining area outside the corresponding largest rectangle in the region is stopped, then it is determined whether the area of the remaining area outside the corresponding largest rectangle in the second predetermined number of sub-regions is less than the predetermined area threshold; if the area of the remaining area outside the corresponding largest rectangle in the second predetermined number of sub-regions is less than the predetermined area threshold, meshing of the remaining area outside the corresponding largest rectangle in the sub-regions of the sub-regions is stopped. When the area of the remaining area is sufficiently small, the number of electrical devices located within it may also be sufficiently small. Not further meshing the sufficiently small remaining area can reduce the processing time for meshing and determining the largest rectangle, thus improving the processing efficiency of the method.
[0036] Step S108: Based on the coordinates of the multiple first power devices and the determined multiple maximum rectangles, determine the multiple second power devices located within the multiple maximum rectangles among the multiple first power devices;
[0037] Step S110: Based on the coordinates of multiple second power devices, determine the target power device located within the target area.
[0038] In some optional embodiments, determining the target power device located within the target area based on the coordinates of multiple second power devices includes: determining multiple third power devices located outside multiple maximum rectangles among the first power devices; determining a fourth power device located within the target area among the multiple third power devices based on the coordinates of multiple vertices of the target area and the coordinates of the multiple third power devices; and determining the target power device located within the target area based on the second power devices and the fourth power device. The multiple maximum rectangles occupy a large portion of the target area, and the number of third power devices located outside the multiple maximum rectangles is a small fraction of the multiple first power devices. By using the coordinates of multiple vertices of the target area and the coordinates of the multiple third power devices, the fourth power device located within the target area among the multiple third power devices can be quickly determined, improving processing efficiency. The target power device located within the target area includes multiple second power devices located within the multiple maximum rectangles, and a fourth power device located outside the multiple maximum rectangles but within the target area.
[0039] Based on the above embodiments and optional embodiments, the present invention provides an optional implementation method.
[0040] It's important to understand that current urban power grid electricity consumption analysis is typically divided by region and power supply station. However, in some application scenarios, the focus is often more on buildings, businesses, industrial parks, and commercial districts. Power companies also need more flexible regional divisions when conducting multi-dimensional and diversified power analysis. Effective extraction of power data from irregularly shaped plots becomes particularly important. A core step in extracting power data from irregularly shaped plots is determining whether the metering point is located within the irregular plot.
[0041] In related technologies, it is usually necessary to compare each point with all vertices or edges of a polygon. When the boundaries of irregular plots are complex or the data volume is large, this method is computationally intensive and inefficient. When power companies provide power support services related to GIS (Geographic Information System) data, they are primarily dealing with complex polygonal plots. Therefore, it is necessary to optimize the power data extraction method for irregular plots to improve extraction efficiency. Flexible regional division and effective power data extraction are essential for the rational planning of urban power grids. They can provide strong theoretical support and basic data for the formulation of relevant policies and the allocation of urban resources, thus contributing to the planning and operation of urban power grids.
[0042] In view of this, this optional embodiment provides a method for determining electrical equipment within a target area. This will be described in detail below.
[0043] In this optional implementation, an example is taken of a region with irregularly shaped plots as the target area.
[0044] In this optional embodiment, by acquiring the boundary latitude and longitude data of the irregular plot and the latitude and longitude data of the measurement point, the irregular plot and the measurement point are projected onto the same two-dimensional plane based on Mercator projection, and it is determined whether the measurement point is inside the irregular plot.
[0045] First, based on each vertex of the irregular plot, or combined with a set grid length threshold, divide the irregular plot into multiple grids. Then, calculate the minimum bounding orthogonal rectangle of the irregular plot and remove the measurement points outside the minimum bounding orthogonal rectangle. Mark the grids whose entire area is within the irregular plot as 1. Calculate the sum of the widths of the consecutive grids marked as 1 to the left of each grid marked as 1, enumerate the heights, and calculate the largest all-1 orthogonal rectangle with that grid as its bottom right corner. Traverse each grid marked as 1 to calculate the global largest orthogonal rectangle, i.e., the largest orthogonal rectangle inside the irregular plot. Divide the irregular plot into five parts: inside the rectangle, above the rectangle, below the rectangle, to the left of the rectangle, and to the right of the rectangle. Iterate through the four polygons (top, bottom, left, and right) to find the largest orthogonal rectangle inside each polygon until the area of the found largest orthogonal rectangle is less than a set area threshold. Iterate through all retained measurement points, comparing each point sequentially with the largest internal orthogonal rectangle found. If a measurement point is inside any orthogonal rectangle, it is within the irregular plot. If a measurement point is not inside any orthogonal rectangle, determine whether it is inside the irregular plot using the method for determining whether a point is inside a polygon. It's important to understand that an orthogonal rectangle can be determined by its two diagonal vertices, requiring only two checks to determine if a point is inside. However, determining whether a point is inside a polygon requires comparing it with every edge or vertex, which is much slower than with rectangles, especially for complex polygons and large numbers of data points. This optional implementation optimizes the method for determining whether a measurement point is inside an irregular plot by dividing the region with orthogonal rectangles, improving processing efficiency and accuracy.
[0046] Figure 2 This is a flowchart of another optional method for determining electrical equipment within a target area according to an embodiment of the present invention. (Refer to...) Figure 2 As shown, the method includes the following steps:
[0047] Step 11: Grid division of irregular plots. Set a grid length threshold based on business requirements. Traverse each vertex of the irregular plot, and based on the vertex coordinates and the set threshold, divide the irregular plot into multiple grids.
[0048] Step 12: Obtain the minimum bounding orthogonal rectangle of the irregular plot, determine the measurement points located outside the minimum bounding orthogonal rectangle, and remove the measurement points outside the minimum bounding orthogonal rectangle.
[0049] Step 13: Mark the grid that is entirely located within the irregular plot.
[0050] Specifically, this is done by traversing the grid and marking the grid points. For example, all grid points within the irregular area can be marked as 1, and others as 0. First, the initial grid marking values are all set to 1, assuming the grid is inside the irregular area. Each vertex of the grid is considered a cutting point, and it's determined whether the cutting point is inside the irregular area. The specific determination method is: check if the x-coordinate of the cutting point lies between the x-coordinates of two adjacent points on the polygon. If it does, then check if the horizontal ray from that point intersects with the edge connecting those two adjacent points. If there is an intersection, start counting. Next, iterate through the grid and check if it intersects with other edges of the irregular area, obtaining the total number of intersections between the horizontal ray and the polygon edges. If the total number of intersections is odd, the point is inside the irregular area; if the total number of intersections is even, the point is outside the irregular area. If the cutting point is outside the irregular area, the marking values of the four surrounding grid points are changed to 0.
[0051] Step 14: Determine the largest orthogonal rectangle consisting entirely of grids located within the irregular plot. That is, find the largest orthogonal rectangle consisting of grids marked as 1 (i.e., grids entirely within the irregular plot).
[0052] First, calculate the sum of the widths of the consecutive 1-marked grids to the left of each 1-marked grid in the grid matrix. Then, for each 1-marked grid in the grid matrix, calculate the largest all-1 orthogonal rectangle with that grid as its bottom right corner. By traversing each 1-marked grid in the grid matrix, calculate the global largest orthogonal rectangle, i.e., the largest orthogonal rectangle within the irregular plot.
[0053] Step 15: Iterative operation to find the largest internal orthogonal rectangle in the remaining areas of the irregular plot. Set an area threshold based on business requirements. If the area of the found largest internal orthogonal rectangle is greater than the threshold, divide the irregular plot into five parts: inside the rectangle, above the rectangle, below the rectangle, to the left of the rectangle, and to the right of the rectangle. Iterate through each of the four polygons (top, bottom, left, and right) to find the largest internal orthogonal rectangle until the area of the found largest internal orthogonal rectangle is less than the area threshold.
[0054] Step 16: Determine if the measurement point is inside the irregular plot. Traverse all the measurement points retained after Step 12, and compare each measurement point with the largest internal orthogonal rectangle found in turn. If the measurement point is inside any orthogonal rectangle, stop the comparison and mark the measurement point as 1, that is, the measurement point is inside the irregular plot; if the measurement point is not inside any orthogonal rectangle, determine whether the measurement point is inside the irregular plot based on the coordinates of the measurement point and the vertex coordinates of the irregular area.
[0055] This optional implementation proposes an improved method for determining electrical equipment within a target area. By acquiring the latitude and longitude data of the boundary of an irregular plot and the latitude and longitude data of the metering point, and based on Mercator projection, the irregular plot and the metering point are projected onto the same two-dimensional plane to determine whether the metering point is inside the irregular plot. Here, an orthogonal rectangle can be determined by the two vertices of its diagonal, requiring only two checks to determine if a point is inside the orthogonal rectangle; however, determining a polygon requires comparison with each side or vertex, which is much slower than with a rectangle, especially for complex polygons and a large number of data points. This optional implementation optimizes the method of determining whether a metering point is inside an irregular plot by dividing the area with orthogonal rectangles.
[0056] The method of this optional implementation will be further described in detail below.
[0057] Step 21: Divide the irregular plots into grids.
[0058] Based on business requirements, a grid length threshold T1 is set. For each vertex of the irregular plot, a list of unique x and y values is calculated and sorted in ascending order. Here, x and y represent the x-coordinate and y-coordinate of the vertex, respectively. The x-value and y-value lists are traversed separately. If the difference between two adjacent values is less than the set difference threshold T1, the latter value is deleted, except for the last value. In other words, the maximum value is always retained during processing. After traversing the x-value and y-value lists, the retained x-value and y-value sets are represented as: X = {X0, X1, ..., Xn} and Y = {Y0, Y1, ..., Ym}, respectively. Here, X0, X1, Xn represent the x-values of the 1st, 2nd, and (n+1th)th vertices, respectively, and Y0, Y1, Yn represent the y-values of the 1st, 2nd, and (n+1th)th vertices, respectively. These two sets of data divide the irregular plot into m×n grids.
[0059] Step 22: Calculate the minimum bounding orthogonal rectangle Rc of the irregular plot and remove the measurement points outside the minimum bounding orthogonal rectangle.
[0060] Let Rc = {(X0, Y0), (Xk, Yk)} be the set of vertex coordinates of the minimum bounding orthogonal rectangle, where X0 and Y0 represent the x-coordinate and y-coordinate of a vertex of the bounding orthogonal rectangle, respectively, and Xk and Yk represent the x-coordinate and y-coordinate of the vertex diagonally opposite to the vertex with coordinates (X0, Y0), respectively. For each measurement point, determine whether it lies within the minimum bounding orthogonal rectangle by checking if its x-coordinate is between X0 and Xk, and its y-coordinate is between Y0 and Yk. If not, delete the measurement point.
[0061] Step 23: Traverse the grid and mark it. If the entire grid area is within an irregular plot, mark it as 1; otherwise, mark it as 0.
[0062] Two matrices are defined: a grid matrix r[i][j] (1≤i≤m,1≤j≤n), where r[i][j] represents the grid in the i-th row and j-th column, where i and j represent the i-th grid intersection in the horizontal direction and the j-th grid intersection in the vertical direction, respectively, and m and n represent the total number of grid intersections in the horizontal and vertical directions, respectively. In one embodiment, to better match the coordinate system, rows are sorted from bottom to top, and columns are sorted from left to right. The stored data is the grid width w, height h, and marker r_mark. The splitting point matrix p[i][j] (0≤i≤m,0≤j≤n) represents the data point in the i-th row and j-th column, storing the coordinates (x,y) of the splitting point and the marker p_mark. If the splitting point is outside the irregular plot, it is marked as 0; otherwise, it is marked as 1. Clearly, the index [i][j] of a grid cell in the grid matrix is equal to the index of its top-right corner point in the splitting point matrix. Knowing the top-right corner point naturally tells us the data points of the entire grid. Obviously, the four grid cells surrounding the splitting point p[i][j] are r[i][j], r[i][j+1], r[i+1][j], and r[i+1][j+1]. When the splitting point p[i][j] is outside the irregular plot, each of its four surrounding grid cells r[i][j], r[i][j+1], r[i+1][j], and r[i+1][j+1] must have a portion outside the irregular plot.
[0063] First, traverse the grid matrix r[i][j], and set the initial value of the marker r_mark to 1, which defaults to inside the irregular plot.
[0064] Then, iterate through the dividing point matrix p[i][j], where the dividing point coordinates (x, y) = (Xj, Yi), and determine whether the point is inside the irregular plot. Here, Xj and Yi represent the x and y coordinates of the dividing point, respectively. The determination method is as follows: check if the x-coordinate of the point lies between the x-coordinates of two adjacent points on the polygon. If it does, then check if the horizontal ray from that point intersects with the edge connecting these two adjacent points. If there is an intersection, start counting. Next, iterate through the polygon and check if the point intersects with other edges of the irregular plot, obtaining the total number of intersections between the horizontal ray and the polygon edges. If the total number of intersections is odd, the point is inside the irregular plot; if the total number of intersections is even, the point is outside the irregular plot. If the splitting point p[i][j] is outside the irregular plot, the value of p_mark is 0, and the value of the r_mark of the four surrounding grids r[i][j], r[i][j+1], r[i+1][j], and r[i+1][j+1] is changed to 0; if the splitting point p[i][j] is inside the irregular plot, the value of p_mark is 1.
[0065] Step 24: Find the largest orthogonal rectangle formed by the grids marked as 1 (i.e., all grids within the irregular plots).
[0066] First, calculate the width and width[i][j] of the consecutive 1-marked grids to the left of each 1-marked grid in the grid matrix. Then, for each 1-marked grid r[i][j] in the grid matrix, calculate the largest all-1 orthogonal rectangle with that grid as its bottom right corner. Enumerate all k values satisfying i≤k<t (t is the row containing the first 0-marked grid encountered). The maximum width of the rectangle is the minimum of width[i][j], width[i+1][j], ..., width[k][j], and the height is the sum of h[i][j], h[i+1][j], ..., h[k][j]. The rectangle with the largest area is the largest orthogonal rectangle with grid r[i][j] as its bottom right corner. Traverse each 1-marked grid in the grid matrix to calculate the global largest orthogonal rectangle, i.e., the largest orthogonal rectangle S0 inside the irregular plot.
[0067] In one embodiment, a time complexity of O(M²N) is considered, where M and N are the number of rows and columns of the matrix, respectively. Calculating width[i][j] takes O(MN) time. For each grid cell in the grid matrix, enumerating the height takes O(M) time. Therefore, the total time complexity is O(MN) + O(MN)·O(M) = O(M²N).
[0068] Step 25: Iterate through the remaining areas of the irregular plot to find the largest orthogonal rectangle inside.
[0069] Based on business requirements, a predetermined area threshold T2 is set. If the area of the rectangle S0 > T2, the irregular plot is divided into five parts: the interior of the rectangle S0, the area above the rectangle A1, the area below the rectangle A2, the area to the left of the rectangle A3, and the area to the right of the rectangle A4. Iterative operations are performed on A1, A2, A3, and A4 respectively until the area of the largest orthogonal rectangle Sk is found to be less than the predetermined area threshold T2.
[0070] Step 26: Determine whether the measurement point is inside an irregular plot of land.
[0071] Traverse all the measurement points retained after step 22, and compare each measurement point with the orthogonal rectangles S0, S1, ..., Sk in turn. If the measurement point is inside any of the orthogonal rectangles, stop the comparison and mark the measurement point as 1, that is, the measurement point is inside the irregular plot. If the measurement point is not inside any of the orthogonal rectangles, determine whether the measurement point is inside the irregular plot according to the method of determining whether the point is inside the polygon in step 3.
[0072] This optional implementation proposes an improved method for extracting electricity data from irregularly shaped plots. By dividing the area into orthogonal rectangles, the method optimizes the extraction process for irregularly shaped plots. This means that when determining whether a metering point is within an irregular plot, most points only need to be compared with the orthogonal rectangles, while only a small number need to be compared with every vertex or edge of the irregular plot. This optional implementation demonstrates good optimization performance when the scale of metering data is large.
[0073] Example 2
[0074] Figure 3 A structural diagram of an optional device for determining electrical equipment within a target area according to an embodiment of the present invention. (Refer to...) Figure 3 As shown, the device includes a data acquisition module 302, a first acquisition module 304, a second acquisition module 306, a first determination module 308, and a second determination module 310, which will be described in detail below.
[0075] The acquisition module 302 is used to acquire latitude and longitude data of multiple vertices in the target area, as well as latitude and longitude data of multiple target power devices. The first acquisition module 304, connected to the acquisition module 302, is used to acquire, based on the latitude and longitude data of the multiple vertices and the multiple target power devices, the coordinates of multiple vertices in the target area and the coordinates of multiple first power devices in the target coordinate system, wherein the multiple first power devices are devices among the multiple target power devices. The second acquisition module 306, connected to the first acquisition module 304, is used to divide the initial area into grids based on multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system, obtaining multiple first grids, determining multiple second grids located within the target area from the multiple first grids, and determining, based on the multiple second grids, grids located within the initial area and connected to the grid. The largest rectangle corresponding to the grid division result is used to divide the area outside the largest rectangle in the initial area into a first predetermined number of sub-regions. Each of the first predetermined number of sub-regions is then gridded, and the largest rectangle of the grid division result within each of the first predetermined number of sub-regions is determined. This process continues, dividing the area outside the largest rectangle in each of the sub-regions into a second predetermined number of sub-regions, performing grid division, and determining the largest rectangle of the corresponding grid division result, until a predetermined division condition is met, resulting in multiple largest rectangles. A first determining module 308, connected to the second obtaining module 306, is used to determine multiple second power devices located within the multiple largest rectangles based on the coordinates of the multiple first power devices and the coordinates of the determined multiple largest rectangles. A second determining module 310, connected to the first determining module 308, is used to determine the target power device located within the target area based on the coordinates of the multiple second power devices.
[0076] It should be noted that the above-mentioned acquisition module 302, first acquisition module 304, second acquisition module 306, first determination module 308, and second determination module 310 correspond to steps S102 to S110 in Embodiment 1. The instances and application scenarios implemented by these modules and their corresponding steps are the same, but they are not limited to the content disclosed in the above embodiments.
[0077] Example 3
[0078] Embodiments of this invention can provide a computer device. Optionally, in this embodiment, the computer device may be located in at least one of a plurality of network devices in a computer network. The computer device includes a memory and a processor.
[0079] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the data processing method and apparatus in this embodiment of the invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby realizing the aforementioned data processing method. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0080] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0081] Embodiments of the present invention also provide a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the method provided in Embodiment 1.
[0082] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0083] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0084] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0085] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0086] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0087] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0088] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0089] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A method for determining electrical equipment within a target area, characterized in that, include: Collect latitude and longitude data of multiple vertices in the target area, as well as latitude and longitude data of multiple target power equipment; Based on the latitude and longitude data of the multiple vertices and the latitude and longitude data of the multiple target power devices, the coordinates of the multiple vertices of the target area and the coordinates of the multiple first power devices are obtained in the target coordinate system, wherein the multiple first power devices are devices among the multiple target power devices; Using the target region as the initial region, the initial region is divided into multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system to obtain multiple first grids. Multiple second grids located within the target region are determined from the multiple first grids. Based on the multiple second grids, the largest rectangle corresponding to the grid division result within the initial region is determined. The region in the initial region other than the largest rectangle is divided into a first predetermined number of sub-regions. The first predetermined number of sub-regions are divided into grids respectively, and the largest rectangle of the grid division result within the first predetermined number of sub-regions is determined for each sub-region. The region in the sub-region other than the largest rectangle is further divided into a second predetermined number of sub-regions, and the grids are divided and the largest rectangle of the corresponding grid division result is determined, until a predetermined division condition is met, resulting in multiple largest rectangles. Based on the coordinates of the plurality of first power devices and the coordinates of the plurality of determined largest rectangles, determine the plurality of second power devices located within the plurality of largest rectangles among the plurality of first power devices; Identify a plurality of third power devices located outside the plurality of largest rectangles in the first power device; determine a fourth power device located within the target area in the plurality of third power devices based on the coordinates of a plurality of vertices of the target area and the coordinates of the plurality of third power devices; determine the target power device located within the target area based on the second power device and the fourth power device.
2. The method according to claim 1, characterized in that, The process continues by dividing the sub-regions, excluding the largest rectangle, into a second predetermined number of sub-regions, performing grid division, and determining the largest rectangle for each grid division result, until a predetermined division condition is met, resulting in multiple largest rectangles, including: If the predetermined division condition is that the area of the remaining area outside the corresponding maximum rectangle in the region is less than a predetermined area threshold, and the grid division of the remaining area outside the corresponding maximum rectangle in the region is stopped, then it is determined whether the area of the remaining area outside the corresponding maximum rectangle in the second predetermined number of sub-regions is less than the predetermined area threshold. If the area of the remaining area in the second predetermined number of sub-regions, excluding the corresponding maximum rectangle, is less than the predetermined area threshold, then the meshing of the remaining area in the sub-regions, excluding the corresponding maximum rectangle, is stopped.
3. The method according to claim 1, characterized in that, include: Based on multiple vertices of the target region, multiple first grid lines are generated that pass through the multiple vertices and are parallel to the horizontal axis of the target coordinate system; Based on multiple vertices of the target region, multiple second grid lines are generated that pass through the multiple vertices and are parallel to the vertical axis of the target coordinate system.
4. The method according to claim 1, characterized in that, The step of determining the plurality of second grids located within the target area from the plurality of first grids includes: For each of the plurality of first grids: determine whether all grid vertices of the first grid are vertices located within the target region; if all grid vertices of the first grid are vertices located within the target region, determine that the first grid is a second grid located within the target region. The step of determining whether all grid vertices of the first grid are located within the target region includes: for each grid vertex of the first grid, drawing a ray from the grid vertex in a direction parallel to the horizontal or vertical axis of the target coordinate system, obtaining the number of intersection points between the ray and multiple edges of the target region, determining whether the number of intersection points is odd, and if the number is odd, determining that the grid vertex is a grid vertex located within the target region.
5. The method according to claim 1, characterized in that, The step of determining the largest rectangle within the initial region corresponding to the grid division result based on the plurality of second grids includes: For each of the plurality of second grids: mark the second grid as the target grid, determine a plurality of first adjacent grids among the plurality of second grids, wherein the plurality of first adjacent grids are grids whose first side is collinear with the first side of the target grid and located on a predetermined side of the target grid, and obtain a first rectangle formed by the line segment jointly formed by the first side of the plurality of first adjacent grids and the first side of the target grid as one side, and composed of the second grids among the plurality of second grids; Obtain the area of each of the first rectangles corresponding to the plurality of second grids; The largest first rectangle among the multiple first rectangles corresponding to the multiple second grids is determined as the largest rectangle corresponding to the grid division result.
6. The method according to claim 1, characterized in that, The step of determining, based on the coordinates of the plurality of first power devices and the determined plurality of largest rectangles, a plurality of second power devices located within the plurality of largest rectangles includes: For each of the plurality of first power devices: the coordinates of the first power device are compared with the vertex coordinates of each of the plurality of largest rectangles. If the x-coordinate of the first power device is between the x-coordinates of two first adjacent vertices of any largest rectangle, and the y-coordinate of the first power device is between the y-coordinates of two second adjacent vertices of the corresponding largest rectangle, then the first power device is determined to be a second power device located within the plurality of largest rectangles.
7. The method according to claim 1, characterized in that, The acquisition of multiple first power devices includes: The bounding rectangle of the target region is determined based on the coordinates of multiple vertices of the target region; Based on the latitude and longitude data of the multiple target power devices, obtain the coordinates of the multiple target power devices; Based on the coordinates of the plurality of target power devices and the coordinates of the plurality of vertices of the circumscribed rectangle, determine whether one of the plurality of target power devices is located inside the circumscribed rectangle; The coordinates of the plurality of first power devices are obtained based on the coordinates of the target power device located inside the outer rectangle among the plurality of target power devices.
8. The method according to claim 7, characterized in that, Determining the bounding rectangle of the target region based on the coordinates of multiple vertices of the target region includes: Determine the first vertex with the largest x-coordinate, the second vertex with the smallest x-coordinate, the third vertex with the largest y-coordinate, and the fourth vertex with the smallest y-coordinate among multiple vertices in the target region; A first target line passing through the first vertex and parallel to the vertical axis of the target coordinate system; a second target line passing through the second vertex and parallel to the vertical axis of the target coordinate system; a third target line passing through the third vertex and parallel to the horizontal axis of the target coordinate system; and a fourth target line passing through the fourth vertex and parallel to the horizontal axis of the target coordinate system. The outer rectangle of the target region is generated based on the first target line, the second target line, the third target line, and the fourth target line.
9. A device for determining electrical equipment within a target area, characterized in that, include: The acquisition module is used to acquire latitude and longitude data of multiple vertices in the target area, as well as latitude and longitude data of multiple target power devices; The first acquisition module is used to acquire, in the target coordinate system, the coordinates of multiple vertices in the target area and the coordinates of multiple first power devices, based on the latitude and longitude data of the multiple vertices and the latitude and longitude data of the multiple target power devices, wherein the multiple first power devices are devices among the multiple target power devices; The second acquisition module is used to divide the initial region into multiple first grids based on multiple first grid lines parallel to the horizontal axis of the target coordinate system and multiple second grid lines parallel to the vertical axis of the target coordinate system, taking the target region as the initial region. It then determines multiple second grids located within the target region from the multiple first grids, determines the largest rectangle corresponding to the grid division result within the initial region based on the multiple second grids, divides the region in the initial region excluding the largest rectangle into a first predetermined number of sub-regions, performs grid division on each of the first predetermined number of sub-regions, and determines the largest rectangle of the grid division result within each of the first predetermined number of sub-regions. It continues to divide the region in the sub-regions excluding the largest rectangle into a second predetermined number of sub-regions, performs grid division, and determines the largest rectangle of the corresponding grid division result, until a predetermined division condition is met, resulting in multiple largest rectangles. The first determining module is used to determine, based on the coordinates of the plurality of first power devices and the determined plurality of maximum rectangles, a plurality of second power devices located within the plurality of maximum rectangles; The second determining module is used to determine a plurality of third power devices located outside the plurality of largest rectangles in the first power device; determine a fourth power device located within the target area in the plurality of third power devices based on the coordinates of a plurality of vertices of the target area and the coordinates of the plurality of third power devices; and determine the target power device located within the target area based on the second power device and the fourth power device.
Citation Information
Patent Citations
Analysis method of unmanned aerial vehicle detection range
CN106127853A
Irregular area node positioning method and device for sensor network
CN107613502A