CANVAS-based forbidden area drawing and path avoidance algorithm
By optimizing restricted area storage through R-tree indexing and quadtree structure, combined with dynamic weights and hierarchical rendering, the accuracy, memory, and performance issues in web path planning are resolved, generating high-quality, smooth paths that support complex polygons and dynamic changes, thus improving the user experience.
Patent Information
- Application Number
- CN202511617675.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-02-24
AI Technical Summary
Existing technologies for Web path planning suffer from problems such as a conflict between accuracy and memory usage, uneven path generation, poor performance, overly simplistic no-entry zone definitions, and inability to handle complex polygons and dynamic changes.
The system uses R-tree index and quadtree structure to store restricted areas, combined with dynamic weight values and hierarchical rendering mechanism. It generates high-quality paths through A* search and smoothing, monitors changes in restricted areas in real time and performs local replanning, establishes a multi-layer drawing structure and interactive editing system, and coordinates scene adaptive optimization and memory management.
It achieves efficient and smooth path planning in complex scenarios, reduces memory usage and computation time, supports multiple restricted area types, and improves path quality and user experience.
Smart Images

Figure CN121564128A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Web visualization technology, specifically to a no-entry zone drawing and path avoidance algorithm based on CANVAS. Background Technology
[0002] Canvas is a powerful drawing API introduced in HTML5 that allows users to draw graphics directly on web pages. It is mainly used in fields such as map navigation, game development, robot path planning, logistics and distribution, virtual simulation and web geographic information systems.
[0003] Currently, in mainstream web path planning applications, the following technical solutions are mainly used for no-entry zone handling and path avoidance based on HTML5 Canvas:
[0004] Gridification method: Divide the Canvas into a grid of fixed size, mark the grid status (passable / no-passable) to represent the no-passable area, and use A* or Dijkstra's algorithm to perform path search on the grid;
[0005] Simple geometric obstacle avoidance: It adopts basic geometric collision detection, determines the validity of the path by calculating the intersection of the line segment and the boundary of the restricted area, and uses simple angle deflection to bypass obstacles;
[0006] Predefined route templates: Design fixed route templates in advance, select the most suitable template for route planning based on the starting point and destination, and avoid known restricted areas through template matching;
[0007] Node-based graph search: The space is preprocessed into a node graph, and traditional graph search algorithms are used to find paths between nodes. When connecting nodes, the occlusion relationship of no-entry zones is considered. To this end, a no-entry zone drawing and path avoidance algorithm based on CANVAS is proposed.
[0008] However, in practice, the existing technical solutions mainly have the following problems:
[0009] There is a trade-off between accuracy and memory usage in the gridding method: fine-grained grids (1-pixel grids) require 2MB of memory at a resolution of 1920×1080, with a computational complexity of O(w×h); coarse-grained grids reduce memory usage but sacrifice path accuracy and cannot handle complex geometries.
[0010] The path generated by the algorithm has obvious defects: the path is obviously jagged, and too many turns affect practical applications; the smoothness of the path is not considered, and the generated path does not conform to the actual movement pattern; it lacks multi-objective optimization, only considering the shortest distance while ignoring other constraints.
[0011] Poor performance in complex scenarios: The algorithm response time exceeds 500ms in large-scale restricted area scenarios; the entire path needs to be recalculated when the restricted area changes dynamically; and it lacks an incremental algorithm and cannot provide real-time feedback.
[0012] The definition of restricted areas is too simplistic: it only supports basic geometric shapes such as rectangles and circles; it cannot handle user-defined complex polygonal restricted areas; and it lacks support mechanisms for dynamic restricted areas and temporary restrictions. Summary of the Invention
[0013] To address the technical problems existing in the prior art, this invention provides a CANVAS-based algorithm for drawing no-entry zones and avoiding paths.
[0014] To solve the above-mentioned technical problems, the present invention provides the following technical solution: a no-entry zone drawing and path avoidance algorithm based on CANVAS, comprising the following steps:
[0015] S1. Establish an R-tree index to store complex polygon restricted areas and partition them, establish a dynamic maintenance mechanism for the restricted area index, construct a restricted area data model, design a dynamic weight value allocation mechanism based on real-time drawing data and establish a layered rendering mechanism to provide an efficient spatial data foundation for path planning and realize fast query and dynamic management of restricted areas.
[0016] S2 generates a dynamically updatable visibility map of restricted areas, calculates the path network of the visibility map and determines the priority of path nodes through a comprehensive evaluation function, establishes a heuristic path search based on the evaluated path nodes, constructs the basic network of path search, and provides an optimized search space for subsequent path planning.
[0017] S3. After initializing the path search parameters, perform A* search to obtain the initial path framework. Then, perform path smoothing, conflict detection and correction on the smoothed path, calculate the optimal path based on the origin and destination, and generate a high-quality path that meets the constraints.
[0018] S4 monitors changes in restricted areas in real time and replans the affected routes, saves historical routes and compares them with new routes, selects the route version after comparison, maintains the continuous validity of routes, and establishes a hierarchical route caching mechanism.
[0019] S5 constructs a multi-layered drawing structure, a path editing system, and an interactive editing structure for restricted areas. It monitors the path search performance, collision detection performance, and rendering performance of the restricted area drawing and path avoidance algorithms in real time, and provides a user interface to realize the visual editing of paths and restricted areas.
[0020] S6 adapts to different scenarios by adjusting algorithm parameters, establishing intelligent memory allocation, storage, and access, thereby achieving adaptive optimization and exception handling of the system.
[0021] Preferably, step S1 specifically includes the following:
[0022] S11, establish an R-tree index to store the restricted areas of complex polygons, and create a quadtree structure to support dynamic insertion and deletion operations. Partition the restricted areas of point-like and geometric objects with an area of less than 100 square pixels or a boundary complexity of less than 4 vertices. Set up a two-level index mapping in the R-tree index and establish a dynamic maintenance mechanism for the restricted area index.
[0023] S12 sets up a unified geometric information, attribute label, priority and timeliness data structure for restricted areas, supports point, line segment, polygon, circle, ellipse and free-drawn area geometric types, establishes a standardized storage format and fast serialization mechanism for geometric data, performs geometric accuracy verification of coordinates, geometric shape integrity, geometric topology, area and perimeter rationality, as well as coordinate, topology, geometric optimization and data consistency repair. If the repair fails, a hierarchical repair strategy is adopted, the repair record is saved and rolled back, and if it cannot be repaired, it is marked as invalid, prompts the user and provides alternative solutions.
[0024] S13. Restricted zones employ a hierarchical priority coverage rule, assigning dynamic weight values based on zone type. This includes: permanently impassable restricted zones; long-term restricted zones adjusted according to restriction severity; adjustable temporary restricted zones; conditionally restricted zones dynamically adjusted based on condition fulfillment; and softly restricted zones that are permissible but not recommended for passage. Through restricted zone coverage rules, conflict resolution mechanisms, timeliness management, weight reallocation mechanisms, and conflict monitoring and alarm mechanisms, rule consistency and system stability are achieved in a multi-restricted zone environment. The dynamic weight value calculation model is as follows:
[0025]
[0026] Where t represents the cumulative time since creation. The attenuation coefficient is... , This represents the actual weight value at time t. This represents the initial weight value, i.e., the base weight set during creation. This represents the minimum weight value, used as a protection threshold to prevent weight decay to zero.
[0027] S14: Build a Canvas drawing optimization engine to achieve high-performance visualization rendering, establish a layered rendering mechanism, and separate the background layer, restricted area layer, path layer and interaction layer.
[0028] The Canvas drawing optimization engine employs a chunked rendering manager: dividing the Canvas into rendering chunks, updating only the changing chunks to reduce processing load, using GPU-accelerated proxies, accelerating complex geometric calculations and pixel processing through the WebGL backend, using a rendering instruction cache to cache repeated drawing instructions to avoid redundant calculations, and employing dynamic level of detail control to dynamically adjust geometric precision based on the scaling level.
[0029] Preferably, step S2 specifically includes the following:
[0030] S21. Based on the vertices and boundaries of the restricted areas, a visibility graph is constructed. The coordinates of all vertices in the restricted areas are extracted, and start and end points are added. A line of sight is detected for each pair of nodes. If the line of sight is not blocked by any restricted area, a connection edge is established. The connection relationship of all non-occluded nodes is calculated by the Lee algorithm. A potential path network and a dynamic update mechanism for the visibility graph are established.
[0031] The dynamic update mechanism of the visibility map is as follows: when the restricted area changes, an incremental update strategy is adopted, and only the visibility connectivity of the affected area is recalculated;
[0032] S22 preprocesses the visibility graph, calculates the shortest distance matrix between nodes, and uses it for path cost calculation and search optimization. The Johnson algorithm is used to handle negative weight edges and complex weight assignments.
[0033] S23, The comprehensive evaluation function F(path), built upon path quality assessment and node priority ranking, determines node priority:
[0034]
[0035] Among them, the distance term: Smoothness term: Security items: Set the adaptive weighting coefficients as follows: α=0.5, β=0.3, γ=0.2. This represents the coordinates of the i-th node on the path. This represents the direction angle of the path at the i-th node;
[0036] S24, estimating the cost from node n to the target point and constructing the heuristic function h(n) is as follows:
[0037]
[0038] Where n represents the path node currently being evaluated, and Indicates the coordinates of the current node. and The target node coordinates are represented by `penalty_factor`, which represents the penalty factor.
[0039] The penalty_factor is dynamically adjusted based on the restricted zone density and path complexity. The adjustment method is as follows:
[0040]
[0041] Wherein, density coefficient = number of restricted areas within a radius of 100 pixels / 10, complexity coefficient = path turning angle / 5.
[0042] Preferably, step S3 specifically includes the following:
[0043] S31, initialize the basic parameters of the A* search based on the start and end coordinates. The specific parameters for the heuristic function initialization are as follows:
[0044] The weighting coefficient w = 1.2, Euclidean distance is used as the distance calculation method, and the initial value of the penalty factor = 1.0;
[0045] Establish a search rectangle boundary by extending 200 pixels to both sides of the line connecting the start and end points. Nodes outside the boundary are not included in the search to limit computational complexity. Establish path constraints for maximum path length, maximum turning angle, and minimum safe distance.
[0046] S32, using the A* search algorithm to perform a multi-stage path search on the visibility graph to obtain an initial path framework, specifically including:
[0047] Coarse path phase: Perform A* search on the global node network to obtain the sequence of main path nodes;
[0048] Refinement stage: Subdivision is achieved by inserting intermediate nodes between adjacent main nodes with a spacing of 10-20 pixels. Local obstacle avoidance is performed using an artificial potential field method, where obstacles generate repulsive forces and target points generate attractive forces. Gradient descent algorithm is applied to optimize the path node positions, with the objective function being a weighted sum of path length and smoothness for fine-tuning.
[0049] Optimization phase: The Douglas-Peucker algorithm is applied to simplify the path, remove redundant nodes, and keep the path shape basically unchanged;
[0050] A checkpoint mechanism for the search state is established, with a checkpoint set every 100 nodes processed to record the current search state and support recovery from the checkpoint after the algorithm is interrupted;
[0051] S33, use cubic spline interpolation to smooth the initial path frame. The specific cubic spline function equation S(t) is:
[0052]
[0053] Where t represents the parameter variable, , , , and The four coefficients of the cubic spline are obtained by solving for the boundary conditions.
[0054] Boundary conditions:
[0055] , , ,
[0056] in, and These represent the position values of the spline function at parameters 0 and 1, respectively. and Let represent the coordinates of the start and end points of the spline segment, respectively. and Let represent the derivative values of the spline function along the tangent direction at parameters 0 and 1, respectively. and These represent the tangent direction vectors at the starting and ending points, respectively.
[0057] S34 performs precise collision detection on the smoothed path, detecting collisions between the smoothed path curve and all restricted areas. It uses the separating axis theorem to detect intersections between the path and polygonal restricted areas, and performs minimization adjustments for detected conflicts. The minimization adjustment method employs a local path replanning strategy, establishing a rollback mechanism and alternative path generation for failed corrections. The rollback mechanism maintains a historical record of path corrections, reverting to the previous valid state when a correction fails. Alternative path generation uses a pool of candidate paths; when the primary path cannot be corrected, a suboptimal path is selected from the pool. If all paths fail, a straight path is used as a degraded path and marked as a low-quality path.
[0058] Preferably, step S4 specifically includes the following:
[0059] S41, establish a restricted area change monitoring mechanism to detect and respond to change events, detect the addition, deletion and modification of restricted areas in real time, determine the path segments that need to be recalculated through geometric intersection judgment, and establish a change event queue through incremental update for batch processing and priority scheduling;
[0060] S42, the path segments affected by the change of the restricted area are replanned through a local search algorithm. The replanning method is as follows: anchor points are set at both ends of the affected path segments, and the path is re-searched only between the anchor points. Collision detection and path correction are performed, but the scope is limited to the local area.
[0061] S43 establishes a lightweight version control system based on Git principles, assigns a UUID to each path, maintains a version tree structure, and supports branching, merging, and tagging operations. It evaluates the quality of paths through a comprehensive evaluation function F(path), records historical paths and change trajectories, compares path quality, and selectively rolls back. When a correction fails, it rolls back to the state recovery at the algorithm level, and the path rolls back to the version selection at the user level.
[0062] S44 establishes a multi-level path caching mechanism consisting of global path caching, regional path caching, and local path caching. The global cache stores complete paths using an LRU eviction policy with a capacity of 1000 paths. The regional cache stores local path segments, partitioned by space, with a capacity of 500 paths per region. The local cache stores intermediate calculation results with a lifespan of a single search process.
[0063] Establish a cache hit rate statistics and performance monitoring mechanism using computation time, memory usage, and cache hit rate as monitoring metrics.
[0064] Preferably, step S5 specifically includes the following:
[0065] S51 creates a multi-layered CANVAS structure consisting of a static background layer, a dynamic restricted area layer, a path display layer, and an interactive overlay layer. It shares data and transmits events through an inter-layer communication mechanism. The inter-layer communication protocol is based on a custom event system and uses a publish-subscribe pattern. Event types include: data updates, window changes, user interactions, and rendering requests. The data sharing method involves establishing a shared data warehouse. Each layer accesses data through a unique identifier and uses read-write locks to ensure data consistency. In the event transmission mechanism, events propagate downwards from the interactive layer. Each layer can choose to process or pass through the event, and it supports both event bubbling and capturing modes.
[0066] S52 establishes a path style system and visual indicators of path quality, enabling interactive path editing, drag-and-drop adjustments, and node editing;
[0067] S53 constructs an interactive editing interface for restricted areas, combining the precise drawing of CAD software with the intuitive operation of map applications, including restricted area drawing tools, interactive editing of restricted areas, restricted area attribute editing panel, and batch operations for restricted areas;
[0068] S54 employs Web Worker for background monitoring, uses a high-precision timer `performance.now()` to measure microsecond-level performance, performs performance trend analysis and anomaly detection based on statistical methods, monitors the path search performance, collision detection performance, and rendering performance of the no-entry zone drawing and path avoidance algorithms in real time, conducts performance benchmark tests, and performs comparative analysis.
[0069] Preferably, the path style system in step S52 includes gradient color mapping path quality, dynamic line width representing passage difficulty, dashed line style distinguishing path type, and arrow density reflecting speed limit; the visualization indicators are path credibility reflected by color transparency, congestion prediction reflected by color temperature, and safety level reflected by border style.
[0070] The path styling system adopts a cascading mechanism similar to CSS style sheets, automatically adjusting the visual style based on the real-time attributes of the path, realizing two-way binding between style and data, providing preset style templates, allowing users to quickly switch between different visual styles, and using a custom style editor: supporting users to adjust line width, dashed line style and endpoint style through a visual interface, and allowing child path segments to inherit the style attributes of the parent path, allowing partial overriding;
[0071] The path quality visualization index adopts a multi-dimensional quantitative evaluation system and performs real-time quality monitoring. It provides a quality change trend chart, supports quality threshold alarms and quality comparison of multiple paths, displays various indicators side by side, provides optimal path recommendations, automatically identifies the best solution based on comprehensive scores, and records and analyzes historical changes in path quality.
[0072] Preferably, step S6 specifically includes the following:
[0073] S61 automatically adjusts algorithm parameters according to scene complexity and performance requirements, establishes parameter optimization models and parameter validity verification and boundary checking mechanisms, configures parameter templates for multiple scenes, and the boundary checking mechanism includes automatic correction of parameter out-of-bounds, alarm for abnormal parameters, and default parameter rollback function;
[0074] S62, establish an algorithm degradation mechanism and issue user error messages and suggested solutions;
[0075] S63 intelligently allocates memory, establishes an object pool mechanism, reuses frequently created objects, and performs incremental garbage collection.
[0076] Preferably, the specific operation of step S63, intelligent memory allocation, is as follows:
[0077] S631, establishing a symmetric pooling mechanism:
[0078] Pre-allocate commonly used object types: including path nodes, restricted area data structures, and visibility graph nodes;
[0079] Set an object reuse strategy: recycle objects to the object pool after use instead of destroying them directly;
[0080] Object pool management: Maintains a list of available objects of different types, and allocates and recycles them as needed;
[0081] S632, reusing frequently created objects:
[0082] Reference counting management: tracks the number of references to each object to determine when it is safe to reclaim it;
[0083] Lifecycle management: Monitoring the complete lifecycle of an object from creation to destruction;
[0084] Reduce memory allocation overhead: Avoid frequent memory allocation and deallocation operations by reusing objects;
[0085] S633, implementing progressive waste recycling:
[0086] Time-sharing garbage collection strategy: Distribute the garbage collection operations of a large number of objects across multiple time slices;
[0087] Avoid performance stalls: Prevent UI freezes or computation interruptions caused by garbage collection of a large number of objects at once;
[0088] Intelligent scheduling and recycling: Prioritize waste recycling operations during system idle periods.
[0089] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0090] 1. This invention innovatively combines the advantages of R-trees and quadtrees through multi-level spatial indexing and intelligent algorithm optimization to establish a two-level spatial index structure, achieving an optimal balance between spatial query efficiency and memory usage. It achieves comprehensive optimization of distance, smoothness, and security in the Canvas environment, establishes a complete multi-objective evaluation system and adaptive weight adjustment mechanism, develops an incremental update algorithm based on influence range analysis, realizes local recalculation when the restricted area changes, avoids the performance bottleneck of global replanning, designs a layered Canvas architecture and selective redraw strategy, and combines GPU acceleration and cache optimization to achieve real-time rendering in complex scenes.
[0091] 2. This invention achieves a significant performance improvement, reducing computational complexity from traditional methods. Reduce to Compared to the grid method, it saves 70-85% of memory usage, reduces the average path calculation time from 500ms to less than 50ms, supports the simultaneous processing of more than one hundred path planning requests, meets the path planning needs of various complex scenarios, and is convenient for handling complex geometries.
[0092] 3. The path quality has been effectively improved, with the number of corners reduced by 60% and the average change in path curvature reduced by 45%. Compared with the shortest path algorithm, the overall efficiency has been improved by 35%, the minimum safe distance from restricted areas has been improved by 40%, and it supports more than 20 different types of restricted areas and constraints, and can handle complex polygonal restricted areas.
[0093] 4. This invention effectively improves user experience, with interface response time stabilized within 16ms, maintaining a smooth 60FPS, supporting real-time path animation and multi-level visualization, reducing the steps and time of restricted area editing operations by 70%, and achieving a 99.5% success rate in handling abnormal situations. Attached Figure Description
[0094] Figure 1 This is a schematic diagram of the no-entry zone drawing and path avoidance algorithm of the present invention;
[0095] Figure 2 This is a schematic diagram illustrating the process of establishing the spatial index and data foundation of the present invention;
[0096] Figure 3 This is a schematic diagram of the visualization construction and path network optimization process of the present invention;
[0097] Figure 4 This is a schematic diagram of the path search and optimization process of the present invention;
[0098] Figure 5 This is a schematic diagram of the dynamic path management process of the present invention;
[0099] Figure 6 This is a schematic diagram of the user interface flow of the present invention;
[0100] Figure 7 This is a schematic diagram of the system optimization and anomaly handling process of the present invention. Detailed Implementation
[0101] The present invention will be further described below with reference to the accompanying drawings and embodiments, which illustrate the above and other technical features and advantages of the present invention. However, the following embodiments are merely preferred embodiments of the present invention and are not exhaustive.
[0102] Example:
[0103] like Figure 1-7 As shown, this invention provides a no-entry zone drawing and path avoidance algorithm based on CANVAS, including the following steps:
[0104] S1. Establish an R-tree index to store complex polygon restricted areas and partition them, establish a dynamic maintenance mechanism for the restricted area index, construct a restricted area data model, design a dynamic weight value allocation mechanism based on real-time drawing data and establish a layered rendering mechanism to provide an efficient spatial data foundation for path planning and realize fast query and dynamic management of restricted areas.
[0105] S2 generates a dynamically updatable visibility map of restricted areas, calculates the path network of the visibility map and determines the priority of path nodes through a comprehensive evaluation function, establishes a heuristic path search based on the evaluated path nodes, constructs the basic network of path search, and provides an optimized search space for subsequent path planning.
[0106] S3. After initializing the path search parameters, perform A* search to obtain the initial path framework. Then, perform path smoothing, conflict detection and correction on the smoothed path, calculate the optimal path based on the origin and destination, and generate a high-quality path that meets the constraints.
[0107] S4 monitors changes in restricted areas in real time and replans the affected routes, saves historical routes and compares them with new routes, selects the route version after comparison, maintains the continuous validity of routes, and establishes a hierarchical route caching mechanism.
[0108] S5 constructs a multi-layered drawing structure, a path editing system, and an interactive editing structure for restricted areas. It monitors the path search performance, collision detection performance, and rendering performance of the restricted area drawing and path avoidance algorithms in real time, and provides a user interface to realize the visual editing of paths and restricted areas.
[0109] S6 adapts to different scenarios by adjusting algorithm parameters, establishing intelligent memory allocation, storage, and access, thereby achieving adaptive optimization and exception handling of the system.
[0110] Multi-platform compatibility: Supports Windows, macOS, and Linux platforms; native support for iOS Safari and Android Chrome; support for Node.js environments; can be used for server-side path calculation; can be extended to WebGL environments; supports 3D path planning; supports integration of machine learning algorithms to achieve intelligent path optimization; supports real-time collaboration and synchronous updates among multiple users; supports large-scale geographic data and complex constraint processing.
[0111] In urban delivery scenarios, various restrictions such as traffic control, temporary road closures, and vehicle restrictions need to be considered. The system should be able to: process dynamic traffic restriction information in real time, adjust route planning based on vehicle type and time period, provide multiple alternative routes and real-time route adjustments, and support route optimization and scheduling for batch orders;
[0112] Game AI Navigation System: In real-time strategy games, units need to move intelligently through complex terrain. System Implementation: Supports various terrain obstacles and dynamic obstacles, enabling coordinated avoidance and path planning for groups of units, providing smooth and natural movement trajectories and turning behaviors, and supporting real-time map editing and obstacle changes.
[0113] In this embodiment, step S1 specifically includes the following:
[0114] S11, establish an R-tree index to store the restricted areas of complex polygons and create a quadtree structure: the R-tree uses minimum bounding rectangle (MBR) to organize nodes, each node has a capacity of 16-64 child nodes, supports dynamic insertion and deletion operations, partitions restricted areas of point-like and geometric shapes with an area of less than 100 square pixels or a boundary complexity of less than 4 vertices, the maximum depth of the quadtree is limited to 10 levels, and each leaf node can store a maximum of 8 objects;
[0115] By setting up a two-level index mapping in the R-tree index, the advantages of spatial hashing and hierarchical indexing are combined to achieve coarse-grained positioning and fine-grained retrieval:
[0116] The first layer is a coarse-grained region division with a 512×512 pixel grid;
[0117] The second layer is for fine-grained, precise positioning, which establishes a mapping relationship through a spatial hash function: hash=(x>>9)|((y>>9) <<16);
[0118] Establish a dynamic maintenance mechanism for forbidden zone indexes, adopt a delayed update strategy, process index changes in batches to reduce reconstruction overhead, update forbidden zone additions, deletions and modifications in real time, and maintain transaction logs for insert / delete / update operations.
[0119] S12 sets up a unified geometric information, attribute label, priority and timeliness data structure for restricted areas, supports point, line segment, polygon, circle, ellipse and free-drawn area geometric types, establishes a standardized storage format and fast serialization mechanism for geometric data, performs geometric accuracy verification and automatic repair, adopts a hierarchical repair strategy after repair failure, saves repair records and rolls back, and marks invalid when repair is not possible, prompts the user and provides alternative solutions;
[0120] Geometric information includes: punctuation set, bounding box information, geometric type identifiers (including: point, line segment, polygon, circle, ellipse, Bézier curve), and pre-calculated values for area and perimeter;
[0121] Attribute tags are divided into the following five categories: type tags, priority tags, status tags, permission tags, and description tags;
[0122] The duration of the restrictions includes: permanent restricted areas, long-term restricted areas (more than 24 hours), short-term restricted areas (1-24 hours), temporary restrictions (less than 1 hour), and real-time restrictions (less than 15 minutes).
[0123] The priority ranking is based on the following security level: Emergency > Important > General.
[0124] Time urgency: Urgent > Important > General;
[0125] Scope of impact: Global > Regional > Local;
[0126] User permission levels: Administrator > Senior User > Regular User;
[0127] The storage format uses a compact binary format, geometric data uses variable-length encoding, attribute data uses bit-field compression, and incremental serialization and parallel deserialization are supported.
[0128] The serialization mechanism is implemented in a lightweight manner based on Protocol Buffers, supporting version compatibility and backward compatibility, with serialization speed >10MB / s and deserialization speed >15MB / s.
[0129] The specific method for verifying geometric accuracy is as follows:
[0130] (1) Coordinate validity verification: Verify whether the coordinate point is within the Canvas area. Points outside the range are marked as invalid. Check whether the coordinate value is a valid number (not NaN, not Infinity). Limit the coordinate precision to a reasonable range (maximum 6 decimal places) to avoid the accumulation of floating point errors.
[0131] (2) Geometric integrity verification: Verify whether the first and last vertices of the polygon coincide to ensure that the figure is closed. The polygon needs at least 3 vertices and the line segment needs at least 2 vertices. Identify and process consecutive repeated vertices to avoid degenerate figures.
[0132] (3) Geometric topology verification: The scan line algorithm is used to detect whether there is self-intersection of polygons, unify the arrangement order of polygon vertices, ensure the correctness of area calculation, distinguish between convex and concave polygons, and select appropriate algorithms for subsequent processing.
[0133] (4) Area and perimeter rationality check: The area of the restricted area cannot be less than 1 square pixel. Areas that are too small will be automatically deleted or merged. The area of a single restricted area shall not exceed 50% of the total area of the canvas to prevent abnormal data and detect abnormally long or complex graphics.
[0134] The specific process of the automatic repair function is as follows:
[0135] (1) Coordinate repair: Project points that exceed the canvas area onto the canvas boundary, maintain the relative shape of the graphic, replace NaN or Infinity coordinates with the average value of adjacent valid points, round off the over-precision coordinates, and unify the precision standard.
[0136] (2) Topology repair: Automatically connect the first and last vertices of the polygon, force the shape to close, first detect the position of the intersection point, then decompose the complex polygon with self-intersection into multiple simple polygons or eliminate slight self-intersection by fine-tuning the vertices, delete the degenerate polygon with zero area, and merge vertices that are too close.
[0137] (3) Geometric optimization and repair: The Douglas-Puk algorithm is used to simplify redundant vertices, reduce complexity while maintaining graphic features, smooth jagged boundaries, improve visual effect, and regularize irregular graphics that are approximately rectangular or circular into standard geometric shapes.
[0138] (4) Data consistency repair: Ensure the consistency between geometric data and attribute labels, repair mismatched relationships, correct abnormal weight values (negative numbers, excessively large values) to a reasonable range, correct invalid timestamps, and ensure the logical correctness of time-sensitive data.
[0139] The handling mechanism after a repair failure is as follows:
[0140] (1) Hierarchical repair strategy: The Douglas-Puk algorithm is used to simplify redundant vertices, maintain graphic features while reducing complexity, smooth jagged boundaries, improve visual effect, and regularize irregular graphics that are approximately rectangular or circular into standard geometric shapes.
[0141] (2) Repair record and rollback: Record the type, reason and modification content of each repair in detail, save the original geometric data before repair, support manual rollback, evaluate the reliability of the data after repair, and provide quality score;
[0142] (3) Handling when repair is not possible: Mark the unrepairable geometric data as invalid, do not participate in path calculation, report the specific reasons for the repair failure and the suggested manual handling solution to the user, provide a simplified geometry as a temporary alternative, and ensure that the system continues to run.
[0143] Batch processing optimization: Perform batch verification and repair on multiple restricted areas to improve processing efficiency. Incremental verification: Only verify the geometric data that has changed, avoiding full inspection.
[0144] Parallel processing: Web Workers are used to execute verification and repair tasks in parallel in the background without blocking the main thread.
[0145] This verification and repair mechanism ensures the reliability of the restricted area geometry data and the stable operation of the system.
[0146] S13. Assign dynamic weight values according to the type of restricted area, including: permanently restricted areas that are impassable, long-term restricted areas that are adjusted according to the severity of the restrictions, adjustable temporary restricted areas, conditional restricted areas that are dynamically adjusted according to the conditions met, and soft restricted areas that are passable but not recommended. The conditions for temporary restricted areas are based on: traffic flow density, time period importance, availability of alternative routes, and user preference settings.
[0147] The calculation model for dynamic weight values is as follows:
[0148]
[0149] Where t represents the cumulative time since creation. The attenuation coefficient is... , This represents the actual weight value at time t. This represents the initial weight value, i.e., the base weight set during creation. This represents the minimum weight value, used as a protection threshold to prevent weight decay to zero.
[0150] The restricted zones adopt a hierarchical priority coverage rule. The specific content of the restricted zone coverage rule is as follows:
[0151] (1) Priority-based coverage rule (highest priority): High-weight restricted areas cover low-weight restricted areas. The larger the weight value, the higher the priority. Permanent restricted area (weight ∞) > Priority restricted area (1000-9999) > Conditional restricted area (100-999) > Suggested avoidance area (1-99). When restricted areas overlap in space, the overlapping area adopts the highest weight value, and the non-overlapping part retains the original weight.
[0152] (2) Time-sensitive coverage rules (secondary priority): Temporary restricted areas cover areas with lower permanent priority during their effective period. They support coverage rules that take effect and expire on a timed basis, record the history of changes in coverage relationships, and support time-backtracking queries.
[0153] (3) Type compatibility rules (lowest priority): Security-type restricted areas can cover public service-type suggested areas; system-level restricted areas take precedence over user-level restricted areas; emergency-type restricted areas can temporarily cover all other types of areas.
[0154] Specific implementation of the conflict resolution mechanism:
[0155] (1) Weight conflict resolution: directly compare weight values, with the higher value taking priority. The weight value of the covered area is automatically adjusted to the weight value of the covered area. For overlapping areas with the same weight, the final weight is calculated by area-weighted average.
[0156] (2) Handling of overlapping time periods in time conflict resolution: adopt stricter prohibition rules, apply the highest priority rules to overlapping time periods, and apply the rules to non-overlapping time periods respectively. The rules of the inner time period can cover the rules of the outer time period.
[0157] (3) Geometric conflict resolution: Decompose the overlapping complex geometry into non-overlapping simple regions. When the boundaries of the restricted areas coincide, a stricter boundary definition is adopted, and the internal restricted area has a higher priority than the external restricted area.
[0158] (4) Attribute conflict resolution: The attributes of the conflicting area adopt the union principle, retain all relevant tags, set attribute priority, retain key attributes first, and mark the areas with attribute conflicts in a special way to facilitate subsequent processing;
[0159] Timeliness management and weight redistribution mechanism:
[0160] (1) Automatic expiration mechanism: The system monitors the expiration time of all temporary restricted areas through a timer. After the expiration, the status is automatically set to "expired". Warning notifications are sent 15 minutes, 5 minutes and 1 minute before the expiration. All temporary restricted areas are scanned once every minute to process the expired areas in batches and avoid frequent updates.
[0161] (2) Weight reallocation strategy: After the temporary restricted area fails, the covered area is restored to its original weight value. A gradual weight recovery is adopted to avoid sudden weight jumps. After the weights are reallocated, all paths in the affected area are automatically recalculated. The formula for calculating the restored weight is:
[0162] Restored weights = Original weights × (1 - e^(-Kt)) + Current weights × e^(-Kt)
[0163] Where t is the time after failure, and K is the recovery rate coefficient;
[0164] (3) Processing flow after failure: Update the status of the failed restricted area from "effective" to "failed", remove the failed restricted area node from the R tree and quadtree index, clean up the path cache data related to the failed restricted area, and remove or gray out the display of the failed restricted area on the interface;
[0165] (4) Reactivation mechanism: Supports setting up a restricted area that takes effect on a recurring basis (such as daily or weekly timed restrictions). The restricted area is automatically reactivated based on external conditions (such as traffic conditions and weather). Users can manually extend or reactivate expired temporary restricted areas.
[0166] Conflict monitoring and alarm mechanisms:
[0167] (1) Real-time conflict detection: Use R-tree index to quickly identify spatially overlapping no-entry zones, assess the severity of conflicts based on overlapping area and weight difference factors, maintain a conflict event queue, and handle conflict resolution according to priority;
[0168] (2) Establish a conflict resolution log: record in detail the decision-making process and basis for each conflict resolution, analyze the impact of conflict resolution on existing path planning, and monitor the execution efficiency and system performance impact of the conflict resolution mechanism;
[0169] This comprehensive set of coverage rules and conflict resolution mechanisms ensures rule consistency and system stability in a multi-restricted zone environment.
[0170] S14: Build a Canvas drawing optimization engine to achieve high-performance visualization rendering, establish a layered rendering mechanism, and separate the background layer, restricted area layer, path layer and interaction layer.
[0171] The Canvas rendering optimization engine employs a tiled rendering manager: dividing the Canvas into rendering blocks, which can be 256×256 pixels, 128×128 pixels, or 512×512 pixels. Only changing blocks are updated, reducing the amount of processing. It uses a GPU-accelerated proxy to accelerate complex geometric calculations and pixel processing through the WebGL backend. It uses a rendering instruction cache to cache repeated drawing instructions, avoiding redundant calculations, and employs dynamic level of detail control to dynamically adjust geometric precision according to the scaling level.
[0172] In this embodiment, step S2 specifically includes the following:
[0173] S21. Construct a visibility graph based on the vertices and boundaries of the restricted areas. During construction: extract the vertex coordinates of all restricted areas, add start and end points, perform line of sight detection on each pair of nodes, and establish connecting edges if the line of sight is not obstructed by any restricted area.
[0174] The Lee algorithm is used to calculate the connection relationships of all non-occluded nodes. The Lee algorithm adopts an optimized line segment intersection algorithm, that is, it uses the scan line algorithm to reduce the number of intersection detections, uses spatial index to pre-screen geometric objects that may intersect, and applies numerical stability optimization to avoid floating point errors.
[0175] A graph structure consisting of all feasible point-to-point connections is used to establish a potential path network, thereby establishing the line-of-sight connection relationship between nodes. All possible path segments are pre-calculated, avoiding repeated calculation of line-of-sight visibility at runtime, which significantly improves path search efficiency.
[0176] The dynamic update mechanism of the visibility graph is as follows: when the restricted area changes, an incremental update strategy is adopted, and only the visibility connections of the affected area are recalculated, reducing the complexity from O(n²) to O(k·n), where k is the number of nodes involved in the changed area;
[0177] S22 preprocesses the visibility graph, calculates the shortest distance matrix between nodes for path cost calculation and search optimization, and uses the Johnson algorithm to handle negative weight edges and complex weight assignments. The Johnson algorithm is a full-source shortest path algorithm for graphs with negative weight edges, supports dynamic adaptive weight adjustment, integrates the Canvas coordinate system and R-tree spatial index, implements an incremental local update mechanism, and supports multi-dimensional constraints of distance, smoothness, and safety. The complexity is reduced from O(V²log V) to O(k×log k), and it is used to handle dynamic weight changes and complex constraints in the Canvas environment.
[0178] A hierarchical path network is established, consisting of global coarse paths and local fine paths. The two layers are connected by hierarchical connection points to achieve multi-resolution path planning.
[0179] Global coarse path: built on a simplified set of nodes with a node spacing > 50 pixels, used for long-distance path planning;
[0180] Global coarse path: built on the complete set of nodes, containing all geometric details, for precise path optimization;
[0181] S23, The comprehensive evaluation function F(path), built upon path quality assessment and node priority ranking, determines node priority:
[0182]
[0183] Among them, the distance term: Smoothness term: Security items: Set the adaptive weighting coefficients as follows: α=0.5, β=0.3, γ=0.2. This represents the coordinates of the i-th node on the path. This represents the direction angle of the path at the i-th node;
[0184] S24, estimating the cost from node n to the target point and constructing the heuristic function h(n) is as follows:
[0185]
[0186] Where n represents the path node currently being evaluated, and Indicates the coordinates of the current node. and The target node coordinates are represented by `penalty_factor`, which represents the penalty factor.
[0187] The penalty_factor is dynamically adjusted based on the restricted zone density and path complexity. The adjustment method is as follows:
[0188]
[0189] Wherein, density coefficient = number of no-entry zones within a radius of 100 pixels / 10, complexity coefficient = path turning angle / 5;
[0190] Furthermore, a search pruning mechanism is established, combining spatial distance pruning, heuristic pruning, and dynamic threshold pruning to remove invalid branches in the R-tree index, improving efficiency by 30% compared to traditional A* pruning.
[0191] In this embodiment, step S3 specifically includes the following:
[0192] S31, initialize the basic parameters of the A* search based on the start and end coordinates. The specific parameters for the heuristic function initialization are as follows:
[0193] The weighting coefficient w = 1.2, Euclidean distance is used as the distance calculation method, and the initial value of the penalty factor = 1.0;
[0194] The search rectangle is established by extending 200 pixels to both sides of the line connecting the start and end points. Nodes outside the boundary are not included in the search to limit the computational complexity.
[0195] Establish path constraints for maximum path length, maximum turning angle, and minimum safe distance; initialize the priority queue and access flag array.
[0196] The initialization of the access marker array is as follows: create a boolean array of the same length as the number of nodes, initialize all of them to false, and use it to mark visited nodes to avoid duplicate processing;
[0197] S32, using the A* search algorithm to perform a multi-stage path search on the visibility graph to obtain an initial path framework, specifically including:
[0198] Coarse path phase: Perform A* search on the global node network to obtain the sequence of main path nodes;
[0199] Refinement stage: Subdivision is achieved by inserting intermediate nodes between adjacent main nodes with a spacing of 10-20 pixels. Local obstacle avoidance is performed using an artificial potential field method, where obstacles generate repulsive forces and target points generate attractive forces. Gradient descent algorithm is applied to optimize the path node positions, with the objective function being a weighted sum of path length and smoothness for fine-tuning.
[0200] Optimization phase: The Douglas-Peucker algorithm is applied to simplify the path, remove redundant nodes, and keep the path shape basically unchanged;
[0201] A checkpoint mechanism for the search state is established, with a checkpoint set every 100 nodes processed to record the current search state and support recovery from the checkpoint after the algorithm is interrupted;
[0202] S33, use cubic spline interpolation to smooth the initial path frame. The specific cubic spline function equation S(t) is:
[0203]
[0204] Where t is a parameter variable, , , , and The four coefficients of the cubic spline are obtained by solving for the boundary conditions.
[0205] Boundary conditions:
[0206] , , ,
[0207] in, and These represent the position values of the spline function at parameters 0 and 1, respectively. and Let represent the coordinates of the start and end points of the spline segment, respectively. and Let represent the derivative values of the spline function along the tangent direction at parameters 0 and 1, respectively. and These represent the tangent direction vectors at the starting and ending points, respectively.
[0208] Achieve C² continuity guarantee, where C² represents second-order continuity, to ensure smooth transition of the path;
[0209] S34 performs precise collision detection on the smoothed path, checking for collisions between the smoothed path curve and all restricted areas. The separating axis theorem is used to detect intersections between the path and polygonal restricted areas, and collisions are minimized for each detected conflict. The minimization adjustment method employs a local path replanning strategy, specifically:
[0210] (1) Find alternative nodes within a 20-pixel range before and after the conflict point;
[0211] (2) Use Bezier curves to bypass obstacles;
[0212] (3) Maintain a maximum deviation from the original path of <30 pixels;
[0213] (4) Re-smooth the process to ensure continuity;
[0214] Establish a rollback mechanism and alternative path generation when correction fails. The rollback mechanism maintains the history of path correction. When correction fails, it rolls back to the previous valid state. Alternative path generation uses a pool of candidate paths to store multiple candidate paths. When the main path cannot be corrected, the second-best path is selected from the pool. If all paths fail, the straight path is used as a downgrade and marked as a low-quality path.
[0215] In this embodiment, step S4 specifically includes the following:
[0216] S41, Establish a restricted zone change monitoring mechanism to detect and respond to change events, and detect the addition, deletion and modification of restricted zones in real time;
[0217] By using geometric intersection judgment, an influence circle with a radius of 100 pixels is expanded with the change area as the center. All path segments passing through this circle need to be recalculated to determine the path segments that need to be recalculated.
[0218] A change event queue is established through incremental updates for batch processing and priority scheduling. The specific change event queue model is as follows: a priority queue is used, and the event types are sorted by urgency (delete > modify > add). Each event includes change type, affected area, timestamp, and priority.
[0219] The incremental update scheme is as follows: based on time window batch processing, all change events within 100ms are collected, changes in adjacent areas are merged, and incremental updates are performed uniformly.
[0220] S42, the path segments affected by the change of the restricted area are replanned through a local search algorithm. The replanning method is as follows: anchor points are set at both ends of the affected path segments, and the path is re-searched only between the anchor points. Collision detection and path correction are performed, but the scope is limited to the local area.
[0221] The local search algorithm is as follows: a restricted A* algorithm is adopted, the search range is limited to 1.5 times the influence area, a local visibility graph is used, and the time complexity is O(k log k), where k is the number of local nodes;
[0222] S43 establishes a lightweight version control system based on Git principles, assigns a UUID to each path, maintains a version tree structure, and supports branching, merging, and tagging operations. It evaluates the quality of paths through a comprehensive evaluation function F(path), records historical paths and change trajectories, compares path quality, and selectively rolls back. When a correction fails, it rolls back to the state recovery at the algorithm level, and the path rolls back to the version selection at the user level.
[0223] S44 establishes a multi-level path caching mechanism consisting of global path caching, regional path caching, and local path caching. The global cache stores complete paths using an LRU eviction policy with a capacity of 1000 paths. The regional cache stores local path segments, partitioned by space, with a capacity of 500 paths per region. The local cache stores intermediate calculation results with a lifespan of a single search process.
[0224] Establish a cache hit rate statistics and performance monitoring mechanism using computation time, memory usage, and cache hit rate as monitoring metrics.
[0225] In this embodiment, step S5 specifically includes the following:
[0226] S51 creates a multi-layered CANVAS structure consisting of a static background layer, a dynamic no-entry zone layer, a path display layer, and an interactive overlay layer. The creation method is to dynamically generate multiple HTML Canvas elements, use CSS absolute positioning to overlap them, and assign an independent rendering context to each layer.
[0227] Data and events are shared and transmitted by establishing an inter-layer communication mechanism. The inter-layer communication protocol is based on a custom event system and uses a publish-subscribe pattern. Event types include: data updates, window changes, user interactions, and rendering requests. The data sharing method is to establish a shared data warehouse. Each layer accesses data through a unique identifier and uses read-write locks to ensure data consistency. In the event transmission mechanism, events propagate downwards from the interaction layer. Each layer can choose to process or pass through the event, and it supports both event bubbling and capturing modes.
[0228] S52, establish a path style system and visual indicators of path quality, enable interactive path editing, drag-and-drop adjustment and node editing. The path style system includes gradient color mapping of path quality, dynamic line width to indicate passage difficulty, dashed line style to distinguish path type and arrow density to reflect speed limit.
[0229] The path style system specifically includes:
[0230] Layered style management architecture: It adopts a cascading mechanism similar to CSS stylesheets, including three levels: basic styles, state styles, and priority styles. Higher priority styles can override lower priority styles.
[0231] Dynamic style binding mechanism: Automatically adjust the visual style based on the real-time attributes of the path (length, curvature, security) to achieve two-way binding between style and data;
[0232] Style Template System: Provides preset style templates (navigation mode, editing mode, presentation mode), allowing users to quickly switch between different visual styles;
[0233] Custom style editor: Allows users to adjust line width (1-10 pixels), color (RGB / HSV color space), dashed line style (solid line, dashed line, dotted line, dotted-dash line), endpoint style (circle, square, arrow) attributes through a visual interface;
[0234] Style inheritance mechanism: Child path segments can inherit the style properties of the parent path, and partial overriding is also allowed;
[0235] The visualization metrics include path reliability reflected by color transparency, congestion prediction reflected by color temperature, and safety level reflected by border style.
[0236] The specific visualization metrics for path quality include:
[0237] (1) Multi-dimensional quantitative evaluation system: The current path is displayed relative to the shortest path through numerical display and progress bar; the curvature heat map is used to display the sharp turning area in red and the smooth area in green; color coding is used to color the path according to the closest distance between the path and the restricted area (red < 10px, yellow 10-20px, green > 20px), and the distance, smoothness and safety are drawn into a radar chart to intuitively display the comprehensive quality of the path;
[0238] (2) Real-time quality monitoring: Dynamically calculate and display the path quality score (0-100 points), provide a quality change trend chart, show the quality improvement during the path optimization process, and give a visual prompt when the path quality is lower than the set standard;
[0239] (3) Comparison and analysis function: Supports quality comparison of multiple paths, displays various indicators side by side, automatically identifies the best solution based on comprehensive score, and records and analyzes the historical changes in path quality.
[0240] S53 constructs an interactive editing interface for restricted areas, combining the precise drawing capabilities of CAD software with the intuitive operation of map applications. This includes restricted area drawing tools, interactive restricted area editing, a restricted area attribute editing panel, and batch operations for restricted areas.
[0241] The tools for drawing restricted areas include: rectangle, circle, polygon, and freehand drawing;
[0242] The interactive editing features for restricted areas include: magnetic grid attachment, intelligent shape recognition, multi-touch support, and gesture-based shortcuts.
[0243] The restricted area attribute editing panel includes: weight, timeliness, color, and label settings;
[0244] Batch operations in restricted areas include: selection, copying, deletion, and batch modification of attributes;
[0245] S54 employs Web Worker for background monitoring, uses a high-precision timer `performance.now()` to measure microsecond-level performance, performs performance trend analysis and anomaly detection based on statistical methods, monitors the path search performance, collision detection performance, and rendering performance of the no-entry zone drawing and path avoidance algorithms in real time, conducts performance benchmark tests and comparative analysis, realizes visualization of the search process, displays node status and tracks algorithm steps, and supports real-time adjustment of algorithm parameters and effect preview.
[0246] In this embodiment, step S6 specifically includes the following:
[0247] S61 automatically adjusts algorithm parameters based on scene complexity and performance requirements, establishes a parameter optimization model and a parameter validity verification and boundary check mechanism, and provides parameter configuration templates for multiple scenes, specifically:
[0248] The parameter optimization model is as follows: a multi-objective optimization model based on genetic algorithm is established, with the objective function including three dimensions: computation time, path quality, and memory usage. The optimal parameter combination is obtained by training with historical performance data.
[0249] The parameter validity verification uses an interval checking mechanism to ensure the weight coefficients are valid. Time parameters attenuation coefficient ;
[0250] The boundary check mechanism includes automatic correction of parameters exceeding the limit, alarm for abnormal parameters, and rollback of default parameters;
[0251] Multi-scenario parameter configuration templates include: City navigation templates (emphasizing path smoothness, Game AI templates (emphasizing computational speed) ) and logistics delivery templates (emphasizing safety, );
[0252] S62, establish an algorithm degradation mechanism and issue user error messages and suggested solutions. The algorithm degradation mechanism adopts a tiered degradation strategy:
[0253] (1) When the computation time of a complex algorithm exceeds a preset threshold (500ms), it will automatically switch to a simplified algorithm;
[0254] (2) Enable low memory mode when memory usage exceeds 80%;
[0255] (3) When the number of restricted areas exceeds 1,000, regional segmentation shall be adopted;
[0256] The established user error messages include: when path planning fails, the message "No feasible path, please adjust the start and end points or remove the blocking restricted area"; when restricted area settings conflict, the message "Restricted areas overlap, please check the priority settings"; and when the algorithm times out, the message "Computational complexity is too high, switched to fast mode".
[0257] The solution includes: automatically providing alternative route options, intelligently recommending restricted area adjustment schemes, and providing performance optimization suggestions;
[0258] Step S63: Intelligent memory allocation, establishing an object pool mechanism, reusing frequently created objects, and performing gradual garbage collection. The specific operations of intelligent memory allocation are as follows:
[0259] S631 establishes a symmetric pooling mechanism, pre-allocates commonly used object types, including path nodes, restricted area data structures, and visibility graph nodes, sets an object reuse strategy, and recycles objects to the object pool after use instead of destroying them directly. It also maintains a list of available objects for different types of object pools and allocates and recycles them as needed.
[0260] S632 reuses frequently created objects, manages reference counting to track the number of references to each object and determine when it can be safely reclaimed, and manages lifecycle to monitor the complete lifecycle of an object from creation to destruction, avoiding frequent memory allocation and deallocation operations through object reuse;
[0261] S633 performs incremental garbage collection: it distributes the garbage collection operations of a large number of objects across multiple time slices to prevent interface lag or computation interruption caused by collecting a large number of objects at once, and prioritizes garbage collection operations during system idle periods.
[0262] Working principle: When the system starts, step S1 is executed to establish a complete spatial index and data structure, providing basic support for subsequent calculations. After the user specifies the start and end points, steps S2 to S5 are executed sequentially.
[0263] The above are merely preferred embodiments of the present invention and are illustrative in nature, not restrictive. Those skilled in the art will understand that many changes, modifications, and even equivalents can be made within the spirit and scope defined by the claims of the present invention, all of which will fall within the protection scope of the present invention.
Claims
1. A no-entry zone drawing and path avoidance algorithm based on CANVAS, characterized in that, Includes the following steps: S1 establishes spatial indexes and basic data management to enable fast querying and dynamic management of restricted areas; S2, generate a visibility graph of the dynamically updatable restricted area, calculate the path network of the visibility graph and determine the priority of the path nodes through a comprehensive evaluation function, establish a heuristic path search based on the evaluated path nodes, and construct the basic network of the path search. S3. After initializing the path search parameters, perform the search to obtain the initial path framework. Then, perform path smoothing, conflict detection and correction on the smoothed path, calculate the optimal path based on the origin and destination, and generate a high-quality path that meets the constraints. S4 monitors changes in restricted areas in real time, replans the affected routes after the changes, and establishes a hierarchical route caching mechanism. S5 constructs a multi-layered drawing structure, a path editing system, and an interactive editing structure for restricted areas. It monitors the path search performance, collision detection performance, and rendering performance of the restricted area drawing and path avoidance algorithms in real time, and provides a user interface to realize the visual editing of paths and restricted areas. S6 adapts to the scene by drawing restricted areas and adaptively adjusting path avoidance algorithm parameters, establishing intelligent memory allocation, storage, and access, thereby achieving adaptive optimization and exception handling of the system.
2. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 1, characterized in that, Step S1 specifically includes the following: S11, establish an R-tree index to store the restricted areas of complex polygons, and create a quadtree structure to support dynamic insertion and deletion operations. Partition the restricted areas of point-like and geometric objects with an area of less than 100 square pixels or a boundary complexity of less than 4 vertices. Set up a two-level index mapping in the R-tree index and establish a dynamic maintenance mechanism for the restricted area index. S12, construct a restricted area data model, including geometric information, attribute labels, priority and timeliness data structure, establish a standardized storage format and fast serialization mechanism for geometric data, perform geometric accuracy verification and automatic repair, adopt a hierarchical repair strategy after repair failure, save repair records and roll back, if repair is not possible, mark it as invalid, prompt the user and provide alternative solutions. S13. The restricted area adopts a hierarchical priority coverage rule, assigning dynamic weight values based on the restricted area type to ensure rule consistency and system stability in a multi-restricted area environment. The calculation model for the dynamic weight values is as follows: Where t represents the cumulative time since creation. The attenuation coefficient is... , This represents the actual weight value at time t. This represents the initial weight value, i.e., the base weight set during creation. This represents the minimum weight value, used as a protection threshold to prevent weight decay to zero. S14: Build a Canvas drawing optimization engine to achieve high-performance visualization rendering, establish a layered rendering mechanism, and divide the Canvas into rendering blocks.
3. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 1, characterized in that, Step S2 specifically includes the following: S21. Construct a visibility graph based on the vertices and boundaries of the restricted areas, extract the vertex coordinates of all restricted areas, add start and end points, perform line of sight detection on each pair of nodes, establish a connection edge if the line of sight is not obstructed by any restricted area, calculate the connection relationship of all unobstructed nodes, and establish a potential path network and a dynamic update mechanism for the visibility graph. The dynamic update mechanism of the visibility map is as follows: when the restricted area changes, an incremental update strategy is adopted, and only the visibility connectivity of the affected area is recalculated; S22 preprocesses the visibility graph, calculates the shortest distance matrix between nodes, and uses it for path cost calculation and search optimization. The Johnson algorithm is used to handle negative weight edges and complex weight assignments. S23, The comprehensive evaluation function F(path), built upon path quality assessment and node priority ranking, determines node priority: Among them, the distance term: Smoothness term: Security items: Set the adaptive weighting coefficients as follows: α=0.5, β=0.3, γ=0.
2. This represents the coordinates of the i-th node on the path. This represents the direction angle of the path at the i-th node; S24, estimating the cost from node n to the target point and constructing the heuristic function h(n) is as follows: Where n represents the path node currently being evaluated, and Indicates the coordinates of the current node. and The target node coordinates are represented by `penalty_factor`, which represents the penalty factor. The penalty_factor is dynamically adjusted based on the restricted area density and path complexity. The adjustment method is as follows: Wherein, density coefficient = number of restricted areas within a radius of 100 pixels / 10, complexity coefficient = path turning angle / 5.
4. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 1, characterized in that, Step S3 specifically includes the following: S31, initialize the basic parameters of the A* search based on the start and end coordinates. The specific parameters for the heuristic function initialization are as follows: The weighting coefficient w = 1.2, Euclidean distance is used as the distance calculation method, and the initial value of the penalty factor = 1.0; Establish a search rectangle boundary by extending 200 pixels to both sides of the line connecting the start and end points. Nodes outside the boundary are not included in the search to limit computational complexity. Establish path constraints for maximum path length, maximum turning angle, and minimum safe distance. S32 performs multi-stage path search on the visibility graph using the A* search algorithm to obtain the initial path framework and establishes a checkpoint mechanism for the search state. A checkpoint is set every 100 nodes processed to record the current search state and support recovery from the checkpoint after the algorithm is interrupted. S33, use cubic spline interpolation to smooth the initial path frame. The specific cubic spline function equation S(t) is: Where t represents the parameter variable, , , , and The four coefficients of the cubic spline are obtained by solving for the boundary conditions. Boundary conditions: , , , in, and These represent the position values of the spline function at parameters 0 and 1, respectively. and Let represent the coordinates of the start and end points of the spline segment, respectively. and Let represent the derivative values of the spline function along the tangent direction at parameters 0 and 1, respectively. and These represent the tangent direction vectors at the starting and ending points, respectively. S34 performs accurate collision detection on the smoothed path, uses the separating axis theorem to detect intersections between the path and the polygonal restricted area, and performs minimization adjustment on the detected conflicts. The minimization adjustment method adopts a local path replanning strategy and establishes a backoff mechanism when the correction fails.
5. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 1, characterized in that, Step S4 specifically includes the following: S41, establish a restricted area change monitoring mechanism to detect and respond to change events, detect the addition, deletion and modification of restricted areas in real time, determine the path segments that need to be recalculated through geometric intersection judgment, and establish a change event queue through incremental update for batch processing and priority scheduling; S42, replans the path segments affected by changes in restricted areas using a local search algorithm; S43 establishes a lightweight version control system based on Git principles, assigns a UUID to each path, maintains a version tree structure, and supports branching, merging, and tagging operations. It evaluates the quality of paths through a comprehensive evaluation function, records historical paths and change trajectories, compares path quality, and selectively rolls back. When a correction fails, it rolls back to the algorithm-level state recovery and the path rolls back to the user-level version selection. S44 establishes a multi-level path caching mechanism consisting of global path caching, regional path caching, and local path caching. It uses computation time, memory usage, and cache hit rate as monitoring metrics to establish a cache hit rate statistics and performance monitoring mechanism.
6. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 1, characterized in that, Step S5 specifically includes the following: S51 creates a multi-layered CANVAS structure consisting of a static background layer, a dynamic restricted area layer, a path display layer, and an interactive overlay layer. It shares data and transmits events by establishing an inter-layer communication mechanism. The inter-layer communication protocol is based on a custom event system and uses a publish-subscribe pattern. S52 establishes a path style system and visual indicators of path quality, enabling interactive path editing, drag-and-drop adjustments, and node editing; S53 constructs an interactive editing interface for restricted areas, combining the precise drawing of CAD software with the intuitive operation of map applications, including restricted area drawing tools, interactive editing of restricted areas, restricted area attribute editing panel, and batch operations for restricted areas; S54 employs Web Worker for background monitoring, uses a high-precision timer `performance.now()` to measure microsecond-level performance, performs performance trend analysis and anomaly detection based on statistical methods, monitors the path search performance, collision detection performance, and rendering performance of the no-entry zone drawing and path avoidance algorithms in real time, conducts performance benchmark tests, and performs comparative analysis.
7. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 6, characterized in that, The path style system in step S52 includes gradient color mapping path quality, dynamic line width representing passage difficulty, dashed line style distinguishing path type, and arrow density reflecting speed limit; the visualization indicators are path credibility reflected by color transparency, congestion prediction reflected by color temperature, and safety level reflected by border style. The path styling system adopts a cascading mechanism similar to CSS style sheets, automatically adjusting the visual style according to the real-time attributes of the path, realizing two-way binding between style and data, and providing preset style templates so that users can quickly switch between different visual styles. The path quality visualization index adopts a multi-dimensional quantitative evaluation system and performs real-time quality monitoring. It provides a quality change trend chart, supports quality threshold alarms and quality comparison of multiple paths, displays various indicators side by side, provides optimal path recommendations, automatically identifies the best solution based on comprehensive scores, and records and analyzes historical changes in path quality.
8. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 1, characterized in that, Step S6 specifically includes the following: S61 automatically adjusts algorithm parameters according to scene complexity and performance requirements, establishes parameter optimization models and parameter validity verification and boundary checking mechanisms, configures parameter templates for multiple scenes, and the boundary checking mechanism includes automatic correction of parameter out-of-bounds, alarm for abnormal parameters, and default parameter rollback function; S62, establish an algorithm degradation mechanism and issue user error messages and suggested solutions; S63 intelligently allocates memory, establishes an object pool mechanism, reuses frequently created objects, and performs incremental garbage collection.
9. The CANVAS-based no-entry zone drawing and path avoidance algorithm as described in claim 8, characterized in that, The specific operation of the intelligent memory allocation in step S63 is as follows: S631, establishing a symmetric pooling mechanism: Pre-allocate commonly used object types: including path nodes, restricted area data structures, and visibility graph nodes; Set an object reuse strategy: recycle objects to the object pool after use instead of destroying them directly; Object pool management: Maintains a list of available objects of different types, and allocates and recycles them as needed; S632, reusing frequently created objects: Reference counting management: tracks the number of references to each object to determine when it is safe to reclaim it; Lifecycle management: Monitoring the complete lifecycle of an object from creation to destruction; Reduce memory allocation overhead: Avoid frequent memory allocation and deallocation operations by reusing objects; S633, implementing progressive waste recycling: Time-sharing garbage collection strategy: Distribute the garbage collection operations of a large number of objects across multiple time slices; Avoid performance stalls: Prevent UI lag or computation interruptions caused by garbage collection of a large number of objects at once; Intelligent scheduling and recycling: Prioritize waste recycling operations during system idle periods.