A method and system for batch operation of lighting equipment based on polygon selection
By drawing polygonal selection boxes on the spatial visualization interface and combining the minimum bounding rectangle and ray method for judgment, the problem of flexibility and efficient conversion in the selection of urban lighting equipment areas is solved, and efficient and accurate equipment screening and operation are achieved.
Patent Information
- Application Number
- CN202611180910.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-05
- Publication Date
- 2026-11-06
AI Technical Summary
In existing technologies, the selection of equipment areas for urban lighting fixtures lacks flexibility and cannot meet the needs of temporary cross-regional instant selection. Furthermore, the conversion efficiency from screen pixel coordinates to geographical latitude and longitude is low, and the boundary processing is imperfect.
This paper provides a batch operation method for lighting equipment based on polygon selection. By freely drawing arbitrary polygons in a spatial visualization interface, and combining minimum bounding rectangle filtering and ray casting, it achieves efficient equipment selection and accurate conversion.
It enables real-time response and efficient device filtering in scenarios with a large number of devices, improves the accuracy of region selection and conversion efficiency, and meets the needs of temporary cross-regional operations.
Smart Images

Figure CN123047838A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of GIS geographic information systems and lighting equipment management technology, specifically to a method and system for performing batch operations on lighting equipment in geographic space using polygon selection on a spatial visualization interface. Background Technology
[0002] With the advancement of smart city construction, the deployment scale of city-level lighting fixtures is rapidly increasing, with the number of streetlights in a single city reaching hundreds of thousands. In daily operation and maintenance, operators often need to perform batch operations on equipment by geographical area, such as uniformly switching, dimming, or changing scenes for lights along a specific block or road. Current mainstream methods for selecting equipment spatial areas have the following shortcomings: Pre-grouping equipment by administrative divisions or grids based on preset areas lacks flexibility and cannot handle temporary, cross-regional, real-time selection needs. Furthermore, user-drawn polygons are represented by screen pixel coordinates, which need to be converted to geographic latitude and longitude. Existing solutions typically use native map engine interfaces for this conversion, but this is inefficient under specific map views and conditions, and its handling of boundary conditions is inadequate. Summary of the Invention
[0003] One of the objectives of this invention is to provide a method and system for batch operation of lighting equipment based on polygon selection. The method and system allow users to freely draw closed polygons of any shape on a spatial visualization interface to select target areas, replacing traditional rectangular selection and improving the accuracy of area selection.
[0004] Another objective of this invention is to provide a method and system for batch operation of lighting equipment based on polygon bounding box selection. The method and system offer a two-stage screening mechanism combining rectangular coarse screening and polygon fine screening. First, a subset of candidate devices is quickly extracted from the device layer using the smallest bounding rectangle of the polygon, significantly reducing the number of devices to be precisely judged from the full set. Then, the candidate subset is individually evaluated using a ray casting method to determine whether each device contains another polygon. This mechanism controls the computational load without sacrificing accuracy, enabling real-time response for polygon bounding box selection in scenarios with a massive number of devices.
[0005] Another objective of this invention is to provide a method and system for batch operation of lighting equipment based on polygon selection. The method and system provide an efficient way to convert screen coordinates to geographic coordinates. When the map is in a vertical top-down view, linear mapping calculation is directly performed using the ratio between the viewport boundary and the canvas size, avoiding the overhead of calling the native interface of the map engine. At the same time, the native conversion capability in the non-top-down view is retained, and longitude boundary correction is performed on the conversion result.
[0006] To achieve at least one of the above-mentioned objectives, the present invention further provides a method for batch operation of lighting equipment based on polygon selection, the method comprising: The interface receives the polygon selection area drawn by the user on the spatial visualization interface, records the screen pixel coordinates of each vertex of the polygon, converts the screen pixel coordinates of each vertex into geographic latitude and longitude coordinates, and obtains the set of latitude and longitude coordinates of the polygon vertices. The minimum bounding rectangle is calculated based on the set of latitude and longitude coordinates of the polygon vertices, and the set of candidate devices within the rectangle is obtained from the device layer using the minimum bounding rectangle; The ray casting method is used to determine the polygonal inclusion of each device in the candidate device set, and the target device dataset located within the polygonal region is selected. Batch operation instructions are then executed on the target device dataset.
[0007] According to a preferred embodiment of the present invention, the process of converting the screen pixel coordinates into geographic latitude and longitude coordinates includes: Determine whether the current map view is in a vertical overhead view and satisfies the linear mapping condition; If the conditions are met, a linear mapping is performed based on the ratio between the latitude and longitude boundaries of the current viewport and the canvas size. The longitude is calculated as: lng = (point.x - viewport.x) × viewport.width / boundsRange.lng + bounds.sw.lng, and the latitude is calculated as: lat = bounds.ne.lat - (point.y - viewport.y) × viewport.height / boundsRange.lat. Here, boundsRange.lng represents the longitude span, boundsRange.lat represents the latitude span, bounds.sw.lng represents the longitude of the southwest corner, and bounds.ne.lat represents the latitude of the northeast corner. Viewport represents the viewport, point represents the screen pixel, x and y represent the coordinate values, and width and height represent the length and height, respectively. The converted longitude value is corrected, and normalization is performed when the longitude exceeds the range of -180° to 180°. If the linear mapping conditions are not met, the map engine's native coordinate conversion interface is called.
[0008] According to another preferred embodiment of the present invention, the method for calculating the minimum bounding rectangle is as follows: traverse each vertex in the set of latitude and longitude of the polygon vertices, compare the latitude and longitude of each vertex, and record the minimum latitude minLat, the maximum latitude maxLat, the minimum longitude minLng, and the maximum longitude maxLng. From these four boundary values, the four vertices of the minimum bounding rectangle are obtained: A0(minLng, minLat), A1(minLng, maxLat), A2(maxLng, minLat), and A3(maxLng, maxLat).
[0009] According to another preferred embodiment of the present invention, when obtaining candidate devices within a rectangular range from the device layer, the following judgment is made regarding whether the device's latitude and longitude are within the rectangular range: invalid coordinates with both latitude and longitude being zero are excluded; it is determined whether the device's latitude is between the latitude of the south boundary and the latitude of the north boundary of the rectangle, and if not, it is excluded; if the longitude of the left boundary of the rectangle is greater than the longitude of the right boundary, it indicates that the rectangle crosses the International Date Line, and the device's longitude is determined to be within the range if it satisfies "greater than or equal to the longitude of the left boundary or less than or equal to the longitude of the right boundary"; otherwise, the device's longitude must simultaneously satisfy "greater than or equal to the longitude of the left boundary and less than or equal to the longitude of the right boundary".
[0010] According to another preferred embodiment of the present invention, the process of determining whether a device is inside a polygon using the ray method is as follows: a horizontal scan line is generated from the device point to be detected; each edge of the polygon is traversed, and the two endpoints of the edge are sorted in ascending order of latitude to determine whether the edge intersects with the scan line; a cross product operation is performed on the intersecting edges, and if the cross product is zero, the device point is on the edge of the polygon and is directly determined to be inside; if the cross product is greater than zero, the crossing counter is incremented by one; after traversal, if the crossing counter is odd, the device point is inside the polygon, and if it is even, it is outside.
[0011] According to another preferred embodiment of the present invention, the cross product operation is: crossProduct=(item.lng-a.lng)×(b.lat-a.lat)-(b.lng-a.lng)×(item.lat-a.lat), where a and b are the two endpoints of the current edge of the polygon, item is the latitude and longitude of the device point to be detected, lat represents latitude, and lng represents longitude.
[0012] According to another preferred embodiment of the present invention, the device is a lighting fixture deployed in geographic space, and the batch operation instructions include one or more of batch switching, batch brightness adjustment, batch color temperature adjustment, batch scene switching, batch firmware upgrade, and batch parameter configuration.
[0013] According to another preferred embodiment of the present invention, the spatial visualization interface is a WebGIS map interaction interface, in which the user sequentially determines each vertex of the polygon by clicking with the mouse or by touching, and completes the polygon drawing by double-clicking or clicking the close button.
[0014] To achieve at least one of the above-mentioned objectives, the present invention also provides a batch operating system for lighting devices based on polygon selection, comprising: a polygon selection interaction module for receiving a polygon selection area drawn by a user on a spatial visualization interface and recording the screen pixel coordinates of each vertex of the polygon; a coordinate transformation module for converting the screen pixel coordinates of each vertex into geographic latitude and longitude coordinates and outputting a set of latitude and longitude coordinates of the polygon vertices; a candidate device filtering module for calculating the minimum bounding rectangle based on the set of latitude and longitude coordinates of the polygon vertices and using the minimum bounding rectangle to obtain a set of candidate devices within the rectangular range from the device layer; a polygon precision judgment module for using the ray casting method to determine the polygon inclusion of each device in the candidate device set and filtering out the target device dataset located within the polygon region; and a batch operation execution module for executing batch operation instructions on the target device dataset.
[0015] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-described method for batch operation of lighting equipment based on polygon selection. Attached Figure Description
[0016] Figure 1 The diagram shown is a flowchart of a batch operation method for lighting equipment based on polygon selection according to the present invention. Detailed Implementation
[0017] The following description is intended to disclose the present invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art. The basic principles of the invention defined in the following description can be applied to other embodiments, modifications, improvements, equivalents, and other technical solutions that do not depart from the spirit and scope of the invention.
[0018] It is understood that the term "a" should be understood as "at least one" or "one or more," that is, in one embodiment, the number of an element can be one, while in another embodiment, the number of the element can be multiple, and the term "a" should not be understood as a limitation on the number.
[0019] Please combine Figure 1 This invention discloses a method and system for batch operation of lighting equipment based on polygon selection, wherein the method mainly includes the following steps: S01. Receive the polygon selection area drawn by the user on the spatial visualization interface, record the screen pixel coordinates of each vertex of the polygon, convert the screen pixel coordinates of each vertex into geographic latitude and longitude coordinates, and obtain the set of latitude and longitude coordinates of the polygon vertices. S02. Calculate the minimum bounding rectangle based on the set of latitude and longitude of the polygon vertices, and use the minimum bounding rectangle to obtain a set of candidate devices within the rectangular range from the device layer; S03. Use the ray casting method to determine the polygonal inclusion of each device in the candidate device set, filter out the target device dataset located within the polygonal region, and execute batch operation instructions on the target device dataset.
[0020] Specifically, the method employs screen coordinate to geographic coordinate conversion technology, minimum bounding rectangle fast filtering technology, and ray-based polygon inclusion judgment technology. The overall process is as follows: the user draws a closed polygon by clicking with the mouse on the WebGIS interface, and the system records the screen pixel coordinates of each vertex of the polygon: points = [(x1, y1), (x2, y2), ..., (x...). n , y n Convert the screen pixel coordinates of each vertex to geographic latitude and longitude coordinates; calculate the minimum bounding rectangle of the polygon based on the vertex latitude and longitude set; use the minimum bounding rectangle to extract the candidate device set from the lighting layer; use the ray casting method to determine the polygon internal inclusion of each device in the candidate device set, and filter out the target device dataset; finally, perform batch operations on the target devices.
[0021] The specific implementation of each step is detailed below.
[0022] Regarding the conversion from screen pixel coordinates to geographic latitude and longitude coordinates: Coordinate transformation is performed on each vertex in the vertex coordinate set. First, it is determined whether the current map is in a vertical top-down view (map.tilt=== 0) and supports linear mapping (canUse is true). If the conditions are met, a linear mapping algorithm based on the viewport boundary ratio is used. The screen pixel boundaries of the current viewport (viewport.x, viewport.y, viewport.width, viewport.height) and the corresponding geographic boundary range of the viewport (boundsRange.lng represents the longitude span, boundsRange.lat represents the latitude span, bounds.sw.lng represents the southwest longitude, and bounds.ne.lat represents the northeast latitude) are obtained. For any screen pixel point(x,y), the longitude lng = (point.x - viewport.x) × viewport.width / boundsRange.lng + bounds.sw.lng, and the latitude lat = bounds.ne.lat - (point.y - viewport.y) × viewport.height / boundsRange.lat. This algorithm can be completed using only four arithmetic operations, without involving map engine interface calls, resulting in extremely low performance overhead. After conversion, the longitude is normalized: when lng > 180, lng = lng - 360; when lng < -180, lng = lng + 360. If the map does not meet the linear mapping conditions (e.g., under tilted viewpoint), the native pixelToLatLng interface of the map engine is called to complete the conversion.
[0023] The calculation of the minimum bounding rectangle involves iterating through the latitude and longitude coordinates of all vertices of the polygon and comparing them to obtain the minimum latitude (minLat), maximum latitude (maxLat), minimum longitude (minLng), and maximum longitude (maxLng). These four values form the coordinates of the four vertices of the minimum bounding rectangle: A0(minLng, minLat), A1(minLng, maxLat), A2(maxLng, minLat), and A3(maxLng, maxLat). This rectangle completely encloses the polygon and has the smallest area.
[0024] Regarding the use of rectangle coarse screening to obtain candidate devices: The process iterates through all lamp data in the lamp layer, calling a rectangle range judgment function for each lamp to determine if its latitude and longitude fall within the minimum bounding rectangle. The judgment logic is as follows: First, check if both latitude and longitude are zero values; if so, return "not within range". Next, check the latitude; the lamp's latitude must be within the interval [minLat, maxLat]. If it is not within this interval, return "not within range". Finally, check the longitude, with two cases: if minLng > maxLng, it indicates the rectangle crosses the International Date Line, and the lamp's longitude is ≥minLng or ≤maxLng, thus being within range; if minLng ≤ maxLng, the lamp's longitude must simultaneously satisfy ≥minLng and ≤maxLng. This step includes all lamps located within the minimum bounding rectangle into the candidate device set.
[0025] Regarding the ray-based polygon screening: For each device in the candidate device set, a polygon containment check is performed. Starting from the device point item(item.lat, item.lng), a horizontal scan line is drawn along the latitude direction. Each edge of the polygon is traversed, with the two endpoints of the current edge being a and b (a being the current vertex lines[i], and b being the next vertex lines[(i+1)%lines.length]). First, a and b are sorted in ascending order of latitude (if a.lat > b.lat, they are swapped). If a.lat ≤ item.lat and b.lat > item.lat, then the edge intersects the scan line. The cross product crossProduct = (item.lng - a.lng) × (b.lat - a.lat) - (b.lng - a.lng) × (item.lat - a.lat). If crossProduct is zero, the device point falls on the edge of the polygon and is directly determined to be inside the polygon. If crossProduct > 0, the crossover counter count is incremented. After traversing all edges, if the count is odd, the device is inside the polygon; if it is even, it is outside. The algorithm has a time complexity of O(n) for each device, where n is the number of vertices in the polygon. Typically, n is small (the number of vertices in a user-drawn polygon is usually no more than a few dozen), so the computational overhead in the fine-tuning stage is controllable.
[0026] The processes described in the flowcharts above, as disclosed in the embodiments of this invention, can be implemented as computer software programs. The embodiments disclosed in this invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication component, and / or installed from a removable medium. When the computer program is executed by a central processing unit (CPU), the methods of this application are not limited to the aforementioned functions. It should be noted that the computer-readable medium described above in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more conductor segments, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wired, optical fiber, RF, etc. Or any suitable combination of the above.
[0027] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation that may be implemented in systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0028] Those skilled in the art should understand that the embodiments of the present invention described above and shown in the accompanying drawings are merely examples and do not limit the present invention. The purpose of the present invention has been fully and effectively achieved. The functions and structural principles of the present invention have been shown and explained in the embodiments. Without departing from the stated principles, the implementation of the present invention may have any variations or modifications.
Claims
1. A method for batch operation of luminaire devices based on polygonal marquing, characterized in that, The method includes: The interface receives the polygon selection area drawn by the user on the spatial visualization interface, records the screen pixel coordinates of each vertex of the polygon, converts the screen pixel coordinates of each vertex into geographic latitude and longitude coordinates, and obtains the set of latitude and longitude coordinates of the polygon vertices. The minimum bounding rectangle is calculated based on the set of latitude and longitude coordinates of the polygon vertices, and the set of candidate devices within the rectangle is obtained from the device layer using the minimum bounding rectangle; The ray casting method is used to determine the polygonal inclusion of each device in the candidate device set, and the target device dataset located within the polygonal region is selected. Batch operation instructions are then executed on the target device dataset.
2. The method of claim 1, wherein the method is characterized by: The process of converting screen pixel coordinates into geographic latitude and longitude coordinates includes: Determine whether the current map view is in a vertical overhead view and satisfies the linear mapping condition; If the conditions are met, a linear mapping is performed based on the ratio between the latitude and longitude boundaries of the current viewport and the canvas size. The longitude is calculated as: lng = (point.x - viewport.x) × viewport.width / boundsRange.lng + bounds.sw.lng, and the latitude is calculated as: lat = bounds.ne.lat - (point.y - viewport.y) × viewport.height / boundsRange.lat. Here, boundsRange.lng represents the longitude span, boundsRange.lat represents the latitude span, bounds.sw.lng represents the longitude of the southwest corner, and bounds.ne.lat represents the latitude of the northeast corner. Viewport represents the viewport, point represents the screen pixel, x and y represent the coordinate values, and width and height represent the length and height, respectively. The converted longitude value is corrected, and normalization is performed when the longitude exceeds the range of -180° to 180°. If the linear mapping conditions are not met, the map engine's native coordinate conversion interface is called. 3.The method of claim 1, wherein, The method for calculating the minimum bounding rectangle is as follows: traverse each vertex in the set of latitude and longitude of the polygon vertices, compare the latitude and longitude of each vertex, and record the minimum latitude minLat, maximum latitude maxLat, minimum longitude minLng, and maximum longitude maxLng. From these four boundary values, the four vertices of the minimum bounding rectangle are obtained: A0(minLng,minLat), A1(minLng,maxLat), A2(maxLng,minLat), and A3(maxLng,maxLat).
4. The method of claim 1, wherein the method further comprises: When retrieving candidate devices within a rectangular area from the device layer, the following checks are made to determine whether the device's latitude and longitude are within the rectangular area: invalid coordinates with both latitude and longitude values being zero are excluded; the device's latitude is determined to be between the latitude of the south boundary and the latitude of the north boundary of the rectangle, and if not, it is excluded; if the longitude of the left boundary of the rectangle is greater than the longitude of the right boundary, it indicates that the rectangle crosses the International Date Line, and the device's longitude is determined to be within the range if it meets the condition of "greater than or equal to the longitude of the left boundary or less than or equal to the longitude of the right boundary"; otherwise, the device's longitude must simultaneously meet the condition of "greater than or equal to the longitude of the left boundary and less than or equal to the longitude of the right boundary".
5. The method of claim 1, wherein the method further comprises: The process of determining whether a device is inside a polygon using the ray method is as follows: Draw a horizontal scan line from the device point to be detected; traverse each edge of the polygon, sorting the two endpoints of the edge in ascending order of latitude, and determine whether the edge intersects with the scan line; perform a cross product operation on the intersecting edges; if the cross product is zero, the device point is on the edge of the polygon and is directly determined to be inside; if the cross product is greater than zero, increment the crossing counter by one; after traversal, if the crossing counter is odd, the device point is inside the polygon; if it is even, it is outside.
6. The method of claim 5, wherein the method further comprises: The cross product operation is: crossProduct=(item.lng-a.lng)×(b.lat-a.lat)-(b.lng-a.lng)×(item.lat-a.lat), where a and b are the two endpoints of the current edge of the polygon, item is the latitude and longitude of the device point to be detected, lat represents latitude, and lng represents longitude.
7. The method of claim 1, wherein, The device is a lighting fixture deployed in geographic space, and the batch operation instructions include one or more of the following: batch switching, batch brightness adjustment, batch color temperature adjustment, batch scene switching, batch firmware upgrade, and batch parameter configuration.
8. The method according to claim 1, characterized in that, The spatial visualization interface is a WebGIS map interaction interface. Users can determine each vertex of the polygon in sequence by clicking with the mouse or touching, and complete the polygon drawing by double-clicking or clicking the close button.
9. A batch operating system for lighting equipment based on polygon selection, characterized in that, include: The polygon selection interaction module is used to receive the polygon selection area drawn by the user on the spatial visualization interface and record the screen pixel coordinates of each vertex of the polygon. The coordinate transformation module is used to convert the screen pixel coordinates of each vertex into geographic latitude and longitude coordinates, and outputs a set of latitude and longitude coordinates of polygon vertices; The candidate device filtering module is used to calculate the minimum bounding rectangle based on the latitude and longitude set of polygon vertices, and use the minimum bounding rectangle to obtain the set of candidate devices within the rectangular range from the device layer; The polygon precision judgment module is used to use the ray method to judge the polygon inclusion of each device in the candidate device set and filter out the target device dataset located within the polygon area. The batch operation execution module is used to execute batch operation instructions on the target device dataset; The system executes a batch operation method for lighting equipment based on polygon selection as described in any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements a method for batch operation of lighting equipment based on polygon selection as described in any one of claims 1 to 8.
