A method and device for downsampling processing of data

By determining the grid index based on the quantization threshold in the back-end engine, discarding or storing adjacent coordinate points, the problems of high data transmission pressure and browser crash in online simulation are solved, and the data volume and browser load are reduced are achieved, ensuring the normal display of the page.

CN118607180BActive Publication Date: 2025-07-11BEIJING GLOBAL CROWN JINYANG TECH DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410639769.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2025-07-11
Estimated Expiration
2044-05-22

AI Technical Summary

Technical Problem

In online simulation applications, when a large amount of data generated by the back-end simulation engine is transmitted to the front-end browser, it causes high data transmission pressure and browser page display crashes.

Method used

Through the downsampling processing method, the grid index of the target coordinate point is determined using the quantization threshold, and adjacent coordinate points are discarded or stored, reducing the amount of data and reducing the browser load.

Benefits of technology

Effectively reduce data transmission pressure, ensure normal drawing and display of browser pages, and dynamically adjust the quantization threshold to meet the requirements of data transmission and page drawing accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118607180B_ABST
    Figure CN118607180B_ABST
Patent Text Reader

Abstract

The present application discloses a method and apparatus for downsampling processing of data. The method includes: for the obtained target coordinate points, when the target coordinate points are coordinate points at a non-initial moment, determining a first grid index of the target coordinate points based on a quantization threshold. Since the target coordinate points are not coordinate points at the initial moment, adjacent coordinate points at the previous moment of the target coordinate points can be obtained, and a second grid index of the adjacent coordinate points can be obtained. When the first grid index is the same as the second grid index, the target coordinate points are discarded. Through the above method, after the coordinate points are output by the backend simulation engine, the adjacent coordinate points can be processed using the grid determined by the quantization threshold, and multiple coordinate points in the same grid can be downsampled into one coordinate point, thereby reducing the amount of data sent to the front-end browser, reducing the data transmission pressure, reducing the load on the browser, and ensuring the normal rendering and display of the browser page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and particularly to a method and device for downsampling data. Background Art

[0002] With the development of computer technology, in the application fields of network transmission and data visualization, large amounts of data and high-frequency transmission are problems that are often faced. In the application scenario of online simulation, the backend simulation engine generates simulation data, and then sends the generated data to the frontend browser, which draws charts, analyzes data, etc. based on the received data.

[0003] When a large amount of data generated by the simulation engine is sent to the frontend browser, it not only causes a large data transmission pressure, but also causes the browser page display to crash when a large number of dense data points are drawn in the frontend browser. Summary of the Invention

[0004] In view of this, this application provides a method and device for downsampling data, so as to reduce the amount of data, reduce the data transmission pressure, reduce the browser load, and ensure the normal drawing and display of the page.

[0005] In a first aspect, this application provides a method for downsampling data, the method includes:

[0006] For the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine the first grid index of the target coordinate point based on a quantization threshold, and the grid corresponding to the first grid index is determined by the quantization threshold;

[0007] Obtain the adjacent coordinate point of the target coordinate point at the previous moment, and obtain the second grid index of the adjacent coordinate point;

[0008] When the first grid index is the same as the second grid index, discard the target coordinate point.

[0009] In a possible implementation manner, the method further includes:

[0010] When the first grid index is different from the second grid index, store the target coordinate point in an array, and the array includes the adjacent coordinate point.

[0011] In a possible implementation manner, the method further includes:

[0012] Determine a plurality of regions based on the plurality of coordinate points included in the array;

[0013] For any region, calculate the density of the coordinate points in the region;

[0014] When the density is greater than a preset density value, for a first coordinate point in the region, calculate the distance between the first coordinate point and a second coordinate point;

[0015] When the distance is less than or equal to a preset distance, delete the second coordinate point, where the first coordinate point is any coordinate point and the second coordinate point is a coordinate point adjacent to the first coordinate point.

[0016] In a possible implementation, the coordinate point includes time information, and the method further includes:

[0017] Obtain the number of coordinate points within a preset time period;

[0018] Update the quantization threshold based on the number and the downsampling factor.

[0019] In a possible implementation, the grid corresponding to the first grid index is a square grid, and the side length of the grid is the quantization threshold. Determining the first grid index of the target coordinate point based on the quantization threshold includes:

[0020] Calculate a first ratio of the abscissa of the target coordinate point to the quantization threshold, and determine a horizontal grid index based on the first ratio;

[0021] Calculate a second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine a vertical grid index based on the second ratio;

[0022] Determine the horizontal grid index and the vertical grid index as the first grid index.

[0023] In a possible implementation, determining the horizontal grid index based on the first ratio includes:

[0024] Round up the first ratio to determine an integer ratio;

[0025] Calculate the product of the integer ratio and the quantization threshold;

[0026] When the abscissa of the target coordinate point is less than the product, determine the integer ratio as the horizontal grid index; when the abscissa of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the horizontal grid index.

[0027] In a possible implementation, determining the vertical grid index based on the second ratio includes:

[0028] Round up the second ratio to determine an integer ratio;

[0029] Calculate the product of the integer ratio and the quantization threshold;

[0030] When the ordinate of the target coordinate point is less than the product, determine the integer ratio as the vertical grid index; when the ordinate of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the vertical grid index.

[0031] In a possible implementation, the method further includes:

[0032] When the target coordinate point is the coordinate point at the initial moment, determine the first grid index of the target coordinate point based on the quantization threshold, and store the target coordinate point in the array.

[0033] In a possible implementation, the target coordinate point is output by the backend simulation engine and stored in the cache, and the method further includes:

[0034] Send the array to the front-end browser.

[0035] In a second aspect, the present application provides a data downsampling processing device, the device includes:

[0036] A determination unit, configured to, for the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine the first grid index of the target coordinate point based on the quantization threshold, and the grid corresponding to the first grid index is determined by the quantization threshold;

[0037] An acquisition unit, configured to acquire the adjacent coordinate points of the target coordinate point at the previous moment, and acquire the second grid index of the adjacent coordinate points;

[0038] A processing unit, configured to discard the target coordinate point when the first grid index is the same as the second grid index.

[0039] In a possible implementation, the device further includes: a storage unit, configured to store the target coordinate point in an array when the first grid index is different from the second grid index, and the array includes the adjacent coordinate points.

[0040] In a possible implementation, the processing unit is further configured to determine a plurality of regions based on a plurality of coordinate points included in the array; for any one of the regions, calculate the density of the coordinate points in the region; when the density is greater than a preset density value, for the first coordinate point in the region, calculate the distance between the first coordinate point and the second coordinate point; when the distance is less than or equal to a preset distance, delete the second coordinate point, the first coordinate point is any coordinate point, and the second coordinate point is the coordinate point adjacent to the first coordinate point.

[0041] In a possible implementation, the coordinate points include time information, and the device further includes: an updating unit, configured to obtain the number of coordinate points within a preset time period; and update the quantization threshold based on the number and the downsampling factor.

[0042] In a possible implementation, the grid corresponding to the first grid index is a square grid, and the side length of the grid is the quantization threshold. The determining unit is specifically configured to calculate a first ratio of the abscissa of the target coordinate point to the quantization threshold, and determine a horizontal grid index based on the first ratio; calculate a second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine a vertical grid index based on the second ratio; and determine the horizontal grid index and the vertical grid index as the first grid index.

[0043] In a possible implementation, the determining unit is specifically configured to round up the first ratio to determine an integer ratio; calculate a product of the integer ratio and the quantization threshold; when the abscissa of the target coordinate point is less than the product, determine the integer ratio as the horizontal grid index; and when the abscissa of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the horizontal grid index.

[0044] In a possible implementation, the determining unit is specifically configured to round up the second ratio to determine an integer ratio; calculate a product of the integer ratio and the quantization threshold; when the ordinate of the target coordinate point is less than the product, determine the integer ratio as the vertical grid index; and when the ordinate of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the vertical grid index.

[0045] In a possible implementation, the determining unit is further configured to, when the target coordinate point is a coordinate point at the initial moment, determine the first grid index of the target coordinate point based on the quantization threshold;

[0046] The storage unit is further configured to store the target coordinate point in the array.

[0047] In a possible implementation, the target coordinate point is output by a backend simulation engine and stored in a cache, and the device further includes: a sending unit, configured to send the array to a front-end browser.

[0048] In a third aspect, the present application provides a device for downsampling processing of data, where the device includes: a memory and a processor;

[0049] The memory is used to store relevant program codes;

[0050] The processor is used to call the program code and execute the downsampling processing method for the data according to any one of the implementation manners of the first aspect above.

[0051] In a fourth aspect, the present application provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the downsampling processing method for the data according to any one of the implementation manners of the first aspect above.

[0052] Thus, the present application has the following beneficial effects:

[0053] In the above implementation manner of the present application, when receiving the coordinate points output by the backend simulation engine, it is possible to determine whether to perform downsampling processing on the coordinate points. Specifically, for the obtained target coordinate points, when the target coordinate points are coordinate points at a non-initial moment, that is, the target coordinate points are not the first coordinate points, the first grid index of the target coordinate points can be determined based on the quantization threshold. Among them, the grid corresponding to the first grid index is determined by the quantization threshold, that is, multiple grids can be determined by using the quantization threshold, and based on the relationship between the quantization threshold and the coordinates of the target coordinate points, the grid corresponding to the target coordinate points, that is, the first grid index, can be determined. Each grid can uniquely correspond to a grid index. Since the target coordinate points are not the coordinate points at the initial moment, the adjacent coordinate points at the previous moment of the target coordinate points can be obtained, and the second grid index of the adjacent coordinate points can be obtained. Among them, the determination method of the second grid index is the same as the determination method of the first grid index. When the first grid index is the same as the second grid index, the target coordinate points are discarded. Through the downsampling processing method for the data provided by the present application, after the coordinate points are output by the backend simulation engine, the adjacent coordinate points can be processed by using the grids determined by the quantization threshold, and multiple coordinate points in the same grid can be downsampled into one coordinate point, so as to reduce the data volume, so as to reduce the data volume sent to the front-end browser, reduce the data transmission pressure, reduce the load of the browser, and ensure the normal rendering and display of the browser page. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments provided in the present application, and those of ordinary skill in the art can also obtain other drawings based on these drawings.

[0055] Figure 1 It is a flowchart of a downsampling processing method for data provided by an embodiment of the present application;

[0056] Figure 2 It is a schematic diagram for determining a grid index provided by an embodiment of the present application;

[0057] Figure 3 Schematic diagram of a data downsampling processing device provided by an embodiment of the present application;

[0058] Figure 4 Schematic diagram of a data downsampling processing device provided by an embodiment of the present application. Detailed implementation manners

[0059] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. The described embodiments are only exemplary embodiments of the present application and not all implementation manners. Those skilled in the art can obtain other embodiments without creative work in combination with the embodiments of the present application, and these embodiments are also within the protection scope of the present application.

[0060] With the development of computer technology, in the application fields of network transmission and data visualization, large amounts of data and high-frequency transmission are problems that often need to be faced. In the application scenario of online simulation, the backend simulation engine will generate simulation data, and then send the generated data to the frontend browser, and the browser will perform icon drawing, data analysis, etc. based on the received data.

[0061] When a large amount of data generated by the simulation engine is sent to the frontend browser, it will not only cause a large data transmission pressure, but also cause the page display of the browser to crash when a large number of dense data points are drawn on the frontend browser.

[0062] Based on this, the embodiments of the present application provide a method for downsampling data to reduce the amount of data, reduce the data transmission pressure, reduce the browser load, and ensure the normal rendering and display of the page. Specifically, when implementing, for the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, that is, the target coordinate point is not the first coordinate point, the first grid index of the target coordinate point can be determined based on the quantization threshold. Among them, the grid corresponding to the first grid index is determined by the quantization threshold, that is, multiple grids can be determined by using the quantization threshold, and based on the relationship between the quantization threshold and the coordinates of the target coordinate point, the grid corresponding to the target coordinate point, that is, the first grid index, can be determined. Each grid can uniquely correspond to a grid index. Since the target coordinate point is not a coordinate point at the initial moment, the adjacent coordinate point of the target coordinate point at the previous moment can be obtained, and the second grid index of the adjacent coordinate point can be obtained. Among them, the determination method of the second grid index is the same as that of the first grid index. When the first grid index is the same as the second grid index, the target coordinate point is discarded. Through the method for downsampling data provided by the present application, after the backend simulation engine outputs coordinate points, the adjacent coordinate points can be processed by using the grids determined by the quantization threshold, and multiple coordinate points in the same grid can be downsampled into one coordinate point, so as to reduce the amount of data, reduce the amount of data sent to the front-end browser, reduce the data transmission pressure, reduce the load of the browser, and ensure the normal rendering and display of the browser page.

[0063] To facilitate understanding of the method provided by the embodiments of the present application, the following will be specifically introduced in conjunction with the drawings in the specification.

[0064] See Figure 1 , Figure 1 which is a flowchart of a method for downsampling data provided by the embodiments of the present application.

[0065] Optionally, the method can be executed by a processing device. The processing device can receive the data output by the backend simulation engine, that is, the coordinate points, and perform downsampling processing on the coordinate points. It can also send the coordinate points after downsampling processing to the front-end browser, and the browser renders and displays according to the coordinate points on the page. In the embodiments of the present application, taking the example of the front-end browser rendering a line chart according to multiple coordinate points output by the backend simulation engine for introduction.

[0066] The method may include the following steps:

[0067] S101: For the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine the first grid index of the target coordinate point based on the quantization threshold.

[0068] When the backend simulation engine is running, it can output coordinate points. Among them, the coordinate points can be composed of the time information of the output coordinate points and the specific coordinate values. For example, the time information can be used as the abscissa of the coordinate point, and the specific coordinate value can be used as the ordinate of the coordinate point.

[0069] In a possible implementation, the coordinate points output by the backend simulation engine can be first stored in a cache, which is convenient for subsequent processing devices to obtain each coordinate point from the cache for downsampling processing.

[0070] When the backend simulation engine outputs the coordinate points at the initial moment, since this coordinate point is the first coordinate point, there is no need to perform downsampling processing on this coordinate point. Therefore, the first grid index of this coordinate point can be determined based on the quantization threshold, and this coordinate point can be stored for subsequent sending of this coordinate point to the front-end browser. The specific implementation of determining the first grid index can be seen in the subsequent embodiments and will not be introduced here first.

[0071] In a possible implementation, this coordinate point can be stored in an array, that is, in this array for storing the coordinate points sent to the front-end browser. When storing the coordinate points in the array, they can be stored based on the chronological order corresponding to the coordinate points. Since this coordinate point is the coordinate point output at the initial moment, this coordinate point can be stored at the initial position in the array.

[0072] Optionally, this coordinate point can also be converted into a binary string for storage. By converting the coordinate point into a binary string and sending it to the front-end browser, the amount of data transmitted can be reduced, the browser load can be reduced, and the front-end page drawing performance can be improved.

[0073] For the target coordinate points output by the backend engine, when this target coordinate point is a non-initial moment coordinate point, it is necessary to determine whether to perform downsampling processing on the target coordinate point based on the relationship between the target coordinate point and the previous adjacent coordinate point.

[0074] Specifically, the first grid index of this target coordinate point is determined based on the quantization threshold. The quantization threshold can be understood as being used to determine the grid, and then the target coordinate point is mapped in the corresponding grid. For example, a square grid can be determined based on the quantization threshold, and the side length of the grid is the quantization threshold.

[0075] In a possible implementation, the first grid index of the target coordinate point can be determined in the following way: calculate the first ratio of the abscissa of the target coordinate point to the quantization threshold, and then determine the horizontal grid index based on the first ratio. Calculate the second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine the vertical grid index based on the second ratio. Thus, the horizontal grid index and the vertical grid index can be determined as the first grid index.

[0076] Determine the first grid index corresponding to the target coordinate point, that is, to determine the grid mapped by the target coordinate point. In actual application scenarios, there may be a situation where the target coordinate point is located on the grid edge. When it is necessary to determine the grid edge where the target coordinate point is located, which grid the target coordinate point belongs to.

[0077] When specifically implemented, when the first ratio of the abscissa of the target coordinate point to the quantization threshold is calculated, when the first ratio is not an integer, round up the first ratio to determine the integer ratio. For example, when the first ratio is 2.3, the integer ratio obtained by rounding up is 3; when the first ratio is 3.6, the integer ratio obtained by rounding up is 4. Then calculate the product of the integer ratio and the quantization threshold. When the abscissa of the target coordinate point is less than the product, it indicates that the target coordinate point is within the grid it belongs to in the horizontal direction, and determine the integer ratio as the horizontal grid index. When the abscissa of the target coordinate point is greater than or equal to the product, add one to the integer ratio to determine the horizontal grid index. In fact, since the integer ratio is obtained by rounding up the first ratio, the abscissa of the target coordinate point can only be less than or equal to the product of the integer ratio and the quantization threshold. Therefore, when the abscissa of the target coordinate point is equal to the product, add one to the integer ratio to determine the horizontal grid index. That is, when the target coordinate point is located on the right boundary of the grid, determine that the target coordinate point belongs to the grid on the right of the current grid in the horizontal direction.

[0078] Similarly, it can be known that when determining the vertical grid index based on the second ratio, the second ratio may not be an integer. Therefore, the second ratio can be rounded up to determine the integer ratio. Then calculate the product of the integer ratio and the quantization threshold. When the ordinate of the target coordinate point is less than the product, it indicates that the target coordinate point is within the grid it belongs to in the vertical direction, and determine the integer ratio as the vertical grid index; when the ordinate of the target coordinate point is greater than or equal to the product, add one to the integer ratio to determine the vertical grid index. Since the integer ratio is obtained by rounding up the second ratio, the ordinate of the target coordinate point can only be less than or equal to the product of the integer ratio and the quantization threshold. Therefore, when the ordinate of the target coordinate point is equal to the product, add one to the integer ratio to determine the vertical grid index. That is, when the target coordinate point is located on the upper boundary of the grid, determine that the target coordinate point belongs to the grid above the current grid in the vertical direction.

[0079] It should be noted that in the above embodiments of the present application, rounding up the first ratio / second ratio to determine an integer ratio is only an exemplary illustration, but is not limited to the above implementation. For example, according to the same principle, rounding down the first ratio / second ratio to determine an integer ratio and other implementable methods also fall within the protection scope of the present application. Similarly, when the abscissa of the target coordinate point is equal to the product (the product of the integer ratio obtained by rounding up the first ratio and the quantization threshold), that is, located at the right boundary of the grid, adding one to the integer ratio to determine the horizontal grid index, or when the ordinate of the target coordinate point is equal to the product (the product of the integer ratio obtained by rounding up the second ratio and the quantization threshold), that is, located at the upper boundary of the grid, adding one to the integer ratio to determine the vertical grid index is only one possible implementation. For example, it can also be set that when the abscissa of the target coordinate point is equal to the product (the product of the integer ratio obtained by rounding up the first ratio and the quantization threshold), the integer ratio obtained by rounding up the first ratio is determined as the horizontal grid index, or when the ordinate of the target coordinate point is equal to the product (the product of the integer ratio obtained by rounding up the second ratio and the quantization threshold), the integer ratio obtained by rounding up the second ratio is determined as the vertical grid index.

[0080] In a possible implementation, the process of determining the first grid index of the target coordinate point can refer to the following code principle:

[0081]

[0082]

[0083] S102: Obtain the adjacent coordinate points of the target coordinate point at the previous moment, and obtain the second grid index of the adjacent coordinate points.

[0084] Since the target coordinate point is not the coordinate point at the initial moment, the adjacent coordinate points of the target coordinate point at the previous moment can be obtained. For each coordinate point output by the backend simulation engine, the grid index corresponding to this coordinate point will be determined. Therefore, the second grid index of the adjacent coordinate points can be obtained at this time. The principle of determining the second grid index is the same as that of determining the first grid index, which can be referred to the above embodiments and will not be elaborated here.

[0085] It should be understood that the adjacent coordinate points are expressed as the coordinate points that have not been downsampled. Therefore, the time corresponding to the adjacent coordinate points may be separated from the time corresponding to the target coordinate point by multiple time units (the time unit of the coordinate points output by the backend simulation engine). That is, there may be other coordinate points removed by downsampling between the target coordinate point and the adjacent coordinate points.

[0086] In a possible implementation, the backend simulation engine can generate multiple coordinate points at the same moment. That is, the moments corresponding to different coordinate points may be the same. At this time, the adjacent coordinate points of the "previous moment" or "next moment" can be determined according to the order in which the backend simulation engine outputs the coordinate points. For example, when there are two adjacent coordinate points, the first coordinate point and the second coordinate point, and the moments at which the first coordinate point and the second coordinate point are generated are the same, but when the backend simulation engine sends the coordinate points to the data processing device, it sends the first coordinate point first and then the second coordinate point. Then the first coordinate point represents the adjacent coordinate point of the second coordinate point at the previous moment.

[0087] S103: When the first grid index is the same as the second grid index, discard the target coordinate point.

[0088] When the first grid index is the same as the second grid index, since the target coordinate point and the adjacent coordinate point are the coordinate points with the closest time interval, and the first grid index is the same as the second grid index, it indicates that the coordinate values of the target coordinate point and the adjacent coordinate point do not differ much. In a scenario like drawing a line chart, the target coordinate point can be removed and only the adjacent coordinate point can be retained.

[0089] When the first grid index is different from the second grid index, it indicates that the coordinate values of the target coordinate point and the adjacent coordinate point differ greatly, which can reflect the performance of the drawn line chart. Therefore, the target coordinate point can be retained. For example, the target coordinate point can be stored in an array, and then the array is sent to the front-end browser for page drawing later. Among them, the array also includes the previously retained adjacent coordinate points. When storing the target coordinate point, the adjacent coordinate point and the target coordinate point can be stored adjacent to each other in chronological order.

[0090] The following is introduced in combination with a specific application scenario. See Figure 2 , Figure 2 which is a schematic diagram of determining a grid index provided by an embodiment of the present application.

[0091] In this application scenario, it can be considered that the coordinate points and the grids are both mapped in an infinitely large two-dimensional space. The origin of the two-dimensional space coordinates is (0, 0), the horizontal axis represents time, the unit is milliseconds / ms, and the vertical axis represents the coordinate value. Set the quantization threshold to 1.1. The first coordinate point output by the backend simulation engine is (3, 19.8), and the second coordinate point is (3.2, 20.4). The second coordinate point is the coordinate point at the next adjacent moment of the first coordinate point, and the first coordinate point is the retained coordinate point. It should be noted that the time interval between the coordinate points output by the backend simulation engine can be not fixed.

[0092] When the back-end simulation engine outputs the second coordinate point, calculate the third ratio of the abscissa 3.2 of the second coordinate point to the quantization threshold 1.1, which is approximately 2.9. Round up the third ratio to obtain the integer ratio 3. Since the abscissa 3.2 of the second coordinate point is less than the product 3.3 of the quantization threshold 1.1 and the integer ratio 3, the horizontal grid index of the second grid index corresponding to the second coordinate point is 3. Calculate the fourth ratio of the ordinate 20.4 of the second coordinate point to the quantization threshold 1.1, which is approximately 18.5. Round up the fourth ratio to obtain the integer ratio 19. Since the ordinate 20.4 of the second coordinate point is less than the product 20.9 of the quantization threshold 1.1 and the integer ratio 19, the vertical grid index of the second grid index is the fourth ratio 19. That is, the second grid index is (3, 19).

[0093] Since the first coordinate point is the reserved coordinate point, that is, the grid index corresponding to the first coordinate point is different from that of the previous adjacent coordinate point. At this time, the first grid index corresponding to the first coordinate point can be obtained. Among them, the determination process of the first grid index is as follows:

[0094] Calculate the first ratio of the abscissa 3 of the first coordinate point to the quantization threshold 1.1, which is approximately 2.7. Round up the first ratio to obtain the integer ratio 3. Since the abscissa 3 of the first coordinate point is less than the product 3.3 of the quantization threshold 1.1 and the integer ratio 3, the horizontal grid index of the first grid index corresponding to the first coordinate point is 3. Calculate the second ratio of the ordinate 19.8 of the first coordinate point to the quantization threshold 1.1, which is 18. After rounding the second ratio, it is still the integer ratio 18. Since the ordinate 19.8 of the first coordinate point is equal to the product 19.8 of the quantization threshold 1.1 and the integer ratio 18, it is necessary to add one to the integer ratio to determine the vertical grid index of the first grid index as 19. That is, the first grid index is (3, 19).

[0095] Since the second grid index of the second coordinate point is the same as the first grid index of the first coordinate point, the second coordinate point is discarded.

[0096] It should be noted that the embodiments of the present application do not limit the specific value of the quantization threshold, and the quantization threshold can be determined in combination with the actual application scenario. Usually, the quantization threshold can be determined in the interval [1, 2]. For example, when the number of coordinate points output by the back-end simulation engine is relatively large and the browser has a low requirement for the page drawing accuracy, relatively more coordinate points can be discarded. At this time, the quantization threshold can be appropriately increased. When the number of coordinate points output by the back-end simulation engine is slightly large and the browser has a high requirement for the page drawing accuracy, the quantization threshold can be appropriately reduced. Based on this, the quantization threshold can be adjusted according to the number of coordinate points. Then, continue to perform downsampling processing on the coordinate points generated by the back-end simulation engine according to the updated quantization threshold.

[0097] In specific implementation, the number of coordinate points within a preset time period is obtained, and the quantization threshold is updated based on the number of coordinate points and the downsampling factor. Among them, the coordinate points can be stored in the cache after being output by the backend simulation engine. That is, the number of coordinate points within the preset time period can be counted, and the quantization threshold can be adjusted according to the size of the data volume.

[0098] Optionally, the updated quantization threshold can be calculated based on the quantization threshold before update, the number of coordinate points, and the downsampling factor. For example, let Th represent the updated quantization threshold, th represent the quantization threshold before update, amount represent the number of coordinate points within the preset time period, and p represent the downsampling factor, then Th can be expressed as: Th = th * amount p . It should be noted that the method for updating the quantization threshold provided in the above embodiments is only an exemplary illustration and is not limited to the above form. A code example will be introduced below.

[0099]

[0100]

[0101] Based on the above code, when adjusting amount and p respectively, the running results are as follows:

[0102] → First run:

[0103] When threshold = 1.3, amount = 100, p = 0.01,

[0104] threshold_result = 1.3612671124661695.

[0105] When amount increases by 10 times to 1000, threshold_result increases from 1.3612671124661695 to 1.3929750968088883, and the growth ratio is approximately 1.02.

[0106] → Second run:

[0107] When threshold = 1.3,, amount = 1000, p = 0.01,

[0108] threshold_result = 1.3929750968088883.

[0109] When the amount increases by 10 times to 10000, the threshold_result increases from 1.3929750968088883 to 1.4254216549861407, and the growth rate is approximately 1.02.

[0110] → Third run

[0111] When threshold = 1.3, amount = 1000, and p = 0.1,

[0112] threshold_result = 2.5938410094595437.

[0113] When the amount increases by 10 times to 10000, the threshold_result increases from 2.5938410094595437 to 3.2654523609624544, and the growth rate is approximately 1.26.

[0114] It should be noted that the interval time for dynamically updating the quantization threshold can be determined according to actual needs. It can be set to automatically trigger the process of updating the quantization threshold after a fixed interval time, or the process of updating the quantization threshold can be triggered manually. The embodiments of this application do not make any limitations in this regard.

[0115] In a possible implementation manner, after downsampling the coordinate points generated by the backend simulation engine based on the above method, the coordinate points retained in the array after downsampling can be obtained. When the number of coordinate points in the array is large, multiple coordinate points in the array can also be downsampled.

[0116] In specific implementation, multiple regions are determined based on the multiple coordinate points included in the array. Since the coordinate points include time information, the regions can be determined based on the time period. For example, a time period of 2 ms can be determined as a region, so that multiple regions can be determined based on the time length of the coordinate points.

[0117] For any region, calculate the density of the coordinate points in this region. Among them, the density can be calculated by calculating the number of coordinate points in this region. When the density is greater than the preset density value, it indicates that the number of coordinate points in this region is large and downsampling processing is required.

[0118] For the first coordinate point in this region, calculate the distance between the first coordinate point and the second coordinate point. For example, it can be the Euclidean distance. The Euclidean distance refers to the straight-line distance between two points in the Euclidean space. The calculation method is as follows: in a two-dimensional space, the first coordinate point P1=(x1, y1) and the second coordinate point P2=(x2, y2), and the Euclidean distance d between the first coordinate point and the second coordinate point can be calculated by the following formula:

[0119] Among them, the first coordinate point can represent any coordinate point, and the second coordinate point is the coordinate point at the next moment adjacent to the first coordinate point. When the distance between the first coordinate point and the second coordinate point is less than or equal to a preset distance, the second coordinate point is deleted. Then, continue to calculate the distance between the first coordinate point and the third coordinate point at the next moment of the second coordinate point, and so on until the distance is greater than the preset distance.

[0120] The following will be introduced in combination with a code example.

[0121]

[0122]

[0123] Through the method provided by the embodiments of the present application, after the backend simulation engine outputs coordinate points, the grids determined by the quantization threshold can be used to process adjacent coordinate points. Multiple coordinate points in the same grid can be downsampled to one coordinate point, thereby reducing the amount of data sent to the front-end browser, reducing the data transmission pressure, reducing the load on the browser, and ensuring the normal rendering and display of the browser page. In addition, the quantization threshold can be dynamically adjusted according to the number of coordinate points to meet the performance requirements of data transmission and the accuracy requirements of page rendering. After the initial downsampling process, when the number of coordinate points is large, the coordinate points can be further downsampled based on the density of the coordinate points to reduce the amount of data that needs to be transmitted.

[0124] Based on the above method embodiments, the embodiments of the present application further provide a device for downsampling processing of data. Refer to Figure 3 As shown, it is a schematic diagram of a device for downsampling processing of data provided by the embodiments of the present application.

[0125] The device 300 includes:

[0126] A determination unit 301, configured to, for the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine a first grid index of the target coordinate point based on a quantization threshold, and the grid corresponding to the first grid index is determined by the quantization threshold;

[0127] An acquisition unit 302, configured to acquire an adjacent coordinate point at the previous moment of the target coordinate point, and acquire a second grid index of the adjacent coordinate point;

[0128] A processing unit 303, configured to discard the target coordinate point when the first grid index is the same as the second grid index.

[0129] In a possible implementation, the device further includes: a storage unit, configured to store the target coordinate point in an array when the first grid index is different from the second grid index, where the array includes the adjacent coordinate points.

[0130] In a possible implementation, the processing unit 303 is further configured to determine a plurality of regions based on a plurality of coordinate points included in the array; for any one of the regions, calculate the density of the coordinate points within the region; when the density is greater than a preset density value, for a first coordinate point within the region, calculate the distance between the first coordinate point and a second coordinate point; when the distance is less than or equal to a preset distance, delete the second coordinate point, where the first coordinate point is any coordinate point and the second coordinate point is a coordinate point adjacent to the first coordinate point.

[0131] In a possible implementation, the coordinate points include time information, and the device further includes: an updating unit, configured to obtain the number of coordinate points within a preset time period; and update the quantization threshold based on the number and the downsampling factor.

[0132] In a possible implementation, the grid corresponding to the first grid index is a square grid, and the side length of the grid is the quantization threshold. The determining unit 301 is specifically configured to calculate a first ratio of the abscissa of the target coordinate point to the quantization threshold, and determine a horizontal grid index based on the first ratio; calculate a second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine a vertical grid index based on the second ratio; and determine the horizontal grid index and the vertical grid index as the first grid index.

[0133] In a possible implementation, the determining unit 301 is specifically configured to round up the first ratio to obtain an integer ratio; calculate the product of the integer ratio and the quantization threshold; when the abscissa of the target coordinate point is less than the product, determine the integer ratio as the horizontal grid index; when the abscissa of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the horizontal grid index.

[0134] In a possible implementation, the determining unit 301 is specifically configured to round up the second ratio to obtain an integer ratio; calculate the product of the integer ratio and the quantization threshold; when the ordinate of the target coordinate point is less than the product, determine the integer ratio as the vertical grid index; when the ordinate of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the vertical grid index.

[0135] In a possible implementation, the determining unit 301 is further configured to, when the target coordinate point is the coordinate point at the initial moment, determine a first grid index of the target coordinate point based on a quantization threshold;

[0136] The storage unit is further configured to store the target coordinate point in the array.

[0137] In a possible implementation, the target coordinate point is output by a backend simulation engine and stored in a cache. The apparatus further includes: a sending unit, configured to send the array to a front-end browser.

[0138] For the beneficial effects of the data downsampling processing apparatus provided in the embodiments of the present application, reference may be made to the above method embodiments, which will not be elaborated herein.

[0139] Based on the above method embodiments and apparatus embodiments, the embodiments of the present application further provide a data downsampling processing device. This will be introduced below with reference to the accompanying drawings.

[0140] See Figure 4 , Figure 4 which is a schematic diagram of a data downsampling processing device provided in the embodiments of the present application.

[0141] The device 400 includes: a memory 401 and a processor 402;

[0142] The memory 401 is configured to store relevant program codes;

[0143] The processor 402 is configured to call the program codes to execute the data downsampling processing method described in the above method embodiments;

[0144] The method includes:

[0145] For the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine a first grid index of the target coordinate point based on a quantization threshold, where the grid corresponding to the first grid index is determined by the quantization threshold;

[0146] Obtain adjacent coordinate points of the target coordinate point at the previous moment, and obtain a second grid index of the adjacent coordinate points;

[0147] When the first grid index is the same as the second grid index, discard the target coordinate point.

[0148] In a possible implementation, the method further includes:

[0149] When the first grid index is different from the second grid index, store the target coordinate point in an array, where the array includes the adjacent coordinate points.

[0150] In a possible implementation, the method further includes:

[0151] Determine a plurality of regions based on a plurality of coordinate points included in the array;

[0152] For any region, calculate the density of the coordinate points within the region;

[0153] When the density is greater than a preset density value, for a first coordinate point within the region, calculate the distance between the first coordinate point and a second coordinate point;

[0154] When the distance is less than or equal to a preset distance, delete the second coordinate point, where the first coordinate point is any coordinate point and the second coordinate point is a coordinate point adjacent to the first coordinate point.

[0155] In a possible implementation, the coordinate points include time information, and the method further includes:

[0156] Obtain the number of coordinate points within a preset time period;

[0157] Update the quantization threshold based on the number and a downsampling factor.

[0158] In a possible implementation, the grid corresponding to the first grid index is a square grid, and the side length of the grid is the quantization threshold. Determining the first grid index of the target coordinate point based on the quantization threshold includes:

[0159] Calculate a first ratio of the abscissa of the target coordinate point to the quantization threshold, and determine a horizontal grid index based on the first ratio;

[0160] Calculate a second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine a vertical grid index based on the second ratio;

[0161] Determine the horizontal grid index and the vertical grid index as the first grid index.

[0162] In a possible implementation, determining the horizontal grid index based on the first ratio includes:

[0163] Round up the first ratio to determine an integer ratio;

[0164] Calculate the product of the integer ratio and the quantization threshold;

[0165] When the abscissa of the target coordinate point is less than the product, determine the integer ratio as the horizontal grid index; when the abscissa of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the horizontal grid index.

[0166] In a possible implementation, determining the longitudinal grid index based on the second ratio includes:

[0167] Round up the second ratio to determine an integer ratio;

[0168] Calculate the product of the integer ratio and the quantization threshold;

[0169] When the ordinate of the target coordinate point is less than the product, determine the integer ratio as the longitudinal grid index; when the ordinate of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the longitudinal grid index.

[0170] In a possible implementation, the method further includes:

[0171] When the target coordinate point is the coordinate point at the initial moment, determine the first grid index of the target coordinate point based on the quantization threshold, and store the target coordinate point in the array.

[0172] In a possible implementation, the target coordinate point is output by a backend simulation engine and stored in a cache, and the method further includes:

[0173] Send the array to the front-end browser.

[0174] In addition, an embodiment of the present application further provides a computer-readable storage medium, which is used to store a computer program, and the computer program is used to execute the data downsampling processing method described in the above method embodiment.

[0175] It should be noted that the technical features in the upper-level means provided in the embodiments of the present application are clear to those skilled in the art, and the problems to be solved by the upper-level means are also clear. How to obtain the means for the corresponding features can be selected by those skilled in the art according to specific implementation requirements. The means provided in the present application should not be regarded as a limitation to the solution or the only implementation means.

[0176] It should be noted that the various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other. In particular, for system or device embodiments, since they are basically similar to method embodiments, they are described relatively simply. For the relevant parts, reference can be made to the corresponding descriptions in the method embodiments. The device embodiments described above are merely illustrative. The units or modules described as separate components may or may not be physically separated. The components shown as units or modules may or may not be physical modules, that is, they may be located in one place or distributed to multiple network units. Some or all of the units or modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative work.

[0177] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of methods, devices, and equipment according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code that contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0178] It should be understood that in the present application, "at least one (item)" means one or more, and "a plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can represent three situations: only A exists, only B exists, and both A and B exist at the same time, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after. "At least one (one) of the following" or its similar expression refers to any combination of these items, including any combination of single items (ones) or plural items (ones). For example, at least one (one) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a, b, and c", where a, b, and c can be single or multiple.

[0179] It should also be noted that in this application, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0180] The steps of the methods or algorithms described in connection with the embodiments disclosed in this application can be implemented directly in hardware, software modules executed by a processor, or a combination of both. The software modules can be placed in random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium well known in the art.

[0181] The foregoing description of the disclosed embodiments enables those skilled in the art to implement or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined in this application can be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed in this application.

Claims

1. A method for downsampling data, characterized in that The method includes: For the obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine the first grid index of the target coordinate point based on a quantization threshold, where the grid corresponding to the first grid index is determined by the quantization threshold; obtain the adjacent coordinate points of the target coordinate point at the previous moment, and obtain the second grid index of the adjacent coordinate points; When the first grid index is the same as the second grid index, discard the target coordinate point; When the first grid index is different from the second grid index, store the target coordinate point in an array, and the array includes the adjacent coordinate points; the target coordinate point is output by a backend simulation engine and stored in a cache; Send the array to a front-end browser; Determine multiple regions based on the multiple coordinate points included in the array; For any region, calculate the density of the coordinate points within the region; When the density is greater than a preset density value, for the first coordinate point within the region, calculate the distance between the first coordinate point and the second coordinate point; When the distance is less than or equal to a preset distance, delete the second coordinate point, where the first coordinate point is any coordinate point and the second coordinate point is the coordinate point adjacent to the first coordinate point; The grid corresponding to the first grid index is a square grid, and the side length of the grid is the quantization threshold. The determining of the first grid index of the target coordinate point based on the quantization threshold includes: Calculate the first ratio of the abscissa of the target coordinate point to the quantization threshold, and determine the horizontal grid index based on the first ratio; Calculate the second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine the vertical grid index based on the second ratio; Determine the horizontal grid index and the vertical grid index as the first grid index; The determining of the horizontal grid index based on the first ratio includes: Round up the first ratio to determine an integer ratio; Calculate the product of the integer ratio and the quantization threshold; When the abscissa of the target coordinate point is less than the product, determine the integer ratio as the horizontal grid index; when the abscissa of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the horizontal grid index.

2. The method according to claim 1, wherein The coordinate point includes time information, and the method further includes: Obtain the number of coordinate points within a preset time period; Update the quantization threshold based on the number and a downsampling factor.

3. The method according to claim 1, wherein The determining of the vertical grid index based on the second ratio includes: Round up the second ratio to determine an integer ratio; Calculate the product of the integer ratio and the quantization threshold; When the ordinate of the target coordinate point is less than the product, determine the integer ratio as the vertical grid index; when the ordinate of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the vertical grid index.

4. The method according to claim 1, wherein The method further includes: When the target coordinate point is a coordinate point at the initial moment, determine the first grid index of the target coordinate point based on the quantization threshold, and store the target coordinate point in the array.

5. A device for downsampling processing of data, characterized in that, The device includes: a determination unit configured to, for an obtained target coordinate point, when the target coordinate point is a coordinate point at a non-initial moment, determine a first grid index of the target coordinate point based on a quantization threshold, and the grid corresponding to the first grid index is determined by the quantization threshold; an acquisition unit configured to acquire adjacent coordinate points of the target coordinate point at the previous moment and acquire a second grid index of the adjacent coordinate points; a processing unit configured to discard the target coordinate point when the first grid index is the same as the second grid index; The device further includes: a storage unit configured to, when the first grid index is different from the second grid index, store the target coordinate point in an array, and the array includes the adjacent coordinate points; The target coordinate point is output by a backend simulation engine and stored in a cache. The device further includes: a sending unit configured to send the array to a front-end browser; The processing unit is further configured to determine a plurality of regions based on a plurality of coordinate points included in the array; for any one of the regions, calculate the density of the coordinate points within the region; when the density is greater than a preset density value, for a first coordinate point within the region, calculate the distance between the first coordinate point and a second coordinate point; when the distance is less than or equal to a preset distance, delete the second coordinate point, where the first coordinate point is any coordinate point and the second coordinate point is an adjacent coordinate point of the first coordinate point; The grid corresponding to the first grid index is a square grid, and the side length of the grid is the quantization threshold. The determination unit is specifically configured to calculate a first ratio of the abscissa of the target coordinate point to the quantization threshold, and determine a horizontal grid index based on the first ratio; calculate a second ratio of the ordinate of the target coordinate point to the quantization threshold, and determine a vertical grid index based on the second ratio; determine the horizontal grid index and the vertical grid index as the first grid index; The determination unit is specifically configured to round up the first ratio to determine an integer ratio; calculate the product of the integer ratio and the quantization threshold; when the abscissa of the target coordinate point is less than the product, determine the integer ratio as the horizontal grid index; when the abscissa of the target coordinate point is greater than or equal to the product, increment the integer ratio by one to determine the horizontal grid index.

Citation Information

Patent Citations

  • Method, device and terminal equipment of track point optimization of driving track and medium

    CN108681545A

  • Curve drawing method, device and equipment and readable storage medium

    CN116863030A