Method of loading and displaying large quantities of objects based on WebGL
Through WebGL-based technology, the lag problem of traditional ship traffic management systems when loading and displaying a large number of ship targets has been solved, and the smooth loading and dynamic updating of large batches of targets have been achieved, improving supervision efficiency and navigation safety.
Patent Information
- Application Number
- CN202110198084.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-12-04
- Filing Date
- 2021-02-22
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-02-22
AI Technical Summary
Traditional web-based ship traffic management systems are prone to interface freezes or process freezes when loading and displaying a large number of ship targets, resulting in inadequate supervision and possible traffic accidents.
Adopting a WebGL-based mass target loading and display method, through map loading, target reception and analysis, coordinate conversion and graphics generation, WebGL is used to achieve target overlay and dynamic updating, ensuring that large batches of target data are loaded and rendered on the map at the same time. and perform smooth dynamic data updates.
It realizes the simultaneous loading and rendering of large batches of target data on the map display interface, improves the smoothness and efficiency of target display, reduces the time for supervisors to analyze jumping targets, improves supervision efficiency and navigation safety, and solves the problems in traditional methods. Problems with incomplete display and delayed updates.
Smart Images

Figure CN112883308B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of VTS system data visualization, and in particular to a method for loading and displaying large quantities of objects based on WebGL. Background Art
[0002] With the continuous deepening and development of the application of Vessel Traffic Management System (VTS), a web-based traffic management system has been proposed and has become the focus of VTS applications. The traditional web-based vessel traffic management system uses VML, SVG and other methods to load and display ship targets on the page. This method has a limited number of targets loaded and displayed on the interface. When a large number of ship targets are drawn at the same time, the interface may freeze or even the process may die, seriously affecting the user's use of the system. There are even cases where ship targets are not loaded and displayed on the map, resulting in "ghost" ships, which can lead to VTS traffic accidents due to inadequate supervision.
[0003] Therefore, a complete set of technical methods that can quickly load maps, smoothly draw and display all ship targets, and update the dynamic data of ship targets in time is very important. This method is designed to solve the above problems. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method for loading and displaying large quantities of targets based on WebGL in view of the deficiencies of the above-mentioned prior art. The method for loading and displaying large quantities of targets based on WebGL can simultaneously load and render large quantities of target data on the map display interface, and can smoothly load and update the dynamic data of large quantities of targets. At the same time, it can also load the map, receive and parse the targets, convert the target coordinates, and generate graphics and primitives, and finally realize the target superposition and dynamic update on the map through the WebGL method, and finally realize the loading and rendering of large quantities of targets.
[0005] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0006] A method for loading and displaying a large number of objects based on WebGL comprises the following steps.
[0007] Step 1, map loading: load the map from the server and convert the loaded map coordinates to WebMercator projection.
[0008] Step 2, target acquisition and processing, specifically includes the following steps:
[0009] Step 21, target acquisition: start tracking the target detected by the radar according to the radar's starting area, and determine the target ship.
[0010] Step 22, target processing: for the target ship obtained in step 21, determine the moving distance and remove the coordinate position jump points.
[0011] Step 3: Target formation, specifically including the following steps:
[0012] Step 31, obtaining target information: multiple targets are received through data messages to form multiple target information. Each target information includes static information and dynamic information. Dynamic information includes target coordinates, heading, and speed information. Static information includes the length, width, and batch number information of the target.
[0013] Step 32, target forming: In WebGL, according to the target length and width information obtained in step 31, each target is drawn one by one to form a plurality of ship icon graphics.
[0014] Step 4, coordinate conversion: each target coordinate obtained in step 31 is uniformly converted into pixel coordinates to form the pixel coordinates (x′, y′) of the target center point.
[0015] Step 5: Target loading, including the following steps:
[0016] Step 51, loading canvas layer: on the map interface loaded in step 1, load a canvas layer, and make the pixel size of the canvas layer consistent with the pixel size of the map, and the canvas layer is a pixel coordinate system.
[0017] Step 52: target scaling processing, specifically including the following steps:
[0018] Step 52A, determine the scaling factor: determine the scaling factor (sx, sy) according to the scaling effect of the canvas layer or map interface in step 51. Wherein, sx represents the scaling ratio of the x-axis in the canvas layer or map interface, and sy represents the scaling ratio of the y-axis in the canvas layer or map interface.
[0019] Step 52B, target scaling: Use the following formula (2) to scale the horizontal axis x and the vertical axis y of the ship icon graphic formed in step 3. The expression of formula (2) is:
[0020]
[0021] Among them, x1 is the horizontal axis where the scaled ship icon graphic is located, and y1 is the vertical axis where the scaled ship icon graphic is located.
[0022] Step 53, target loading: According to the pixel coordinates (x', y') of the corresponding target center point formed in step 4,
[0023] Then load the center points of the multiple ship icon graphics scaled in step 52 and display them in the canvas layer.
[0024] Position the ship at the correct location and make sure the bow of the ship icon faces due north.
[0025] Step 6, angle conversion: The ship icon loaded on the map is dynamically rotated so that the bow point facing due north is rotated to the corresponding heading.
[0026] The target processing in step 22 specifically includes the following steps:
[0027] Step 22A: Set the target moving distance deviation threshold.
[0028] Step 22B, target data acquisition: Receive target data through TCP messages, and parse the target data to obtain the continuous actual target coordinate points of each target, as well as the time point, speed and heading corresponding to each actual target coordinate point.
[0029] Step 22C, calculate the theoretical target coordinate point at the next time point T2: calculate the theoretical target coordinate point at the next time point T2 according to the actual target coordinate point, speed and heading at the previous time point T1, and the time value between the two time points T1 and T2.
[0030] Step 22D, remove the coordinate position jump point: if the deviation value of the actual target coordinate point corresponding to the next time point T2 in step 22B and the theoretical target coordinate point in step 22C does not exceed the target moving distance deviation threshold set in step 22A, the actual target coordinate point corresponding to the next time point T2 is considered to be a stable target data. Otherwise, the actual target coordinate point corresponding to the next time point T2 is considered to be a jump target and is removed.
[0031] In step 22A, the method for calculating the target moving distance deviation threshold comprises the following steps:
[0032] Step 22A1, calculate the target moving distance deviation K: Assume that the real coordinates of the target at time P0 before moving are P0 (x0, y0), and the real coordinates at time P2 after moving are P2 (x2, y2). At time P2, the predicted coordinates calculated based on the position, angle and speed at time P0 are P2′ (x2′, y2′). Then the target moving distance deviation K is calculated using the following formula:
[0033]
[0034] Step 22A2: Obtain the real coordinates of the target at n consecutive moments, where n is not less than 20.
[0035] Step 22A3: Calculate the predicted coordinates of the target at n consecutive moments.
[0036] Step 22A4: Using the method of step 22A1, calculate the target moving distance deviation K at n consecutive moments.
[0037] Step 22A5, for the n target moving distance deviations K obtained in step 22A4, calculate the mean K0 and the standard deviation σ, and obtain the target moving distance deviation threshold KT, then KT = K0 ± 3σ, and KT = 0-45.
[0038] In step 32, the method of drawing each target specifically includes the following steps:
[0039] Step 32A, construct the four corner points of the target ship: Based on WebGL, arbitrarily select a coordinate point in the pixel coordinate system as the center point of the target, and according to the length and width information of the target, expand the outline around the center point of the target to obtain the four corner points of the target ship.
[0040] Step 32B, construct the bow point of the target ship: draw a bow point directly in front of the two corner points of the broadside.
[0041] Step 32C, draw the outer frame of the target ship: connect the four corner points and one bow point in sequence to form a pentagonal outer frame of the target ship.
[0042] Step 32D, divide the triangle: divide the outer frame drawn in step 32C into the smallest unit triangle to form the primitives to be colored.
[0043] Step 32E, coloring: Turn on the graphics card. In WebGL, use the graphics card to color and fill each primitive to form a ship icon graphic.
[0044] In step 4, the specific process of coordinate transformation includes the following steps:
[0045] Step 41, conversion of geographic coordinates into radians: convert the acquired geographic coordinates of the target center point into radians to form (rLog, rLat).
[0046] Among them, rLog represents the longitude in radians, with east longitude being positive and west longitude being negative, and rLat represents the latitude in radians, with north latitude being positive and south latitude being negative.
[0047] Step 42, converting to pixel coordinates: converting the (rLog, rLat) coordinates formed in step 41 to pixel coordinates (x, y) according to the following formula (1), the expression of formula (1) is:
[0048]
[0049] Here, r represents the radius of the earth.
[0050] In step 6, angle conversion specifically includes the following steps.
[0051] Step 61, Baseline Alignment: The true north direction of the map is 0 degrees, so that the angle of the target is aligned with the map angle.
[0052] Step 62, calculate the rotation angle γ: According to the heading of the target obtained in step 31, determine the angle γ that the ship icon needs to rotate. Assuming that the axis passing through the target center point O and perpendicular to the map interface is the z-axis, the ship icon will rotate positively around the z-axis. Assuming that at a certain point A on the ship icon, the angle at which the OA line intersects the x-axis before rotation is a, and the angle at which the OA line intersects the x-axis after rotation is b, the calculation formula for the rotation angle γ is: γ=b–a.
[0053] Step 63, calculate the coordinates of the icon after rotation: Assume that the coordinates of point A before rotation are (x′, y′), and the coordinates of point A after rotation are (x″, y″). Then use the following formulas (3) and (4) to solve and obtain the coordinates of point A after rotation:
[0054] is (x″, y″). The expressions of formula (3) and formula (4) are:
[0055]
[0056]
[0057] Where r1 is the rotation radius of point A.
[0058] Step 64, graphic rotation: the ship icon graphic loaded in step 53 is transformed into the following matrix with its own center point as the origin to realize the angle rotation transformation of the target graphic. Where x and y represent the coordinates of each border point.
[0059]
[0060] The method further includes step 65, first rendering: drawing and rendering the graphics rotated to the correct angle together with the target graphics by means of WebGL.
[0061] Step 66, re-rendering: When the target dynamic information is updated, only the updated position and angle are re-rendered.
[0062] The present invention has the following beneficial effects:
[0063] 1. The present invention simultaneously loads and renders a large amount of target data on a map display interface, and can smoothly realize batch target loading and batch target dynamic data updating.
[0064] 2. The present invention provides map loading, target reception and parsing, target coordinate conversion and generation of graphics and primitives, and finally realizes target overlay and dynamic update on the map through WebGL, and finally realizes large-scale target loading and rendering.
[0065] 3. The traditional target display mode (non-WebGL) runs in the Dom of the page. The Dom operation consumes a lot of CPU computing power and system memory. At the same time, the data loading of the Dom of the page is limited. When it exceeds a certain limit, the stability and response speed of the page itself will have problems. Therefore, when a large number of targets are loaded, the page will first freeze and then crash, and finally restart. The present invention is based on WebGL technology. WebGL is a 3D drawing standard. This drawing technology standard allows JavaScript and OpenGL ES 2.0 to be combined together. By adding a JavaScript binding to OpenGL ES 2.0, WebGL can provide hardware 3D accelerated rendering for HTML5 Canvas, so that 2D, 3D scenes and models can be displayed more smoothly in the browser with the help of the system graphics card. The traditional working mechanism of target rendering and display through CPU and memory has been changed, thereby improving display capabilities and efficiency.
[0066] 4. The present invention removes unstable erroneous targets by performing jump judgment and filtering on targets, reducing the time for supervisors to analyze and judge jumping targets, allowing supervisors to focus their time and energy on tracking and managing stable targets, thereby improving supervision efficiency.
[0067] 5. The present invention uses WebGL-based target loading and display to greatly increase the number of target displays. This changes the situation in which supervisors can only view specific targets in a small range and can only view influence maps or aggregation maps in a large range. It realizes the ability to view specific targets in a macroscopic range, increases the scope of supervision and the number of supervised targets, and thus ensures the safety of ship navigation.
[0068] 6. This method can display and update targets more quickly and effectively, solving the problems of incomplete display, update delay and jamming in traditional target display. It can timely understand the ship position information and timely and effectively judge whether the ship target is in danger of collision or encounter, further improving safety.
[0069] 7. The present invention can realize the loading and processing of large quantities of targets, which is very suitable for the current maritime page-side BS application. First, load the basic map of the nautical chart, receive and parse the AIS / radar target message data through TCP messages, and fuse the received data to form a unified target. Expand the target coordinates according to the length and width of the target, form the frame coordinates to form the primitives, and color them into graphic targets. Bind the canvas through map events to achieve target re-rendering when the map range changes and dynamic update of the target when the target dynamic data changes. The present invention greatly improves the number and efficiency of target loading. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 It is a schematic diagram of a method for loading and displaying large quantities of objects based on WebGL of the present invention.
[0071] Figure 2 Shows the basic processing flow chart of radar for target detection and tracking.
[0072] Figure 3 A diagram of the target forming process is shown.
[0073] Figure 4 A schematic diagram showing the setting of the target moving distance deviation threshold during target processing is shown.
[0074] Figure 5 A schematic diagram showing the process of angular rotation is shown. DETAILED DESCRIPTION
[0075] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific preferred embodiments.
[0076] In the description of the present invention, it should be understood that the terms "left side", "right side", "upper part", "lower part" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. "First", "second" and the like do not indicate the importance of the components, and therefore cannot be understood as limiting the present invention. The specific dimensions used in this embodiment are only for illustrating the technical solution, and do not limit the scope of protection of the present invention.
[0077] like Figure 1 As shown, a method for loading and displaying a large number of objects based on WebGL includes the following steps:
[0078] Step 1, map loading: load the map from the server and convert the loaded map coordinates to the WebMercator projection, preferably WGS84 Web Mercator.
[0079] If the map in the server has a WebMercator projection, it will be directly loaded in the WebMercator projection coordinate system. Otherwise, the map will be loaded first, and then the loaded map coordinates will be converted to the WebMercator projection.
[0080] WGS84 Web Mercator is the coordinate system for map display. When loading and drawing objects on the map, there is no need for secondary coordinate conversion. It can be achieved by simply matching them with the corresponding pixel coordinates.
[0081] The specific process of map loading is as follows: First, load the map slice service. The map coordinate system is WebMercator projection. The level of the map starts from 0. As the level increases, the number of all slices in the large level is 4 times the number of slices in the small level. That is, there is a mathematical relationship between the number of all slices in each level and the level. The number of slices that need to be loaded is TitleConut(level) = 4 level (level ≥ 0).
[0082] When the earth is zoomed to a certain level, assuming the current level is 5, there must be slices at level 5 on the map, but not all slices at level 5 are displayed on the map. Only the slices at level 5 in the view volume need to be displayed. Areas that are not in our field of view do not need to be rendered using slices at level 5. Except for level 0, each slice has a parent slice. The four slices at level 5 above must have a parent slice. It is possible that their parent slices are the same or different. The four parent slices at level 4 are also to be displayed. Similarly, the parent slices at level 3 are also to be displayed, until level 0. Except for level 0, levels 1, 2, 3, 4, and 5 may only display a portion of the slices at that level. This situation becomes more obvious as the level increases. In other words, as the level increases, the proportion of the number of slices displayed at that level to the total number of slices at that level becomes smaller and smaller.
[0083] Step 2, target acquisition and processing, specifically includes the following steps.
[0084] Step 21, target acquisition: start tracking the target detected by the radar according to the radar's starting area, and determine the target ship.
[0085] The above radar detects and tracks targets, such as Figure 2 As shown, it is the prior art, which specifically includes the following steps:
[0086] Step 21A, target detection: draw a radar tracking mask to exclude areas that do not need to be detected and tracked. Targets that can be detected in 10 consecutive cycles within the tracking area are considered to be true radar targets.
[0087] Step 21B, target tracking: Calculate the residual vector based on the quantity measurement and state prediction, track the change of the residual vector to perform maneuver detection and maneuver identification; calculate according to the filter overflow and covariance matrix, obtain the estimated value and predicted value of the target through the filtering algorithm, and complete the target tracking function.
[0088] Step 22, target processing: for the target ship obtained in step 21, the moving distance is determined and the coordinate position jump points are removed, which specifically includes the following steps:
[0089] Step 22A, setting a target moving distance deviation threshold, and specifically setting a calculation method, preferably includes the following steps.
[0090] Step 22A1, calculate the target moving distance deviation K.
[0091] like Figure 4 As shown in the figure, assume that the real coordinates of the target at time P0 before movement are P0 (x0, y0), and the real coordinates at time P2 after movement are P2 (x2, y2). At time P2, the predicted coordinates calculated based on the position, angle and speed at point P0 are P2′ (x2′, y2′). Then the target moving distance deviation K is calculated using the following formula:
[0092]
[0093] Step 22A2: Obtain the real coordinates of the target at n consecutive moments, where n is not less than 20.
[0094] Step 22A3: Calculate the predicted coordinates of the target at n consecutive moments.
[0095] Step 22A4: Using the method of step 22A1, calculate the target moving distance deviation K at n consecutive moments.
[0096] Step 22A5, for the n target moving distance deviations K obtained in step 22A4, calculate the mean K0 and the standard deviation σ, and obtain the target moving distance deviation threshold KT, then KT = K0 ± 3σ, and KT = 0-45.
[0097] Step 22B, target data acquisition: Receive target data through TCP messages, and parse the target data to obtain the continuous actual target coordinate points of each target, as well as the time point, speed and heading corresponding to each actual target coordinate point.
[0098] Step 22C, calculate the theoretical target coordinate point at the next time point T2: calculate the theoretical target coordinate point at the next time point T2 according to the actual target coordinate point, speed and heading at the previous time point T1, and the time value between the two time points T1 and T2.
[0099] Step 22D, remove coordinate position jump points: compare the actual target coordinate point corresponding to the next time point T2 in step 22B with the theoretical target coordinate point in step 22C. If the deviation value between the two does not exceed the target movement distance deviation threshold set in step 22A, the actual target coordinate point corresponding to the next time point T2 is considered to be a stable target data; otherwise, the actual target coordinate point corresponding to the next time point T2 is considered to be a jump target and is removed.
[0100] Step 22E, draw the navigation curve of the target ship: connect the stable target data in step 22D to form the navigation curve of the target ship; all stable target data form a stable and dynamically balanced target data set.
[0101] Step 22F, target identification: for each target in the target data set, associate it with the corresponding attribute information to obtain the full target information.
[0102] The so-called full target is the collection of all targets received by the radar (excluding jumping targets). Acquiring the full target has the following advantages:
[0103] 1. All targets in the entire supervision area can be displayed on the map.
[0104] 2. The targets of the last 20 cycles will be cached in the memory. The latest targets can be used to judge whether the newly received targets are continuous or jumping. When a jump is found, the previous target data is still displayed. When a jumping target does not jump for 20 consecutive cycles after jumping, it means that the target has become a stable target again, and the new target data will continue to be used on the map.
[0105] Step 3: Target forming, specifically including the following steps.
[0106] Step 31, obtaining target information: receiving multiple targets through data messages to form multiple target information.
[0107] Each target information includes static information and dynamic information; the dynamic information includes the target coordinates, heading, and speed information; the static information includes the length, width, and batch number information of the target.
[0108] Step 32, target forming: In WebGL, according to the length and width information of the target obtained in step 31, each target is drawn one by one to form a plurality of ship icon graphics.
[0109] The drawing method for each of the above targets is as follows: Figure 3 As shown, the specific steps include:
[0110] Step 32A, construct the four corner points of the target ship: Based on WebGL, arbitrarily select a coordinate point in the pixel coordinate system as the center point of the target, and according to the length and width information of the target, expand the outline around the center point of the target to obtain the four corner points of the target ship.
[0111] Step 32B, construct the bow point of the target ship: draw a bow point directly in front of the two corner points of the broadside.
[0112] Step 32C, draw the outer frame of the target ship: connect the four corner points and one bow point in sequence to form a pentagonal outer frame of the target ship.
[0113] Step 32D, divide the triangle: divide the outer frame drawn in step 32C into the smallest unit triangle to form the primitives to be colored.
[0114] Step 32E, coloring: Turn on the graphics card. In WebGL, use the graphics card to rasterize each primitive and fill the middle part with color to form a ship icon graphic.
[0115] Step 4, coordinate conversion: each target coordinate obtained in step 31 is uniformly converted into pixel coordinates to form the pixel coordinates of the target center point.
[0116] The specific process of the above coordinate transformation includes the following steps:
[0117] Step 41, conversion of geographic coordinates into radians: convert the geographic coordinates of the target center point obtained in step 31 into radians to form (rLog, rLat); wherein rLog represents longitude in radians, with east longitude being positive and west longitude being negative, and rLat represents latitude in radians, with north latitude being positive and south latitude being negative.
[0118] Step 42, converting to pixel coordinates: converting the (rLog, rLat) coordinates formed in step 41 to pixel coordinates (x′, y′) according to the following formula (1), where the expression of formula (1) is:
[0119]
[0120] Here, r represents the radius of the earth.
[0121] Step 5: Target loading, specifically including the following steps.
[0122] Step 51, load the canvas layer.
[0123] On the map interface loaded in step 1, load a canvas layer. The coordinate system of the canvas layer starts from the upper left corner (0, 0). x increases to the right and y increases downward. The pixel size of the canvas is required to be consistent with the pixel size of the map. At this time, it is a pixel coordinate system. Finally, the 2D context is obtained through the canvas object to draw and render the target.
[0124] This step is a process of reversing the WGS84 geographic coordinate system to generate a pixel coordinate system and rendering the target through pixels. After the target is loaded, the map event is bound to the canvas, and the map zoom in, zoom out, pan and other operation events are triggered synchronously when the above map event operations are performed, so that the loaded target is re-rendered and a target suitable for the current map is generated.
[0125] The map and canvas layers are bound together. The canvas is attached to the map layer and is a separate layer. When you zoom in or out on the map on the system, it is actually the map that is zooming in or out. However, in order to ensure that the canvas layer can also follow the map, Figure 1 Changes occur, listen for map events (zooming), and when the map is operated (zooming), the target on the canvas layer is adjusted to make it zoomed at the same time. In this way, operating the map is like zooming the canvas.
[0126] In the canvas layer, the target length, width and time are encoded to form a key-value pair [Key, Value] of the target; Key represents the unique index value of the target, including the target length, width and time value; Value represents the target data; the target data includes dynamic information and static information; the dynamic information includes ship coordinate information, heading information, speed information, and the static information includes ship length, ship width, and batch number information.
[0127] In this embodiment, the length and width values of the Key value are fixed values, and the time value is determined by the time range in which the target acquisition time falls. That is, the continuous time is divided into 10-minute segments, and the time is the start time of the time segment into which the acquisition time falls. If the key value is lost, it will be acquired again in a very short time, so after a certain period of time, it will return to the original key value again, which can reduce the frequency of internal switching and improve processing efficiency.
[0128] Step 52: target scaling processing, specifically including the following steps.
[0129] Step 52A, determine the scaling factor: determine the scaling factor (sx, sy) according to the scaling effect of the canvas layer or map interface in step 51; wherein sx represents the scaling ratio of the x-axis in the canvas layer or map interface, and sy represents the scaling ratio of the y-axis in the canvas layer or map interface.
[0130] Step 52B, target scaling processing: Use the following formula (2) to scale the horizontal axis x and the vertical axis y where the ship icon graphic formed in step 3 is located; wherein the expression of formula (2) is:
[0131]
[0132] Among them, x1 is the horizontal axis where the scaled ship icon graphic is located, and y1 is the vertical axis where the scaled ship icon graphic is located.
[0133] The above formula (2) can also be expressed by the following matrix:
[0134]
[0135] After the target is loaded on the canvas layer, when the map is scaled, the target loaded on the canvas must also be scaled to adapt to the map scale. The scale factor is determined by the map scale, and then the matrix conversion is performed on the target loaded on the canvas layer at the same scale with the scale factor, so as to achieve the same enlargement or reduction of the rendered target. If this step is performed, all the targets displayed on the map need to be cleared, and then reloaded and rendered through the previous steps, which will affect the processing efficiency. This is one of the methods to improve display efficiency.
[0136] Step 53, target loading: according to the pixel coordinates (x′, y′) of the corresponding target center point formed in step 4, positioning is performed in the canvas layer; then the center points of the multiple ship icon graphics scaled in step 52 are loaded and displayed at the positioning points of the canvas layer, and the bow points of the ship icon graphics are made to face the north direction.
[0137] The canvas layer is bound to the map, and its size is consistent with the size of the map interface. Because the target is converted from the original geographic coordinates to the pixel coordinates supported by the canvas, the location of the target loaded on the canvas is the same as the location loaded directly on the map without coordinate conversion. This ensures the consistency of the position. So why not load it directly on the map instead of loading it through the canvas? Because the canvas can support the GPU, and the GPU can be used to load and draw targets, which can improve efficiency and achieve smooth loading of large quantities of targets.
[0138] Step 6: Angle conversion: The ship icon loaded on the map is dynamically rotated so that the bow point facing due north is rotated to the corresponding heading.
[0139] The above angle conversion method specifically includes the following steps.
[0140] Step 61, base alignment: The true north direction of the map is 0 degrees, so that the angle of the target is aligned with the map angle. That is, the starting angle of all targets starts from the true north direction. Rotate with the ship target center as the center and the target vertex as the rotation point.
[0141] Step 62, calculate the rotation angle γ: according to the heading of the target obtained in step 31, determine the angle γ that the ship icon graphic needs to rotate.
[0142] Assuming that the axis passing through the target center point O and perpendicular to the map interface is the z-axis, the ship icon will rotate positively around the z-axis; assuming that at a certain point A on the ship icon, the angle at which the OA line intersects the x-axis before rotation is a, and the angle at which the OA line intersects the x-axis after rotation is b, the calculation formula for the rotation angle γ is:
[0143] γ=b–a
[0144] In this embodiment, if Figure 5 As shown, with due north as the starting point at 0 degrees, the angle between the x-axis and the due north direction is 90 degrees.
[0145] Step 63, calculate the coordinates of the icon after rotation: Assume that the coordinates of point A before rotation are (x′, y′), and the coordinates of point A after rotation are (x″, y″); then use the following formula (3) and formula (4) to solve and obtain that the coordinates of point A after rotation are (x″, y″); the expressions of formula (3) and formula (4) are:
[0146]
[0147]
[0148] Where r1 is the rotation radius of point A.
[0149] Step 64, graphic rotation: the ship icon graphic loaded in step 53 is transformed into the following matrix with its own center point as the origin, so as to realize the angle rotation transformation of the target graphic. Where x and y represent the coordinates of each point.
[0150]
[0151] Step 65, first rendering: Draw and render the rotated graphics to the correct angle together with the target graphics through WebGL.
[0152] Step 66, re-rendering: When the target dynamic information (position, angle) is updated, the target is no longer drawn, but only the position and angle are updated and re-rendered.
[0153] The preferred embodiments of the present invention are described in detail above; however, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, various equivalent transformations can be made to the technical solutions of the present invention, and these equivalent transformations all belong to the protection scope of the present invention.
Claims
1. A method for loading and displaying a large number of objects based on WebGL, characterized by: The steps include: Step 1, map loading: load the map from the server and convert the loaded map coordinates to WebMercator projection; Step 2, target acquisition and processing, specifically includes the following steps: Step 21, target acquisition: start tracking the target detected by the radar according to the radar's starting area, and determine the target ship; Step 22, target processing: for the target ship obtained in step 21, the moving distance is determined and the coordinate position jump points are removed, which specifically includes the following steps: Step 22A, setting the target moving distance deviation threshold, includes the following steps: Step 22A1, calculate the target moving distance deviation K: Assume that the real coordinates of the target at time P0 before movement are P0 (x0, y0), and the real coordinates at time P2 after movement are P2 (x2, y2); at time P2, the predicted coordinates calculated according to the position, angle and speed at time P0 are P2′ (x2′, y2′); then the target moving distance deviation K is calculated using the following formula: Step 22A2, obtaining the real coordinates of the target at n consecutive moments, where n is not less than 20; Step 22A3, calculating the predicted coordinates of the target at n consecutive moments; Step 22A4, using the method of step 22A1, calculate the target moving distance deviation K of the target at n consecutive moments; Step 22A5: for the n target moving distance deviations K obtained in step 22A4, calculate the mean K0 and the standard deviation σ to obtain the target moving distance deviation threshold KT, where KT=K0±3σ, and KT=0-45; Step 22B, target data acquisition: receiving target data through TCP messages, parsing the target data, acquiring continuous actual target coordinate points of each target, and the time point, speed and heading corresponding to each actual target coordinate point; Step 22C, calculating the theoretical target coordinate point at the next time point T2: according to the actual target coordinate point, speed and heading at the previous time point T1, and the time value between the two time points T1 and T2, the theoretical target coordinate point at the next time point T2 is calculated; Step 22D, removing the coordinate position jump point: if the deviation value between the actual target coordinate point corresponding to the next time point T2 in step 22B and the theoretical target coordinate point in step 22C does not exceed the target moving distance deviation threshold set in step 22A, the actual target coordinate point corresponding to the next time point T2 is considered to be a stable target data; otherwise, the actual target coordinate point corresponding to the next time point T2 is considered to be a jump target and is removed; Step 3: Target formation, specifically including the following steps: Step 31, obtaining target information: receiving multiple targets through data messages to form multiple target information; each target information includes static information and dynamic information; the dynamic information includes target coordinates, heading, speed information; the static information includes the length, width and batch number information of the target; Step 32, target forming: in WebGL, according to the target length and width information obtained in step 31, each target is drawn one by one to form multiple ship icon graphics; Step 4, coordinate conversion: each target coordinate obtained in step 31 is uniformly converted into pixel coordinates, and the pixel coordinates (x′, y′) of the target center point are formed; Step 5: Target loading, including the following steps: Step 51, loading canvas layer: on the map interface loaded in step 1, load a canvas layer, and make the pixel size of the canvas layer consistent with the pixel size of the map, and the canvas layer is a pixel coordinate system; Step 52: target scaling processing, specifically including the following steps: Step 52A, determining a scaling factor: determining a scaling factor (sx, sy) according to the scaling effect of the canvas layer or the map interface in step 51; wherein sx represents the scaling ratio of the x-axis in the canvas layer or the map interface, and sy represents the scaling ratio of the y-axis in the canvas layer or the map interface; Step 52B, target scaling processing: Use the following formula (2) to scale the horizontal axis x and the vertical axis y of the ship icon graphic formed in step 3; wherein the expression of formula (2) is: Among them, x1 is the horizontal axis where the scaled ship icon graphic is located, and y1 is the vertical axis where the scaled ship icon graphic is located; Step 53, target loading: according to the pixel coordinates (x′, y′) of the corresponding target center point formed in step 4, positioning is performed in the canvas layer; then the center points of the multiple ship icon graphics scaled in step 52 are loaded and displayed at the positioning points of the canvas layer, and the bow points of the ship icon graphics are made to face the north direction; Step 6, angle conversion: The ship icon loaded on the map is dynamically rotated so that the bow point facing due north is rotated to the corresponding heading.
2. The method for loading and displaying large quantities of objects based on WebGL according to claim 1, characterized in that: In step 32, the method of drawing each target specifically includes the following steps: Step 32A, constructing four corner points of the target ship: Based on WebGL, arbitrarily select a coordinate point in the pixel coordinate system as the center point of the target, and according to the length and width information of the target, expand the outline from the center point of the target to the surrounding areas to obtain the four corner points of the target ship; Step 32B, construct the bow point of the target ship: draw a bow point directly in front of the two corner points of the broadside; Step 32C, draw the outer frame of the target ship: connect the four corner points and the bow point in sequence to form a pentagonal outer frame of the target ship; Step 32D, dividing triangles: dividing the outer frame drawn in step 32C into triangles of the smallest unit to form primitives to be colored; Step 32E, coloring: Turn on the graphics card. In WebGL, use the graphics card to color and fill each primitive to form a ship icon graphic.
3. The method for loading and displaying large quantities of objects based on WebGL according to claim 1, characterized in that: In step 4, the specific process of coordinate transformation includes the following steps: Step 41, conversion of geographic coordinates into radians: convert the acquired geographic coordinates of the target center point into radians to form (rLog, rLat); wherein rLog represents longitude in radians, with east longitude being positive and west longitude being negative, and rLat represents latitude in radians, with north latitude being positive and south latitude being negative; Step 42, converting to pixel coordinates: converting the (rLog, rLat) coordinates formed in step 41 to pixel coordinates (x, y) according to the following formula (1), the expression of formula (1) is: Here, r represents the radius of the earth.
4. The method for loading and displaying a large number of objects based on WebGL according to claim 1, characterized in that: In step 6, angle conversion specifically includes the following steps: Step 61, reference alignment: the true north direction of the map is 0 degrees, so that the angle of the target is aligned with the angle of the map; Step 62, calculate the rotation angle γ: according to the heading of the target obtained in step 31, determine the angle γ that the ship icon needs to rotate; assuming that the axis passing through the target center point O and perpendicular to the map interface is the z-axis, the ship icon will rotate positively around the z-axis; assuming that at a certain point A on the ship icon, the angle at which the OA line intersects the x-axis before rotation is a, and the angle at which the OA line intersects the x-axis after rotation is b, the calculation formula for the rotation angle γ is: γ = b – a; Step 63, calculate the coordinates of the icon after rotation: Assume that the coordinates of point A before rotation are (x′, y′), and the coordinates of point A after rotation are (x″, y″); then use the following formula (3) and formula (4) to solve and obtain that the coordinates of point A after rotation are (x″, y″); the expressions of formula (3) and formula (4) are: Where r1 is the rotation radius of point A; Step 64, graphic rotation: the ship icon graphic loaded in step 53 is used as the origin, and the coordinates of the five border points of the target are respectively subjected to the following matrix transformation to realize the angle rotation transformation of the target graphic; Among them, x and y represent the coordinates of each border point.
5. The method for loading and displaying large quantities of objects based on WebGL according to claim 1, characterized in that: The step 65 is also included. First rendering: drawing and rendering the graphics rotated to a correct angle together with the target graphics by means of WebGL; Step 66, re-rendering: When the target dynamic information is updated, only the updated position and angle are re-rendered.
