Heat map generation method and apparatus, electronic device, and storage medium

By creating elevation texture sources and color texture sources, the data sources for heatmap color sampling and elevation sampling are decoupled, enabling fast and stable switching between two-dimensional and three-dimensional heatmaps. This solves the problem of high computational load during the switching process in existing technologies and improves the display efficiency and flexibility of heatmaps.

CN115643391BActive Publication Date: 2026-07-21GUANGZHOU YAXIN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU YAXIN TECH CO LTD
Filing Date
2022-10-14
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

In existing technologies, the switching process between two-dimensional and three-dimensional heat maps involves large data throughput and computational loads for GPUs and CPUs, resulting in difficulties and low efficiency in display switching.

Method used

By creating elevation and color texture sources, the data sources for heatmap color sampling and elevation sampling are decoupled, allowing 2D and 3D heatmaps to share the same color and elevation texture sources. A unified calculation method is used in vertex and fragment shaders to achieve fast dynamic switching.

Benefits of technology

It enables fast and stable switching between two-dimensional and three-dimensional heat maps, reduces data transfer and computation during display switching, and improves the flexibility and visualization capabilities of heat map display.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115643391B_ABST
    Figure CN115643391B_ABST
Patent Text Reader

Abstract

The present disclosure provides a heat map generation method and device, electronic equipment and computer readable storage medium, relating to the field of computer image processing. The method comprises: obtaining a display type of a target heat map corresponding to a current frame, the display type comprising a three-dimensional heat map and a two-dimensional heat map; calculating three-dimensional space coordinate values and gray values of vertices of the heat map according to the display type from a vertex shader; a fragment shader obtains color values of the vertices from a texture source according to the three-dimensional space coordinate values and the gray values, and performs rasterization to obtain a rendered target heat map; wherein the texture source comprises a color texture source for representing a color space of the heat map and an elevation texture source for representing a heat value distribution obtained from a heat map data source, and the two-dimensional heat map and the three-dimensional heat map use the same color texture source and the elevation texture source. The present disclosure embodiment realizes fast switching of two-dimensional heat map and three-dimensional heat map display.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer image processing technology, and more specifically, to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for generating heatmaps. Background Technology

[0002] In the field of Geographic Information Systems (GIS) applications, heatmaps, as a method of geographic data visualization, generally use color depth to visually represent the spatial distribution and intensity changes of geographic data within a region. Darker colors in a heatmap typically represent higher data intensity or density, while lighter colors represent the opposite. For example, a visitor heatmap of a scenic area uses color depth to visually display visitor density at different geographical locations within the scenic area, thus providing support for visitor safety management. In recent years, with the construction and widespread application of the BeiDou Navigation Satellite System, the demand for geographic data visualization has increased across various industries. Heatmaps, as an effective method for visualizing geographic data, can intuitively display and analyze data information, and their applications are very extensive.

[0003] Traditional heatmaps are two-dimensional, often using color differences to represent changes in data intensity across geographical locations. In recent years, with the development of 3D technology, several methods for generating 3D heatmaps have been proposed, increasing the height and surface display of the heatmap, enriching its perceptual dimensions and display effects. Current 3D heatmap generation methods typically construct independent 3D texture maps, obtain the geospatial coordinates of pixels through Gaussian transforms and inverse graph transformations, and generate the 3D heatmap based on world spatial coordinates and heat map height. Both two-dimensional and 3D heatmaps have their advantages in geographic data analysis and visualization. Two-dimensional heatmaps are more accurate in displaying the grid distribution of data; 3D heatmaps offer richer and more three-dimensional visualization.

[0004] Therefore, in some application scenarios, it is necessary to be able to switch between displaying 2D and 3D heatmaps for the same data source. However, in related technologies, 2D and 3D heatmaps are drawn separately, and switching between them involves changing from one rendering mode to another. When the amount of geographic information data is large, the data throughput and computational load for GPUs and CPUs are very high. No publicly available literature provides a feasible solution for heatmap display. Figure Two A method for stable and rapid switching between 3D modes. Summary of the Invention

[0005] The embodiments disclosed herein aim to address at least one aspect of the aforementioned problems to a certain extent. Therefore, the embodiments disclosed herein provide a series of technical solutions for heatmap generation.

[0006] According to a first aspect of the present disclosure, a method for generating a heat map is provided, the heat map generation method comprising:

[0007] Obtain the display type of the target heatmap corresponding to the current frame. The display type includes 3D heatmap and 2D heatmap.

[0008] Based on the display type, the corresponding vertex calculation method is selected from the vertex shader to perform vertex calculation of the heatmap, and the three-dimensional spatial coordinates and grayscale values ​​of each vertex are calculated.

[0009] The fragment shader controls the color values ​​of the vertices of the target heatmap from the texture source based on the three-dimensional spatial coordinates and grayscale values ​​of each vertex, and performs rasterization to obtain the rendered target heatmap.

[0010] The texture source includes a color texture source for characterizing the color space of the heatmap and an elevation texture source for characterizing the distribution of heat values, obtained from the heatmap data source. The two-dimensional heatmap and the three-dimensional heatmap use the same color texture source and elevation texture source.

[0011] According to a second aspect of the present disclosure, an electronic device is provided, the electronic device comprising:

[0012] Memory;

[0013] Processor; and

[0014] A computer program stored in a memory is characterized by:

[0015] When the processor executes a computer program, it implements a heatmap generation method according to the first aspect of this disclosure.

[0016] According to a third aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the heatmap generation method according to the first aspect of the present disclosure.

[0017] The beneficial effects of the technical solutions provided in this disclosure are:

[0018] By creating elevation and color texture sources, the data sources for heatmap color sampling and elevation sampling are decoupled, allowing 2D and 3D heatmaps to use a common color value method. This enables fast dynamic switching between 2D and 3D heatmaps without changing the fragment shader and texture source, while maintaining the stability of the heatmap display. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments of this disclosure will be briefly introduced below.

[0020] Figure 1A schematic diagram of the architecture for image display and rendering using GPUs in related technologies;

[0021] Figure 2 A schematic flowchart of a heatmap generation method provided in one embodiment of this disclosure;

[0022] Figure 3 A schematic flowchart of a heatmap generation method provided in another embodiment of this disclosure;

[0023] Figure 4 A schematic diagram illustrating the display effect of a two-dimensional heat map provided in the embodiments of this disclosure;

[0024] Figure 5 A schematic diagram illustrating the display effect of a three-dimensional heat map provided for an embodiment of this disclosure;

[0025] Figure 6 A schematic diagram of the structure of an electronic device generated from a heat map, provided for embodiments of this disclosure. Detailed Implementation

[0026] The embodiments of this disclosure are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this disclosure, and do not constitute a limitation on the technical solutions of the embodiments of this disclosure.

[0027] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this disclosure mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element are connected through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”

[0028] To make the objectives, technical solutions, and advantages of this disclosure clearer, the embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.

[0029] For ease of explanation, a brief explanation of some terms used in this disclosure is provided below.

[0030] Central Processing Unit (CPU): The core of a computer's operation and control; it is the final execution unit for information processing and program execution.

[0031] Graphics Processing Unit (GPU): Also known as display core, visual processor, display chip, or graphics chip, it is a microprocessor specifically designed to perform graphics calculations on personal computers, workstations, game consoles, and some mobile terminals.

[0032] Red, Green, Blue (RGB) color model: an industry color standard that uses variations in the three color channels (red R, green G, and blue B) and their superposition to obtain a wide variety of colors. RGB represents the colors of the red, green, and blue channels. This standard covers almost all colors that can be perceived by human vision and is one of the most widely used color systems.

[0033] Figure 1 This diagram illustrates the architecture of GPU-based image display and rendering in related technologies. The CPU and GPU are connected via a bus. During image rendering, the GPU renders the image to be displayed frame by frame, storing the rendered frames in a frame buffer, and the video controller controls the display for viewing. However, in the field of heatmaps, 2D and 3D heatmaps are currently drawn using different methods, and their rendering processes are completely different. This means that when switching between 2D and 3D heatmaps, the GPU needs to reconfigure the shaders, reset all parameters, and retransmit them from the CPU, leading to difficulties in switching displays and affecting the display speed and quality.

[0034] Based on the discovery of the root cause of the above-mentioned technical problems, the inventors of this disclosure propose a heatmap generation method with the main inventive concept of reducing the retransmission and calculation of GPU rendering data during the switching between two-dimensional and three-dimensional heatmaps.

[0035] By generating thermal color and elevation texture sources based on GIS thermal data sources, and creating vertex calculation methods for 2D and 3D thermal maps in the vertex shader of the graphics, and a common color rendering method in the slice shader, rapid and stable switching between 2D and 3D modes can be achieved during thermal map display. This eliminates the need to completely regenerate new thermal map coordinate data or change the data source and texture source during thermal map display. Figure Two The dynamic switching of 3D modes greatly improves the flexibility of heatmap display and provides richer geographic data visualization capabilities.

[0036] The following description of several exemplary embodiments illustrates the technical solutions of this disclosure and the technical effects produced by these solutions. It should be noted that the following embodiments can be referenced, learned from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0037] This disclosure provides a method for generating a heatmap, such as... Figure 2 As shown, the method includes steps S110 to S130.

[0038] In S110, the display type of the target heatmap corresponding to the current frame is obtained. The display type includes 3D heatmap and 2D heatmap. Depending on the display type, different vertex calculation methods stored in the vertex shader can be selected for vertex calculation. At the same time, for the fragment shader, a relatively consistent algorithm is used to reduce data throughput and computation during the switching process between 2D and 3D displays.

[0039] In S120, the corresponding vertex calculation method is selected from the vertex shader according to the display type to perform vertex calculation of the heatmap, and the three-dimensional spatial coordinate value and gray value of each vertex are calculated.

[0040] In S130, the fragment shader controls the color values ​​of the vertices of the target heatmap from the texture source based on the three-dimensional spatial coordinates and grayscale values ​​of each vertex, and performs rasterization to obtain the rendered target heatmap.

[0041] The texture source includes a color texture source for characterizing the color space of the heatmap and an elevation texture source for characterizing the distribution of heat values, obtained from the heatmap data source. The two-dimensional heatmap and the three-dimensional heatmap use the same color texture source and elevation texture source.

[0042] Color texture sources can include texture images based on the RGB color mode created using a Canvas. For example, they can be images composed of color levels arranged according to a certain preset pattern based on the color depth settings of the display, which can build textures in a relatively simple form and facilitate the use of fragment shaders.

[0043] The elevation texture source is used to represent the thermal value corresponding to each point. It needs to meet the design constraint that the total thermal value per unit area corresponding to each data point in the data source should be as consistent as possible after coordinate transformation, and should be designed in a normalized form to facilitate computation. For example, grayscale values ​​can be used to represent the magnitude trend of the corresponding thermal value. In some embodiments, the elevation texture image can be created as follows: mapping each source data point of the heatmap data source to the corresponding image data point of the elevation texture image, where the source data point includes coordinate values ​​and thermal values; normalizing the coordinate values ​​of the source data points and mapping them to the coordinates of the image data points; normalizing the thermal values ​​of the source data points and mapping them to the grayscale values ​​of the image data points between 0 and 1; and performing data fitting based on the image data points to obtain the elevation texture image. The data fitting method can be implemented using image processing and mathematical interpolation methods of relevant technologies. The most suitable approach is selected based on the specific data source form. For example, data fitting of the image data points can be performed based on a linear trend surface model. Gradual continuous interpolation within the surrounding neighborhood of each source data point can also be used to fit the elevation texture image.

[0044] The constructed elevation texture image provides the grayscale value for each pixel within the corresponding heatmap display area, representing the relative magnitude of the heatmap value. This grayscale value can be read and used during the rendering process. Furthermore, for rendering 2D and 3D heatmaps, there's no need to update the elevation texture image data; instead, it can be directly accessed and used by different rendering algorithms (i.e., rendering 2D and 3D heatmaps). This decouples color texture and elevation texture, enabling texture data reuse between 2D and 3D heatmaps and reducing the data transfer and computational load required for display switching.

[0045] For two-dimensional heatmaps, vertex calculation is relatively simple: obtain the normalized coordinates of each vertex position, calculate the gray value of each vertex based on the normalized coordinates, store the gray value of each vertex in a variable used for data transfer to the fragment shader, and calculate the three-dimensional spatial coordinates of each vertex based on the latitude and longitude coordinates of each vertex position through coordinate transformation.

[0046] In the operation of calculating the grayscale value of each vertex based on normalized coordinates, the method for calculating the grayscale value of each vertex is similar to the method for calculating the grayscale value of the corresponding normalized coordinates in the elevation texture image of the elevation texture source. In practice, the two can be calculated independently, or the grayscale values ​​of each pixel in the vertex's neighborhood can be directly obtained from the elevation texture image for calculation. Depending on the specific data processing scenario, the method with lower computational load or faster processing speed can be selected to provide greater flexibility.

[0047] For three-dimensional heat maps, since the changes in heat values ​​need to be displayed in the form of elevation in three-dimensional space, and the consistency between the total heat value per unit ground area and the data source should be maintained as much as possible, further corrections and adjustments need to be made based on the three-dimensional spatial coordinates obtained from coordinate transformation.

[0048] Specifically, the three-dimensional spatial coordinates of each vertex can be calculated first using a method similar to that of a two-dimensional heatmap: obtain the normalized coordinates of each vertex position, and calculate the corresponding vertex grayscale value based on the normalized coordinates; store the grayscale values ​​of each vertex in variables used for data transfer to the fragment shader; and calculate the three-dimensional spatial coordinates of each vertex by performing coordinate transformation based on the latitude and longitude coordinates of each vertex position. Alternatively, variables can be set in the shader to store the three-dimensional coordinates of each vertex, thereby further reducing the amount of calculation during display switching.

[0049] Next, the spatial direction vector of each vertex is calculated based on its three-dimensional spatial coordinates, and the thermal correction offset is calculated based on the spatial direction vector and grayscale value of each vertex. The corrected three-dimensional spatial coordinates of each vertex are then calculated based on the thermal correction offset and its three-dimensional spatial coordinates. This ensures that the three-dimensional shape of the thermal map more accurately reflects the distribution trend of thermal values.

[0050] Next, the fragment shader is controlled to obtain the color values ​​of the vertices of the target heatmap from the texture source based on the three-dimensional spatial coordinates and grayscale values ​​of each vertex. This may include obtaining the corresponding color value in the color texture source based on the grayscale value of each vertex. Then, rasterization is performed to obtain the rendered target heatmap. The rasterization and the presentation of the final rendering effect can be implemented using various three-dimensional rendering methods in related technologies, and this disclosure does not impose any restrictions on this. For two-dimensional and three-dimensional heatmaps, the implementation of the fragment shader is basically similar. Within the framework of the heatmap generation and rendering method provided in this disclosure, the two-dimensional heatmap can be regarded as a special instance of the three-dimensional heatmap. Both use the same fragment shader algorithm and texture source, so that when switching displays, there is no need to reload GPU data and reset the entire shader, which greatly improves the image rendering efficiency during the switching process.

[0051] According to the heatmap generation method disclosed herein, by creating an elevation texture source and a color texture source, the data sources for heatmap color sampling and elevation sampling are decoupled, allowing two-dimensional and three-dimensional heatmaps to use a common color value method. Thus, when switching between two-dimensional and three-dimensional heatmaps, the fragment shader and texture source do not need to be changed, achieving fast dynamic switching while maintaining the stability of the heatmap display.

[0052] The technical solution of this disclosure will be further described below with reference to specific implementation scenarios. In this document, WebGL is used as an example to implement the method of this disclosure embodiment in conjunction with a Canvas. Obviously, other image processing and rendering related programming languages ​​can also be applied. It should be noted that, under the guidance of the inventive concept of this disclosure, any program written in any computer language or method implemented in electronic product hardware will fall within the protection scope of this disclosure.

[0053] See Figure 3 , Figure 3 This is a schematic flowchart illustrating a heatmap generation method according to another embodiment of the present disclosure. It is used to draw a heatmap on a map corresponding to a heatmap data source based on geographic information system (GIS). Obviously, the heatmap can also be drawn independently of the map. This disclosure does not limit this.

[0054] Before rendering a heatmap, the GIS heatmap data source usually needs to be preliminarily processed according to the display requirements. This includes mapping the geographic data source in the heatmap data source to the display area, normalizing the coordinates of the heatmap data values, and so on.

[0055] In one embodiment of preliminary data processing, the location range of the geographic data source can be calculated first, which can also be referred to as calculating its rectangular boundaries.

[0056] Obtain the heatmap data source, which can be a collection of geographic data points. For example, each data point includes geographic coordinates and a heat value (long, lat, value), where long is the latitude value, lat is the longitude value, and value is the heat value. Optionally, the CGCS2000 geodetic coordinate system is recommended for geographic coordinates. For example, a heatmap data point (113.4575 E, 38.4354 E, 300) means that the geographical location of this data point is 113.4575 degrees longitude, 38.4354 degrees latitude, and has a heat value of 300.

[0057] Iterate through the longitude and latitude values ​​of each data point, obtain the maximum and minimum longitude and latitude values ​​in the data source as the geographical boundaries, and calculate the aspect ratio r of the geographical boundaries.

[0058] r=(long_max-long_min) / (lat_max-lat_min).

[0059] In the formula, long_max is the maximum longitude value, long_min is the minimum longitude value, lat_max is the maximum latitude value, and lat_min is the minimum latitude value.

[0060] Next, a transparent rectangle is drawn based on the rectangular boundaries of the geographic data source to serve as the basis for displaying the 2D or 3D heatmap. For example, a transparent rectangular shape can be drawn in the map using WebGL. Various methods can be used to create a transparent rectangular shape using WebGL, which will not be elaborated here. For example, the main steps may include: passing coordinates to the vertex shader to construct the rectangular shape, and passing vec4(0.0,0.0,0.0,0.0) to the fragment shader to render the transparent color. The coordinates of the top-left vertex of the transparent rectangle are (long_min, lat_max), and the coordinates of the bottom-right vertex are (long_max, lat_min). The rectangle covers the geographic extent of all data in the heatmap data source.

[0061] The heatmap texture source is constructed using a Canvas. The specific construction methods for the color texture source and the elevation texture source are explained below.

[0062] A color texture source based on the RGB color mode can be created using a Canvas. For example, with 256 colors, a 256*1 pixel striped Canvas can be created using the Canvas2dRenderer method. Color interpolation is then performed using the createLinearGradient method to interpolate the red, green, and blue color values ​​of the RGB values.

[0063] One approach is simple linear interpolation, with the function y = a0 + a1 * x, where x is the cell number and y is the color value. For example, the first cell might have a light color value of rgb(0,0,255), and the 256th cell a dark color value of rgb(255,0,0). In this method, the red interpolation is y = 255 - x, and the blue interpolation is y = x - 1. This achieves one color per pixel along the horizontal axis, from light to dark. This Canvas texture source serves as a shared texture data source for both 2D and 3D heatmaps.

[0064] The construction of the elevation texture source can include the correspondence between the heatmap data source and the canvas coordinate pixels, and the calculation of grayscale values. It can include the following steps 1 to 3.

[0065] Step 1: Use Canvas2dRenderer to draw a matrix image. Taking a canvas length of 256 pixels as an example, the canvas size is 256*r pixels, where r is the aspect ratio of the geographical boundaries calculated above. This achieves accurate matching of the aspect ratio of the rectangular shape with the elevation texture source location.

[0066] Step 2: Convert each point of the heatmap data source into a grayscale interpolation data source point (x, y, grey), where x and y represent the horizontal and vertical coordinates of the Canvas, and grey represents the grayscale value. The calculation formulas are as follows:

[0067] x=(long–long_min) / (long_max–long_min)*256;

[0068] y=(lat–lat_min) / (lat_max–lat_min)*256*R;

[0069] gray=(index-index_min) / (index_max–index_min).

[0070] This generates a table of grayscale values ​​for the heatmap data source, see Table 1.

[0071] Table 1. Grayscale values ​​of heatmap data sources

[0072]

[0073] Step 3: Based on a limited source of grayscale data points, a spatial interpolation method is used to generate a global grayscale texture calculation method. One approach is the trend surface model method, which first constructs a linear trend surface calculation equation:

[0074] grey=b0+b1*x+b2*y

[0075] In the formula, the attribute `grey` is the grayscale value at coordinates (x, y), where x is the horizontal axis coordinate of the canvas and y is the vertical axis coordinate. The normalized grayscale value `grey` has a minimum value of 0.0 and a maximum value of 1.0. The coefficients b0, b1, and b2 are calculated by fitting data from the grayscale value data source point set (Table 1). One fitting method is the normal equation pattern method, and the equation is constructed as follows:

[0076] ∑z=b0*n+b1*∑x+b2*∑y

[0077] ∑xz=b0*∑x+b1*∑x 2 +b2*∑xy

[0078] ∑yz=b0*∑y+b1*∑xy+b2*∑y 2

[0079] Rewrite the equation in matrix form:

[0080]

[0081]

[0082] The values ​​of parameters b0, b1, and b2 are calculated from this, and the grayscale value of any coordinate point in the Canvas elevation texture source can be calculated from this value.

[0083] The rendering methods for 2D and 3D heatmaps can store the calculation methods in the shaders, store the vertex algorithms for 2D and 3D heatmaps in the WebGL vertex shader method library respectively, and store the color value algorithm common to both 2D and 3D heatmaps in the WebGL source shader method library.

[0084] Next, the vertex calculation methods for two-dimensional and three-dimensional heatmaps will be explained in detail. The vertex calculation method for two-dimensional heatmaps can be implemented through the following steps 1-3.

[0085] Step 1: Calculate the gray value (grey_value) point by point according to the linear trend surface calculation equation. The gray value represents the intensity of heat at that point.

[0086] Taking the calculation of a point in the aforementioned constructed rectangular planar figure as an example, firstly, calculate the normalized coordinates (s, t) of the point, where s is the normalized coordinate value of the point on the x-axis of the rectangle, and t is the normalized coordinate value on the y-axis of the rectangle:

[0087] s=(position.x–long_min) / (long_max–long_min);

[0088] t=(position.y–lat_min) / (lat_max–lat_min).

[0089] In the formula, position is the coordinate (x, y) of the point in the rectangle, where x is the longitude value and y is the latitude value.

[0090] Secondly, the grayscale value of the point is calculated using the linear trend surface calculation equation grey = b0 + b1*s + b2*t obtained earlier. Alternatively, after the elevation texture map is constructed, the grayscale value of the point can be obtained by finding the grayscale values ​​of pixels within the corresponding range in the elevation texture map. The method of obtaining the grayscale value can be chosen based on the computational complexity involved in recalculating and searching the elevation texture map.

[0091] Step 2: Create a new variable named grey_value, which will be used to send the grayscale values ​​per vertex to the source shader.

[0092] Step 3: Calculate the vertex coordinates of the heatmap graph vertex by vertex, converting the latitude and longitude coordinate system to the coordinates vec3_position in the spatial rectangular coordinate system. The expression vec3_position indicates that position is a 3-dimensional vector, which corresponds to the definition of vec3 position in the program. Similar expressions in the following text have similar meanings and will not be explained one by one.

[0093] vec3_position=vec3(x_world,y_world,z_world)

[0094] In the formula, x_world, y_world, and z_world represent the x, y, and z axis coordinates of the transparent rectangular graphic in the geographic coordinate system, respectively. The transparent rectangle is a two-dimensional planar graphic, and based on this, the coordinate point positon of the two-dimensional planar heat map is formed.

[0095] The method for calculating vertices in a 3D heatmap is based on the algorithm for vertices in a 2D heatmap, and further calculates the vertex offset. This may include the following steps 1 to 4.

[0096] Step 1 is the same as step 1 in the two-dimensional heatmap vertex calculation method.

[0097] Step 2 is the same as step 2 in the two-dimensional heatmap vertex calculation method.

[0098] Step 3: Calculate the vertex coordinates of the heatmap graph vertex by vertex. First, calculate the normalized spatial direction vector of the vertex coordinates. A normalized space vector can be represented as:

[0099] vec3_upDir=normalize(x_world,y_world,z_world),

[0100] Calculate the thermally corrected coordinates ΔdisPos of the vertex based on the geographic direction vector and grayscale value.

[0101] vec3_ΔdisPos=upDir*grey_value*heightRange.

[0102] In the formula, upDir is the unit direction vector of the vertex position, grey_value is the sampled thermal grayscale value, and heightRange is the maximum elevation increase value. heightRange can be selected by the user according to specific needs.

[0103] Step 4: Calculate the vertex coordinates positon of the heatmap graphic. Based on the coordinate correction vector, calculate the vertex coordinates for each vertex: positon = vec3(x_world,y_world,z_world) + ΔdisPos, where x_world, y_world, and z_world represent the x, y, and z axis coordinates of the transparent rectangular graphic in the geographic coordinate system, and disPos is the heatmap correction coordinate value of the vertex.

[0104] By correcting the coordinate values ​​of a rectangular graphic point by point using thermal values, the two-dimensional planar transparent rectangle is stretched vertex by vertex, and a three-dimensional curved surface thermal map coordinate point is formed based on this, and the corrected vertex coordinate value positon is returned.

[0105] In the fragment shader, the method for determining the color value of a heatmap can include the following steps 1 and 2.

[0106] Step 1: Create a new variable named grey_value in the source shader. This variable grey_value receives the grayscale value of each vertex from the vertex shader. The value ranges from 0 to 1, representing the strength of the heat value at that vertex.

[0107] Step 2: Use the `texture2D(color_texture, vec2(s', t'))` method to sample the color RGB value from the Canvas color texture source. In the formula, `color_texture` is the color texture source, `s'` is the grayscale value of that vertex `grey_value`, and `t'` is 0.5. This method samples the color RGB value at pixel (256 * gray_value, 0.5) of the Canvas color texture source. If the grayscale value is small, a lighter color value is sampled; if the grayscale value is large, a darker color value is sampled. After the method completes the calculation, it returns the sampled color value.

[0108] After completing the above preparations, heatmaps can be generated in real time. The following explains how to create a new heatmap. A new heatmap can be either a 3D or 2D heatmap. To differentiate them during rendering, a heatmap mode control variable can be set to select whether to draw a 2D or 3D heatmap. For example, the mode control variable can be set to 2D or 3D, and this variable can also control the selection of the heatmap vertex generation method in the graphics shader.

[0109] Case 1: When the heat map is initialized and the mode control variable is "2D": In the vertex shader of WebGL, the vertex position uses the two-dimensional heat map vertex calculation method in the method library to obtain the two-dimensional plane graphic coordinates and assign them to the shader gl_Positon; in the fragment shader, the heat map graphic color value-taking method is used to obtain the per-vertex rgb color values and assign them to the gl_FragColor of the shader; primitive assembly is performed in the vertex shader, and rasterization is performed according to the per-vertex color values in the fragment shader to generate a two-dimensional heat map.

[0110] Case 2: When the heat map is initialized and the mode control variable is "3D": In the vertex shader of WebGL, the vertex position uses the three-dimensional heat map vertex calculation method in the method library to obtain the three-dimensional surface graphic coordinates and assign them to the shader gl_Positon; in the fragment shader, the heat map graphic color value-taking method is used to obtain the per-vertex rgb color values and assign them to the gl_FragColor of the shader; primitive assembly is performed in the vertex shader, and rasterization is performed according to the per-vertex color values in the fragment shader to generate a three-dimensional heat map.

[0111] After initial generation, during subsequent display, the display mode of the heat map can be switched. For example, when the user's display requirements for the heat map change, the value of the mode variable can be changed, and in the next frame drawing of WebGL, the vertex calculation method in the vertex shader is changed, while the calculation method of the fragment shader does not need to be changed, and the heat map mode is switched.

[0112] Case 1: Switch from a two-dimensional heat map to a three-dimensional heat map. The value of the mode variable is switched to "3D". In the next frame drawing of the WebGL shader, the calculation method of the vertex position gl_Position uses the three-dimensional heat map vertex calculation method in the method library, and the calculation of the fragment shader does not need to be changed. A three-dimensional heat map is rendered in the next frame of WebGL.

[0113] Case 2: Switch from a three-dimensional heat map to a two-dimensional heat map. The value of the mode variable is switched to "2D". In the next frame drawing of the WebGL shader, the calculation method of the vertex position gl_Position uses the two-dimensional heat map vertex calculation method in the method library, and the calculation of the fragment shader does not need to be changed. A two-dimensional heat map is rendered in the next frame of WebGL.

[0114] Ref. Figure 4 and Figure 5 , Figure 4 is a schematic diagram of the display effect of the two-dimensional heat map provided by the embodiment of the present disclosure, Figure 5 is a schematic diagram of the display effect of the three-dimensional heat map provided by the embodiment of the present disclosure. It can be seen that both the two-dimensional heat map and the three-dimensional heat map drawn according to the method of the present disclosure have good display effects.

[0115] As can be seen from the above description, during the creation and switching of heatmaps, the method of creating elevation and color texture sources using a Canvas decouples the data sources for heatmap color sampling and elevation sampling, simultaneously satisfying the data source conditions for generating two-dimensional and three-dimensional heatmaps. Furthermore, this disclosure proposes a novel method for calculating vertex values ​​in two-dimensional and three-dimensional heatmaps, stored in the WebGL vertex shader method library; and a novel method for obtaining heatmap color values ​​that can be shared between two-dimensional and three-dimensional heatmaps, stored in the WebGL fragment shader method library, which can be called during rendering based on the heatmap display mode. For vertex shaders, the vertex calculation methods for two-dimensional and three-dimensional heatmaps can share some data calculation results; for fragment shaders, two-dimensional and three-dimensional heatmaps can share common color value algorithms and texture sources, without needing to refresh and transfer all data again during switching. This allows for the preservation of texture data, fragment shader algorithms and some variables, and some variables from the vertex shader for displaying heatmaps of different dimensions after switching. By changing the mode variable value, the calculation method of the vertex shader is changed in the next frame of WebGL rendering, while the source shader and texture data source do not need to be changed. This achieves dynamic switching between 2D and 3D heatmaps while maintaining the stability of the heatmap display.

[0116] This disclosure provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a heatmap generation method. Compared with related technologies, this method can achieve the following: by creating an elevation texture source and a color texture source, the data sources for heatmap color sampling and elevation sampling are decoupled, allowing two-dimensional and three-dimensional heatmaps to use a common color value method. Thus, when switching between two-dimensional and three-dimensional heatmaps, the fragment shader and texture source do not need to be changed, achieving fast dynamic switching while maintaining the stability of the heatmap display.

[0117] In one alternative embodiment, an electronic device is provided, such as Figure 6 As shown in the figure, the electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this disclosure.

[0118] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with this disclosure. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0119] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the figure, but this does not indicate that there is only one bus or one type of bus.

[0120] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.

[0121] The memory 4003 is used to store computer programs that execute embodiments of the present disclosure, and is controlled by the processor 4001 to execute them. The processor 4001 is used to execute the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0122] Electronic devices include, but are not limited to: computers, smartphones, servers, etc.

[0123] This disclosure provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0124] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0125] The terms “first,” “second,” “third,” “fourth,” “1,” “2,” etc. (if present) in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in a sequence other than that shown in the figures or text.

[0126] It should be understood that although arrows indicate various operation steps in the flowcharts of the embodiments of this disclosure, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of the embodiments of this disclosure, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured as required, and the embodiments of this disclosure do not limit this.

[0127] The above description is only an optional implementation method for some implementation scenarios of this disclosure. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this disclosure, without departing from the technical concept of this disclosure, also fall within the protection scope of the embodiments of this disclosure.

Claims

1. A method for generating a heatmap, characterized in that, include: Obtain the display type of the target heatmap corresponding to the current frame, wherein the display type includes a three-dimensional heatmap and a two-dimensional heatmap; According to the display type, a corresponding vertex calculation method is selected from the vertex shader to perform vertex calculations for 2D and 3D heatmaps. The vertex calculation includes calculating the 3D spatial coordinates and grayscale values ​​of each vertex. Specifically, the vertex calculation for the 2D heatmap includes: obtaining the normalized coordinates of each vertex position, and finding the grayscale values ​​of pixels within the corresponding range of each vertex in the elevation texture image based on the normalized coordinates, using these as the grayscale values ​​of each vertex; storing the grayscale values ​​of each vertex in variables used for data transfer to the fragment shader; and calculating the 3D spatial coordinates of each vertex based on the latitude and longitude coordinates of its position. The vertex calculation for the 3D heatmap... The process includes: obtaining the normalized coordinates of each vertex position, and finding the grayscale values ​​of pixels within the corresponding range of each vertex in the elevation texture image based on the normalized coordinates, using these as the grayscale values ​​of each vertex; storing the grayscale values ​​of each vertex in variables used for data transmission to the fragment shader; calculating the three-dimensional spatial coordinates of each vertex by performing coordinate transformation based on the latitude and longitude coordinates of each vertex position; calculating the spatial direction vector of each vertex based on its three-dimensional spatial coordinates, and calculating a thermal correction offset based on the spatial direction vector of each vertex and the vertex grayscale value; and calculating the corrected three-dimensional spatial coordinate values ​​of each vertex based on the thermal correction offset and the three-dimensional spatial coordinates. The fragment shader obtains the corresponding color value in the color texture source based on the grayscale value of each vertex, and performs rasterization to obtain the rendered target heatmap. The color texture source is used to characterize the color space of the heatmap, and the two-dimensional heatmap and the three-dimensional heatmap use the same color texture source and elevation texture source. The elevation texture source includes an elevation texture image, which provides the grayscale value corresponding to each pixel within the display area of ​​the target heatmap, and the grayscale value characterizes the relative magnitude of the heatmap value.

2. The heatmap generation method according to claim 1, characterized in that, The color texture source includes texture images based on the RGB color mode created using a Canvas canvas.

3. The heatmap generation method according to claim 1, characterized in that, The elevation texture image is created in the following manner: Each source data point of the heatmap data source is mapped to the corresponding image data point of the elevation texture image, wherein the source data point includes coordinate values ​​and thermal values; The coordinate values ​​of the source data points are normalized and mapped to the coordinates of the image data points; The thermal values ​​of the source data points are normalized and mapped to the gray values ​​of the image data points between 0 and 1. The elevation texture image is obtained by fitting data based on the image data points.

4. The heatmap generation method according to claim 3, characterized in that, The step of performing data fitting based on the image data points to obtain the elevation texture image includes: performing data fitting on the image data points according to a linear trend surface model.

5. An electronic device, comprising: Memory; processor; as well as A computer program stored in a memory is characterized by: When the processor executes the computer program, it implements the heatmap generation method according to any one of claims 1-4.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the heatmap generation method according to any one of claims 1-4.