A real-time rendering method and system for terrain shading images of a custom area

By converting digital elevation model data into Terrain-RGB raster data and publishing it as a map service, combining the ribbon configuration of custom areas and a three-dimensional rendering engine, the problem of lack of real-time and dynamic terrain rendering in the prior art is solved. It realizes the terrain rendering and coloring effects of custom areas, enhancing the expression ability of electronic maps.

CN119006683BActive Publication Date: 2025-02-18SUZHOU IND PARK SURVEYING MAPPING & GEOINFORMATION CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411485282.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-02-18
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The existing electronic map terrain rendering technology lacks real-time and dynamic nature, and cannot adapt to changes in elevation in different geographical regions, and the fixed color scheme cannot reflect the characteristics of terrain fluctuations.

Method used

By obtaining digital elevation model raster data, converting it into Terrain-RGB raster data, publishing it as WMS and WMTS map services, building custom areas, requesting map services to obtain elevation value lists, creating appropriate ribbon configuration tables, and rendering It is a ribbon texture map and uses a 3D rendering engine to render the terrain in real time in the terrain tile shader.

Benefits of technology

It realizes dynamic real-time electronic map terrain rendering, meets the real-time rendering needs of custom areas, can clearly and vividly express regional terrain changes, and enhances the expression effect and information transmission capabilities of electronic maps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006683B_ABST
    Figure CN119006683B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of digital map rendering technology, and in particular to a method and system for real-time rendering of a terrain shading map of a custom area, including: obtaining original DEM raster data of an area that needs terrain expression, converting it into Terrain‑RGB raster data and then publishing a map service; constructing a custom area, obtaining a list of elevation values ​​in the custom area, and creating a color band configuration table that matches the custom area according to the elevation value list; rendering the color band configuration table into a color band texture map; obtaining terrain tiles according to the map level and window space range of the current map, passing the terrain tiles and the color band texture map into a terrain tile shader rendering program, and realizing the terrain rendering of the custom area in the current map window space based on a three-dimensional rendering engine. The present invention realizes real-time dynamic rendering of a terrain shading map for a custom area in an electronic map, and enhances the expression effect and information transmission capability of the electronic map.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of digital map rendering, and in particular to a method and system for real-time rendering of a terrain shading map of a custom area. Background Art

[0002] Electronic maps are widely used due to their real-time, interactive and rich visualization features. Terrain rendering is an important component of them. Terrain can graphically display the ups and downs of the earth's surface and changes in terrain, making the map more vivid and three-dimensional. It is of great significance both for enhancing visualization effects and supporting geographic analysis.

[0003] The shading method is a terrain rendering method based on the principle of light and shadow to express the undulation of terrain by contrasting tones. Using the shading method for terrain rendering in electronic maps can enhance the terrain expression effect. In recent years, many researchers have made many attempts, but there are still some problems:

[0004] (1) Terrain data is expressed using digital elevation model (DEM) raster data. To achieve the terrain shading effect in electronic maps, the usual approach is to pre-render the DEM raster data, generate hillshade raster data or slice data, and then render the terrain for the raster data in the map rendering engine. This pre-rendering method cannot flexibly deal with the update of terrain data.

[0005] (2) Since the geographic space range expressed by raster data is fixed, when it is necessary to render terrain in a local area, the raster data often needs to be clipped. However, due to the large amount of data, complex calculations and fast-changing requirements, the clipping of raster data cannot meet the real-time and dynamic update requirements. In addition, there is also a method in the prior art of creating a plane grid according to the longitude and latitude range and then rendering the terrain. The longitude and latitude range is a fixed range and dynamic real-time rendering cannot be achieved.

[0006] (3) In terms of rendering effect, mountain shading combined with gradient coloring is currently a commonly used method for terrain rendering. However, in terms of color scheme configuration, most existing technologies use fixed color schemes. However, the elevation changes in different geographical regions vary greatly, and fixed color schemes cannot reflect the changing characteristics of terrain in different regions.

[0007] For example, in patent document CN117333631A, the terrain data to be rendered is published as an initial grayscale layer and an initial terrain color matching layer, and then a plane grid corresponding to the longitude and latitude range to be rendered is created, and the three-dimensional terrain effect corresponding to the longitude and latitude range is rendered according to the plane grid, the initial grayscale layer and the initial terrain color matching layer. The longitude and latitude range of the plane grid is a fixed range, and dynamic real-time rendering cannot be achieved; and the plane grid created according to the maximum and minimum values ​​of the longitude and latitude range can only achieve terrain rendering within a fixed rectangular range, and cannot achieve rendering of custom irregular areas; the pre-published initial terrain color matching layer is pre-rendered, and the color matching layer cannot be dynamically updated during rendering.

[0008] In summary, existing electronic map terrain rendering has the problems of lack of real-time performance, dynamism and inability to adapt to elevation changes in different geographical areas. Summary of the invention

[0009] Therefore, the technical problem to be solved by the present invention is to overcome the problems in the prior art that electronic map terrain rendering lacks real-time performance, dynamism, and cannot adapt to elevation changes in different geographical areas.

[0010] In order to solve the above technical problems, the present invention provides a method for real-time rendering of a terrain shaded image of a custom area, comprising:

[0011] S1. Obtain the original digital elevation model raster data of the area that needs terrain expression, convert it into Terrain-RGB raster data, and publish it as WMS and WMTS map services;

[0012] S2. Construct a custom region in the area where terrain expression is required, request the WMS map service, obtain the elevation value list in the custom region, and create a color band configuration table suitable for the custom region according to the elevation value list;

[0013] S3, rendering the color band configuration table into a color band texture map;

[0014] S4, requesting WMTS terrain tiles according to the map level and window space range of the current map, passing the terrain tiles and the color band texture map as parameters to the terrain tile shader rendering program, and using the three-dimensional rendering engine to realize the custom area terrain rendering in the current map window space;

[0015] S5. When the map window is updated, return to S4;

[0016] S6. When the range of the custom area is updated, return to S2.

[0017] Preferably, the S2 specifically includes:

[0018] Build custom zones;

[0019] Calculate the bounding box of the custom area and request the WMS map service to obtain the WMS map image data Terrain-RGB-WMS;

[0020] Get a list of elevation values ​​within a custom area based on WMS map image data;

[0021] Create a color ramp configuration table that matches the custom area based on the elevation value list within the custom area.

[0022] Preferably, the step of constructing a custom area includes:

[0023] The custom area includes multiple irregular polygons, which are represented by longitude and latitude coordinate strings: ;in Represents a polygon, N represents the number of vertices that constitute the polygon, and N>=3; Represents the coordinates of the Nth vertex of the polygon, and Respectively represent the longitude and latitude of the Nth vertex;

[0024] Custom regions are represented by multiple polygons as follows: ;in Represents a custom area, M represents the number of polygons contained in the custom area, and M>=1; Represents the Mth polygon.

[0025] Preferably, the step of calculating the bounding box of the custom area and requesting a WMS map service includes:

[0026] Traverse all polygons in the custom area and the vertex coordinates of each polygon, and select the minimum longitude, maximum longitude, minimum latitude and maximum latitude in the vertex coordinates of all polygons as the boundary of the bounding box of the custom area;

[0027] Calculate the projection coordinates of the bounding box coordinates of the custom area in the EPSG:3857 coordinate system;

[0028] Request the WMS map service based on the projection coordinates of the bounding box of the custom area.

[0029] Preferably, obtaining a list of elevation values ​​within a custom area according to WMS map image data includes:

[0030] Convert the vertex coordinates of the custom area to the image coordinate space of Terrain-RGB-WMS to obtain the image vertex coordinates of the custom area;

[0031] Crop Terrain-RGB-WMS based on the image vertex coordinates of the custom area to obtain an image containing only the custom area data;

[0032] Iterate over all pixels in the image that only contains custom area data, convert the pixel value of each pixel into an elevation value, and obtain a list of elevation values ​​within the custom area.

[0033] Preferably, the step of creating a color band configuration table adapted to the custom area according to the elevation value list in the custom area includes:

[0034] Calculate segmentation points according to the elevation value list in the custom area to obtain a segmentation point list;

[0035] Creating a color band configuration table according to the segmentation point list, including: assigning a color value to the value of each segmentation point in the segmentation point list, and saving the result as the color band configuration table.

[0036] Preferably, according to the elevation value list in the custom area, the segmentation points are calculated using the quantile method to obtain a segmentation point list.

[0037] Preferably, the S4 specifically includes:

[0038] Render the custom area in vector surface drawing mode, and update the stencil value belonging to the custom area in the stencil buffer to 1;

[0039] Request WMTS terrain tiles based on the map level and window spatial extent of the current map;

[0040] Pass the relevant parameters to the terrain tile shader rendering program, render the terrain tiles in the current map window space, and discard the fragments based on the template value, including:

[0041] Passing relevant parameters into the terrain tile shader rendering program, wherein the relevant parameters include terrain tiles and color band texture maps;

[0042] The terrain tile shader rendering program calculates the terrain rendering color value of each fragment to achieve custom area terrain rendering in the current map window space;

[0043] Determine whether to output the rendering result to the screen based on the template value in the template buffer. If the template value is 1, the terrain rendering color value is rendered and output to the screen, otherwise no processing is performed.

[0044] Preferably, the terrain tile shader rendering program calculates the terrain rendering color value of each fragment to achieve the custom area terrain rendering in the current map window space, including:

[0045] Get the texture coordinates of each fragment;

[0046] Calculate the mountain shadow grayscale value of each fragment;

[0047] Sample the color band texture image and calculate the gradient color value of each fragment;

[0048] Calculate the terrain rendering color value of each fragment according to the mountain shadow grayscale value and gradient color value of each fragment;

[0049] The terrain tile shader rendering program renders each fragment based on the terrain rendering color value to achieve terrain rendering.

[0050] The present invention also provides a real-time rendering system for terrain shading images of a custom area, comprising:

[0051] The terrain service publishing module is used to obtain the original digital elevation model raster data of the area that needs terrain expression, convert it into Terrain-RGB raster data, and publish it as WMS and WMTS map services;

[0052] The color band configuration module is used to build a custom area, request the WMS map service, obtain the elevation value list in the custom area, and create a color band configuration table that matches the custom area based on the elevation value list;

[0053] A color ribbon texture map rendering module is used to render the color ribbon configuration table into a color ribbon texture map;

[0054] The terrain rendering module is used to request WMTS terrain tiles according to the map level and window space range of the current map, pass the terrain tiles and the color band texture map as parameters to the terrain tile shader rendering program, and realize the custom area terrain rendering in the current map window space based on the three-dimensional rendering engine;

[0055] The window update module is used to return to the terrain rendering module when the map window is updated;

[0056] The area range update module is used to return the ribbon configuration module when the range of the custom area is updated.

[0057] The above technical solution of the present invention has the following beneficial effects compared with the prior art:

[0058] The method for real-time rendering of a terrain shaded map of a custom area described in the present invention first converts DEM raster data with terrain height information into Terrain-RGB raster data, then publishes a map service, incorporates the terrain height information into map tiles, and then calculates the mountain shadow grayscale value and gradient color value of each fragment in real time in a terrain rendering shader after each map window is updated and terrain tiles are obtained, and then calculates the terrain rendering color value of each fragment, thereby realizing dynamic and real-time electronic map terrain rendering.

[0059] Taking into account the problem that raster data clipping cannot meet the real-time and dynamic requirements, the present invention does not clip the original DEM raster data, but constructs a custom area and utilizes the template test function of the three-dimensional rendering engine to execute fragment discard in the terrain tile shader rendering program, thereby improving data processing efficiency and meeting the real-time rendering requirements of the custom area.

[0060] After constructing a custom area, the present invention automatically generates a coloring scheme in sections according to the elevation value list in the custom area, creates a color band configuration table that matches the custom area, renders the color band matching table into a color band texture map, and passes the color band texture map into a terrain tile shader as a texture attachment, thereby achieving a terrain shading coloring effect that matches the local terrain features in the custom area, being able to more clearly and vividly show the regional terrain change features, and enhancing the expression effect and information transmission capability of the electronic map. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:

[0062] Figure 1 is a flow chart of the method of the present invention;

[0063] Figure 2 is a flow chart of calculating a ribbon configuration table in an embodiment of the present invention;

[0064] Figure 3 Schematic diagram of a terrain tile shader in an embodiment of the present invention. DETAILED DESCRIPTION

[0065] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention. Embodiment 1

[0066] Reference Figure 1 As shown, the present invention provides a method for real-time rendering of a terrain shading map of a custom area, comprising the following steps:

[0067] S1. Obtain the original digital elevation model raster data of the area that needs to be expressed in terrain, convert it into Terrain-RGB raster data, and publish the map service.

[0068] S1-1, obtaining the original digital elevation model raster data of the area where terrain expression is required. The digital elevation model is a physical ground model that represents the ground elevation in the form of an ordered numerical array, and is usually expressed in the form of raster data.

[0069] S1-2. Convert the original digital elevation model raster data into Terrain-RGB raster data.

[0070] Terrain-RGB raster is a raster data type that uses special encoding rules to encode and store ground elevation. It converts elevation values ​​in meters into RGBA color values ​​of an image through special encoding rules and uses the RGBA four channels of the image to store them; R represents red, G represents green, B represents blue, and A represents transparency.

[0071] The original digital elevation model raster data usually only includes a single-band data set, in which the single-band data stores elevation values. The present invention converts elevation values ​​into RGB color values ​​and stores them in three bands respectively, sets the transparency A to 255, and stores them in the fourth band to construct Terrain-RGB raster data containing four-band data sets.

[0072] The specific encoding rules for Terrain-RGB raster data are:

[0073] ;

[0074] in, is the elevation value, is the red channel value, is the green channel value, It is the blue channel value. Transparency A is not included in the calculation.

[0075] It is easy to know from the above formula that given the elevation value The RGB three-channel color value can also be calculated. This process is a simple mathematical calculation process and will not be described in detail. The conversion process can be implemented using any programming language or public tool and is not limited here.

[0076] S1-3. Publish Terrain-RGB raster data as WMTS and WMS map services.

[0077] Web Map Service (WMS) is an international standard for providing and using dynamic maps on the Internet. WMS map service has many characteristics. The present invention mainly uses its dynamic map generation capability. The client dynamically obtains map data by specifying the geographic range, spatial reference, output width and height, and format.

[0078] Web Map Tile Service (WMTS) is an international standard for providing digital maps on the Internet using cached image blocks. The WMTS map service uses a specified tiling scheme to cut map data into a pyramid-structured tile data set. Each map tile can be uniquely located by the tile row and column number + level number. For example, the specified map tile data can be requested through the network resource path http: / / baseURL / zoom / tileX / tileY.png, where zoom represents the level number, tileX represents the column number, and tileY represents the row number. The network resource path is not an actual URL, but a naming rule for the path that calls the WMTS map service resource. The tiling scheme of the WMTS map service can be specified according to actual needs. This embodiment adopts the Google Maps tiling scheme.

[0079] This embodiment uses the EPSG:3857 (Web Mercator) projection coordinate system as the map coordinate system, converts the Terrain-RGB raster data into the EPSG:3857 coordinate system, and then uses the map service publishing tool to publish it as a WMS map service and a WMTS map service. The map service publishing tool can use the GeoServer open source map server, but is not limited to this tool, and can implement the map service publishing function.

[0080] S2. Build a custom region in the area where terrain expression is required, request the map service, obtain the elevation value list in the custom region, and create a color band configuration table that matches the custom region based on the elevation value list. The calculation process of the color band configuration table is as follows: Figure 2 shown.

[0081] S2-1. Build a custom area, including:

[0082] A custom area usually includes multiple irregular polygons. This embodiment uses a longitude and latitude coordinate string to represent the polygon: ;in Represents a polygon, N represents the number of vertices that constitute the polygon, and N>=3; Represents the coordinates of the Nth vertex of the polygon, and Respectively represent the longitude and latitude of the Nth vertex.

[0083] So the custom area is represented by multiple polygons as follows: ;in Represents a custom area, M represents the number of polygons contained in the custom area, and M>=1; Represents the Mth polygon.

[0084] S2-2. Calculate the bounding box of the custom area and request the WMS map service to obtain the WMS map image data Terrain-RGB-WMS.

[0085] S2-2-1. Calculate the bounding box coordinates of the custom area.

[0086] Traverse all polygons in the custom area and the vertex coordinates of each polygon, and calculate the bounding box coordinates of the custom area by comparing them one by one. , the formula is:

[0087] ;

[0088] in, Represents the minimum longitude value among all polygon vertex coordinates. Represents the minimum latitude value among all polygon vertex coordinates. Represents the maximum longitude among all polygon vertex coordinates. Represents the maximum latitude among all polygon vertex coordinates; is the coordinate value of the lower left corner of the bounding box, The coordinate value of the upper right corner of the bounding box.

[0089] S2-2-2. Calculate the projection coordinates of the bounding box of the custom area.

[0090] Calculate the projection coordinates of the bounding box coordinates of the custom area in the EPSG:3857 coordinate system. The formula is:

[0091] ;

[0092] ;

[0093] in, , They represent the lower left corner and upper right corner coordinates of the bounding box in the EPSG:3857 coordinate system. Represents the mathematical process of converting longitude and latitude coordinates to EPSG:3857 coordinates, which is a common calculation method in the GIS field.

[0094] S2-2-3. Request WMS map service according to the projection coordinates of the bounding box of the custom area.

[0095] Construct the request address of WMS map service:

[0096] http: / / baseURL / wms?bbox={proj_XMin,proj_YMin,proj_XMax,proj_YMax}&width={MapWidth}&height={MapHeight}&format=image / png&srs=EPSG:3857;

[0097] MapWidth and MapHeight represent the width and height of the map respectively, and this embodiment adopts the pixel values ​​of the width and height of the window used to draw the map. The request address of the WMS map service is not the actual website address, but the naming rule of the path for calling the WMS map service resource.

[0098] Send a WMS map service request to obtain WMS map image data. The WMS map image data is in PNG image format and is represented as Terrain-RGB-WMS.

[0099] S2-3. Obtain a list of elevation values ​​within the custom area based on the WMS map image data Terrain-RGB-WMS.

[0100] Since the custom area is an irregular polygon, and the requested WMS map image data Terrain-RGB-WMS is a regular rectangle of all terrain data within the bounding box of the custom area, it is necessary to crop and remove the data in Terrain-RGB-WMS that does not belong to the custom area.

[0101] S2-3-1. Convert the vertex coordinates of the custom area to the image coordinate space of Terrain-RGB-WMS to obtain the image vertex coordinates of the custom area, including:

[0102] Traverse all polygons and vertex coordinates of each polygon in the custom area, and obtain the longitude and latitude coordinate values ​​of all vertex coordinates;

[0103] Convert the latitude and longitude coordinates of each vertex into the projection vertex coordinates of the EPSG:3857 coordinate system using the following formula:

[0104] ;

[0105] in, and Respectively represent the latitude and longitude coordinate values ​​of the vertex coordinates, represents the projected vertex coordinates, Represents the mathematical process of converting longitude and latitude coordinates into EPSG:3857 coordinates;

[0106] The projection vertex coordinates are converted to the image vertex coordinates of Terrain-RGB-WMS. The formula is:

[0107] ;

[0108] ;

[0109] in, Represents the projected vertex coordinates The corresponding image vertex coordinates, and Respectively represent the minimum and maximum values ​​on the x-axis of all projected vertex coordinates, and Respectively represent the minimum and maximum values ​​on the y-axis of all projected vertex coordinates, and Respectively represent the width and height of the map;

[0110] The image vertex coordinates of the custom region converted to the Terrain-RGB-WMS image coordinate space are represented as imagePolygons.

[0111] S2-3-2. Clip the Terrain-RGB-WMS based on the image vertex coordinates of the custom area to obtain an image Terrain-RGB-WMS-CLIP containing only the custom area data.

[0112] The specific cropping process is an image processing process, which is a common technical means in the field of image processing. This embodiment uses the OpenCV.js library to implement it, which is only for illustration and not for limitation. The specific steps include:

[0113] Use the cv2.Mat.zeros method to create a mask image MaskImage with the same size as Terrain-RGB-WMS and fill it with black (0,0,0,0);

[0114] Use cv2.fillPoly method to fill polygonal area of ​​mask image MaskImage. The polygon coordinates are the image vertex coordinates imagePolygons of the custom area converted to Terrain-RGB-WMS image coordinate space. The polygonal area is filled with white (255,255,255,255).

[0115] The cv2.bitwise_and method is used to perform mask processing on Terrain-RGB-WMS and MaskImage to obtain the image Terrain-RGB-WMS-CLIP that only contains the custom area data.

[0116] S2-3-3, traverse all pixels in the image Terrain-RGB-WMS-CLIP, convert the pixel value of each pixel into an elevation value, and obtain a list of elevation values ​​in the custom area. The specific steps include:

[0117] Define an empty array elevList as the elevation array to save elevation values;

[0118] Traverse all pixels in Terrain-RGB-WMS-CLIP and obtain the pixel value pixelValue(r,g,b,a) of each pixel, where r, g, and b represent the color values ​​of the red, green, and blue channels respectively, and a represents the transparency value;

[0119] Determine whether each pixel is a valid area: If the values ​​of the four channels in the pixel value are all 0, that is, r=0, g=0, b=0, and a=0, it means that the pixel is data in a non-custom area and is marked as an invalid area; otherwise, the pixel is marked as a valid area;

[0120] Determine whether each pixel belongs to a valid area or an invalid area. If it is a valid area, calculate the elevation value corresponding to the pixel according to the Terrain-RGB encoding rule; if it is an invalid area, discard the pixel;

[0121] Add the elevation values ​​of the pixels marked as valid areas to the elevation array elevList. The elevation array elevList is the list of elevation values ​​within the custom area.

[0122] The elevation value corresponding to the pixel is calculated according to the Terrain-RGB encoding rule, and the formula is:

[0123] ;

[0124] in, Indicates the elevation value corresponding to the pixel.

[0125] S2-4. Create a color band configuration table that matches the custom area based on the elevation value list in the custom area.

[0126] The gradient color rendering of terrain is usually drawn based on contour lines, that is, in each contour line interval of the terrain map, a certain order of colors is used for gradient rendering to express the ups and downs of the terrain. However, this method fixes the contour line division and color scheme, and the expression effect is relatively good for static maps with a fixed range and fixed resolution, but for dynamically changing electronic maps, the expression ability is insufficient. The spatial range and resolution of electronic maps are dynamically variable, and the fixed contour line color scheme cannot reflect regional differences. In addition, electronic maps have a wide range of applications, and a single terrain color scheme cannot meet the needs of diverse scenarios.

[0127] The present invention fully considers the characteristics of local area elevation distribution, automatically calculates the gradient color scheme, and creates a color band configuration table to achieve flexible color configuration, adapt to the dynamic changes of electronic maps, and fully express regional characteristics.

[0128] S2-4-1. Calculate segmentation points based on the elevation value list in the custom area to obtain a segmentation point list.

[0129] There are many ways to calculate segmentation points given a list of elevation values, such as the contour method, quantile method, natural breakpoint method, standard deviation method, etc.

[0130] This embodiment comprehensively considers the uncertainty of elevation distribution within the user-defined area, and adopts the quantile method to calculate segment points in order to show the characteristics of different terrain forms as much as possible.

[0131] In this embodiment, the number of segments is set to , , the calculation steps include:

[0132] Sort the elevation values ​​in the elevation value list within the custom area to obtain an ordered elevation value list sorted from small to large ;

[0133] Get the length of the elevation value list in the custom area, that is, the number of values ​​in the elevation value list ;

[0134] Define a list of segment points , initialized to an empty array, used to save all segment point values;

[0135] Set a Loop times, define the loop index Starting from 0, , after each loop ends, the index Increase by 1;

[0136] Each loop process calculates the quantile index and extracts the segment point value, including:

[0137] Calculate the quantile index: ,in Indicates a round-down operation;

[0138] Extract segment point values: by quantile index From an ordered list of elevations Retrieve segment point values ​​from , Indicates the operation of taking values ​​from a list according to index values, and then dividing the values ​​into segments Join In array;

[0139] After the cycle is completed, The last value of the array is added to In array;

[0140] Finally, save the segmentation point list , the number of values ​​in the list is recorded as .

[0141] S2-4-2. Create a color band configuration table that matches the custom area based on the segmentation point list.

[0142] Assign a color value to each segment point value in the segment point list to form a gradient color scheme, and save it as a color band configuration table, which is represented by an array as follows:

[0143] ;

[0144] in, Indicates the ribbon configuration table, Represents the kth ribbon configuration item, Represents the value of the kth segmentation point in the segmentation point list, Indicates the value of the kth segment point The corresponding color value, expressed in hexadecimal color value, is .

[0145] S3. Render the color band configuration table as a color band texture map.

[0146] Since the current three-dimensional rendering engine shader does not support the passing of multi-dimensional arrays or variable-length arrays, and the color band configuration table can be dynamically updated and needs to be stored as a multi-dimensional array of indefinite length, this embodiment renders the color band configuration table into a color band texture map, and passes the color band texture map as a texture attachment to the terrain tile shader, thereby passing the color band configuration information into the terrain tile shader.

[0147] This embodiment uses Canvas drawing to render the color band configuration table into a color band texture map. The specific process is as follows:

[0148] Create a Canvas object with a size of 256*256;

[0149] Use the createLinearGradient method to create a linear gradient object ctxGradient;

[0150] Traverse the ribbon configuration table and get the kth ribbon configuration item ], calculate the offset value of the current ribbon configuration item , the formula is:

[0151] ;

[0152] in, and Respectively represent the first and last segment point values ​​in the segment point list;

[0153] Use ctxGradient's addColorStop() , ) method, assign the offset value and color value of the current color band configuration item to the gradient object;

[0154] After the traversal is completed, the fillStyle attribute of the Canvas object is assigned to the gradient object ctxGradient;

[0155] The fillRect method of the Canvas object is used to draw a rectangle with a size of 256*256, so as to obtain a Canvas object that draws gradient colors and linear interpolation according to the color band configuration table as a color band texture map.

[0156] A ribbon texture map can be passed into a terrain tile shader as a texture attachment.

[0157] S4. Request WMTS terrain tiles according to the map level and window space range of the current map, pass the terrain tiles and the color band texture map as parameters to the terrain tile shader rendering program, and implement custom area terrain rendering in the current map window space based on the three-dimensional rendering engine.

[0158] Request WMTS terrain tiles according to the map level and window space range of the current map, pass the terrain tiles and ribbon texture map as parameters to the terrain tile shader rendering program, and render the terrain for the custom area in the current map window space based on the 3D rendering engine.

[0159] Since the terrain tiles in the published WMTS map service contain all terrain data within the original range, when the custom area is a subset of the original range, in some specific application scenarios, it is expected that only the terrain within the custom area will be rendered in the map. The present invention realizes terrain rendering of the custom area based on the template testing function of the three-dimensional rendering engine and the shader programming technology.

[0160] S4-1. Render the custom area and update the stencil value belonging to the custom area in the stencil buffer to 1.

[0161] Enable stencil writing, set the stencil function to GL_ALWAYS, and set the stencil mask value to 0xFF. Use vector surface drawing to render the custom area. After rendering, the stencil value of the custom area in the stencil buffer will be updated to 1.

[0162] S4-2. Request WMTS terrain tiles according to the map level and window spatial range of the current map.

[0163] Calculate the row and column number set of all terrain tiles covered according to the current map level and window space range, and traverse the row and column number set to request WMTS terrain tiles. The WMTS request address is such as: http: / / baseURL / zoom / tileX / tileY.png, where zoom represents the level number, tileX represents the column number, and tileY represents the row number. The terrain tile returned by WMTS is in PNG image format, represented as Terrain-RGB-Tile. The WMTS request address is not the actual URL, but the naming rule of the path to call the WMTS map service resource.

[0164] S4-3, passing the relevant parameters into the terrain tile shader rendering program, rendering the terrain tiles in the current map window space, and discarding the fragments based on the template buffer value. Figure 3 shown.

[0165] Turn off stencil writing, turn on stencil testing, set the stencil function to GL_EQUAL, and the stencil mask value to 0xFF.

[0166] Through the template test, only the fragments that pass the template test are rendered when the terrain rendering is performed subsequently, ensuring that the terrain tiles are rendered only when the template value is equal to the template buffer template value, that is, the area with the template value of 1 will be rendered, so that the terrain rendering of the custom area can be realized.

[0167] The process of rendering terrain tiles in the current map window space is as follows:

[0168] S4-3-1. Pass the relevant parameters into the terrain tile shader rendering program.

[0169] Pass the terrain tile Terrain-RGB-Tile into the terrain tile shader and save it as terrainRGBTexture; pass the color band texture map into the terrain tile shader and save it as colorConfigTexture.

[0170] In the terrain tile shader, the pixel value can be sampled from the terrainRGBTexture and converted into a height value through the texture sampling method, and the color value can be sampled from the color band texture map to support subsequent terrain calculation and rendering. The terrain tile shader includes a vertex shader and a fragment shader.

[0171] S4-3-2. The terrain tile shader rendering program calculates the terrain rendering color value of each fragment to achieve custom area terrain rendering in the current map window space.

[0172] S4-3-2-1. Get the texture coordinates of each fragment.

[0173] The shape of the terrain tile is a regular rectangle. A rectangle containing four vertices is defined to render the specified terrain tile. When defining the vertices of the rectangle, the texture coordinates (u0, v0), (u1, v1), (u2, v2), and (u3, v3) are specified.

[0174] Among them, (u0,v0)=(0,1), (u1,v1)=(0,0), (u2,v2)=(1,1), and (u3,v3)=(1,0).

[0175] In the vertex shader, the texture coordinates can be read vertex by vertex. The texture coordinates are passed to the fragment shader, and based on the automatic interpolation feature of the shader, the texture coordinates of each fragment can be generated in the fragment shader. .

[0176] S4-3-2-2. Calculate the mountain shadow grayscale value of each pixel.

[0177] Hill shadow assumes that the terrain receives parallel light from a fixed light source. As the angle between the slope and the light source changes, light and dark tones are generated. Hill shadow can intuitively depict the undulating characteristics of the terrain. The hill shadow grayscale value of each pixel can be calculated by the terrain height value and the specified light direction. This process is a commonly used calculation method in the GIS field.

[0178] By way of example, this embodiment provides a method for calculating the grayscale value of a mountain shadow, which is only for illustrative purposes and is not intended to be limiting.

[0179] The grayscale value of the mountain shadow is calculated based on the incident angle and direction of the light and the slope and aspect of each fragment. The calculation process is as follows:

[0180] (1) Calculate the incident angle and direction of light:

[0181] The mountain shadow changes with the incident light. The incident light simulating sunlight is represented by the altitude angle AzimuthAngle and the azimuth angle ElevationAngle. The altitude angle and azimuth angle can be specified as fixed values. For example, the altitude angle is usually set to 45 degrees and the azimuth angle is usually set to 315 degrees. They can also be calculated in real time based on the actual geographical location, date, and time. The calculation method is a common method and will not be repeated here.

[0182] The incident angle is expressed in radians and the calculation process is:

[0183] ;

[0184] in, Indicates the azimuth radian value, that is, the angle of incidence; Represents the calculation process of converting angle to radians.

[0185] The incident direction is expressed in radians of the zenith angle, and the calculation process is:

[0186] ;

[0187] in, Indicates the zenith angle in radians, that is, the incident direction.

[0188] (2) Calculate the slope and aspect of the current element:

[0189] The slope and aspect of the current fragment are calculated based on the terrain height value of the current fragment and the height values ​​of the eight pixels around the current fragment.

[0190] The texture coordinates of the current fragment are , the texture coordinates of the current fragment and the texture coordinates of the surrounding eight pixels are defined as:

[0191] ;

[0192] ;

[0193] ;

[0194] ;

[0195] ;

[0196] ;

[0197] ;

[0198] ;

[0199] ;

[0200] in, Indicates the resolution of the terrain tiles, , Indicates the pixel size of the terrain tile, usually 512; is the coordinate of the current fragment, , , , , , , and The texture coordinates of the eight pixels surrounding the current fragment.

[0201] Based on texture coordinates Terrain Tiles Sampling the texture and calculating the height value, the general formula is:

[0202] ;

[0203] ;

[0204] in, Represents a two-dimensional texture sampling operation, Represents the color value of the texture, , and Respectively represent the red channel value, green channel value, and blue channel value of the texture. Indicates the height value.

[0205] Based on the above general formula, the height values ​​of the current fragment and the surrounding eight pixels are calculated as follows: , , , , , , , and .

[0206] Calculate the rate of change of the current fragment in the X and Y directions:

[0207] ;

[0208] ;

[0209] in, Indicates the rate of change of the current fragment in the X direction, Indicates the rate of change of the current fragment in the Y direction, Represents the terrain tile resolution, that is, the actual physical distance represented by each pixel in the terrain tile image space. The specific calculation method is:

[0210] ;

[0211] in is the radius of the Earth, and the value used is , Indicates the pixel size of the terrain tile, usually 512; Represents the current map level, which is passed into the shader from outside.

[0212] The formula for calculating the slope of the current fragment is:

[0213] ;

[0214] in, Indicates the slope arc value, Indicates the longitudinal stretch ratio of the terrain. It can achieve exaggerated or smooth terrain effects. Setting it to 1 means no stretching. Represents the inverse tangent function.

[0215] The formula for calculating the slope of the current element is:

[0216] ;

[0217] in, Indicates the slope arc value.

[0218] (3) Calculate the grayscale value of the mountain shadow of the current pixel:

[0219] ;

[0220] in, Represents the gray value of the mountain shadow, Indicates the zenith angle in radians. Indicates the azimuth value in radians. Indicates the slope arc value, Indicates the slope arc value; The function constrains the value value to between 0 and 1. If value is less than 0, it returns 0; if value is greater than 1, it returns 1.

[0221] S4-3-2-3. Calculate the gradient color value of each fragment.

[0222] The height value of the current fragment terrain is , based on an ordered list of elevation values Get the minimum elevation value in the custom area , the maximum value is .

[0223] Calculate the elevation ratio of the current fragment height value within the custom area:

[0224] ;

[0225] in, Indicates the elevation ratio of the current fragment height value within the custom area.

[0226] Since terrain tiles are obtained based on the WMTS map service, the maximum and minimum elevation values ​​of the custom area are calculated based on the WMS map service. The map resolutions of the two may be different. Based on the resampling characteristics of raster data, the height value of the current fragment The condition of being within the custom area height range may not be met, then the calculated It may not be in the range of 0-1. Therefore, this embodiment adopts The function constrains the elevation scale value to the range 0-1.

[0227] Construct the texture coordinates of the current fragment's color band texture map based on the elevation ratio value of the current fragment's height value within the custom area .

[0228] Sample the color band texture image and use the obtained color value as the gradient color value of the current fragment. The formula is:

[0229] ;

[0230] in, Indicates the gradient color value of the current fragment. Represents a two-dimensional texture sampling operation, Represents a ribbon texture map, Represents the texture coordinates of the current fragment's color band texture map.

[0231] S4-3-2-4. Calculate the terrain rendering color value of each fragment.

[0232] The terrain rendering color value is calculated by mixing the mountain shadow grayscale value and the gradient color value. The formula is:

[0233] ;

[0234] ;

[0235] in, Represents the red, green, and blue channel values ​​in the gradient color value of the current fragment. Indicates the grayscale value of the mountain shadow of the current pixel. represents a three-dimensional vector, Represents the red, green and blue channel values ​​in the terrain rendering color value of the current fragment; Indicates the transparency value of the gradient color value of the current fragment. Indicates the transparency value in the terrain rendering color value of the current fragment.

[0236] S4-3-2-5. The terrain tile shader rendering program renders each tile pixel based on the terrain rendering color value to achieve terrain rendering.

[0237] S4-3-3. Determine whether to output the rendering result to the screen according to the template value in the template buffer. If the template value is 1, the terrain rendering color value is rendered as the final color and output to the screen to achieve the gradient rendering effect of the terrain tiles in the current map window; otherwise, no processing is performed.

[0238] S5. When the map window is updated, return to S4.

[0239] When the map is panned or zoomed, and the map window changes, the process returns to S4, requests WMTS terrain tiles based on the map level and window space range of the current map, and then renders the terrain for the custom area in the current map window space. The map window is refreshed to display the new rendering results.

[0240] S6. When the range of the custom area is updated, return to S2.

[0241] According to actual needs, the range of the custom area is updated, and S2 is returned to rebuild the custom area and the color band configuration table that matches the custom area, and the terrain rendering operation is performed. The map window is refreshed to display the new rendering results. Embodiment 2

[0242] Based on the method for real-time rendering of a terrain shading map in a custom area in the first embodiment, this embodiment further provides a system for real-time rendering of a terrain shading map in a custom area, including:

[0243] The terrain service publishing module is used to obtain the original digital elevation model raster data of the area that needs terrain expression, convert it into Terrain-RGB raster data, and publish it as WMS and WMTS map services;

[0244] The color band configuration module is used to build a custom area, request the WMS map service, obtain the elevation value list in the custom area, and create a color band configuration table that matches the custom area based on the elevation value list;

[0245] A color ribbon texture map rendering module is used to render the color ribbon configuration table into a color ribbon texture map;

[0246] The terrain rendering module is used to request WMTS terrain tiles according to the map level and window space range of the current map, pass the terrain tiles and the color band texture map as parameters to the terrain tile shader rendering program, and use the three-dimensional rendering engine to realize the custom area terrain rendering in the current map window space;

[0247] The window update module is used to return to the terrain rendering module when the map window is updated;

[0248] The area range update module is used to return the ribbon configuration module when the range of the custom area is updated.

[0249] Compared with the prior art, the present invention has the following beneficial effects:

[0250] 1. The present invention first converts the DEM raster data with terrain height information into Terrain-RGB raster data, then publishes the map service, incorporates the terrain height information into the map tile, and then calculates the mountain shadow grayscale value and gradient color value of each fragment in the terrain rendering shader in real time after each map window is updated and terrain tiles are obtained, and then calculates the terrain rendering color value of each fragment. The present invention dynamically requests terrain tiles according to the map window range, and then performs tile-by-tile terrain rendering according to the actual spatial range of the terrain tiles. Compared with the prior art, it does not rely on a fixed latitude and longitude range, and realizes dynamic and real-time electronic map terrain rendering.

[0251] 2. Taking into account the problem that raster data clipping cannot meet the real-time and dynamic requirements, the present invention does not clip the original DEM raster data, but constructs a custom area based on irregular polygons, and uses the template testing function of the three-dimensional rendering engine to execute fragment discard in the terrain tile shader rendering program, thereby improving data processing efficiency and meeting the real-time rendering requirements of the custom area.

[0252] 3. After the custom region is constructed, the present invention automatically generates a color scheme in sections according to the elevation value list in the custom region, creates a color band configuration table that matches the custom region, and renders the color band matching table into a color band texture map, and passes the color band texture map as a texture attachment to the terrain tile shader, thereby achieving a terrain gradient coloring effect that matches the local terrain features in the custom region, and can more clearly and vividly express the regional terrain change characteristics, thereby enhancing the electronic map expression effect and information transmission capabilities. In addition, by using the color band configuration table to calculate the terrain rendering color, the terrain color scheme can be flexibly specified in a parameterized configuration manner, which is simpler and more convenient when facing frequent updates, and achieves real-time terrain rendering.

[0253] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0254] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0255] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0256] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0257] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.

Claims

1. A real-time rendering method for terrain shading map of a custom area, characterized in that: include: S1. Obtain the original digital elevation model raster data of the area that needs terrain expression, convert it into Terrain-RGB raster data, and publish it as WMS and WMTS map services; S2. Build a custom region in the area where terrain expression is required, request the WMS map service, obtain the elevation value list in the custom region, and create a color band configuration table that matches the custom region based on the elevation value list, including: Build custom regions in areas where terrain expression is required; Calculate the bounding box of the custom area and request the WMS map service to obtain the WMS map image data Terrain-RGB-WMS; Get a list of elevation values ​​within a custom area based on WMS map image data, including: Convert the vertex coordinates of the custom area to the image coordinate space of Terrain-RGB-WMS to obtain the image vertex coordinates of the custom area; Crop Terrain-RGB-WMS based on the image vertex coordinates of the custom area to obtain an image containing only the custom area data; Traverse all pixels in the image that only contains custom area data, convert the pixel value of each pixel into an elevation value, and obtain a list of elevation values ​​within the custom area; Create a color band configuration table that matches the custom area based on the elevation value list in the custom area, including: Calculate segmentation points according to the elevation value list in the custom area to obtain a segmentation point list; Creating a color band configuration table according to the segmentation point list, including: assigning a color value to a value of each segmentation point in the segmentation point list, and saving the value as the color band configuration table; S3, using Canvas drawing method to render the color band configuration table into a color band texture map; S4, requesting WMTS terrain tiles according to the map level and window space range of the current map, passing the terrain tiles and the color band texture map as parameters to the terrain tile shader rendering program, and using the three-dimensional rendering engine to realize the custom area terrain rendering in the current map window space; S5. When the map window is updated, return to S4; S6. When the range of the custom area is updated, return to S2.

2. The method for real-time rendering of a terrain shading map of a custom area according to claim 1, characterized in that: The step of constructing a custom region in a region where terrain expression is required includes: The custom area includes multiple irregular polygons, which are represented by longitude and latitude coordinate strings: ;in Represents a polygon, N represents the number of vertices that constitute the polygon, and N>=3; Represents the coordinates of the Nth vertex of the polygon, and Respectively represent the longitude and latitude of the Nth vertex; Custom regions are represented by multiple polygons as follows: ;in Represents a custom area, M represents the number of polygons contained in the custom area, and M>=1; Represents the Mth polygon.

3. The method for real-time rendering of a terrain shading map of a custom area according to claim 2, characterized in that: The calculation of the bounding box of the custom area and requesting the WMS map service includes: Traverse all polygons in the custom area and the vertex coordinates of each polygon, and select the minimum longitude, maximum longitude, minimum latitude and maximum latitude in the vertex coordinates of all polygons as the boundary of the bounding box of the custom area; Calculate the projection coordinates of the bounding box coordinates of the custom area in the EPSG:3857 coordinate system; Request the WMS map service based on the projection coordinates of the bounding box of the custom area.

4. The method for real-time rendering of a terrain shading map of a custom area according to claim 1, characterized in that: According to the elevation value list in the custom area, the segmentation points are calculated using the quantile method to obtain a segmentation point list.

5. The method for real-time rendering of a terrain shading map of a custom area according to claim 1, characterized in that: The S4 specifically includes: Render the custom area in vector surface drawing mode, and update the stencil value belonging to the custom area in the stencil buffer to 1; Request WMTS terrain tiles based on the map level and window spatial extent of the current map; Pass the relevant parameters to the terrain tile shader rendering program, render the terrain tiles in the current map window space, and discard the fragments based on the template value, including: Passing relevant parameters into the terrain tile shader rendering program, wherein the relevant parameters include terrain tiles and color band texture maps; The terrain tile shader rendering program calculates the terrain rendering color value of each fragment to achieve custom area terrain rendering in the current map window space; Determine whether to output the rendering result to the screen based on the template value in the template buffer. If the template value is 1, the terrain rendering color value is rendered and output to the screen, otherwise no processing is performed.

6. The method for real-time rendering of a terrain shading map of a custom area according to claim 5, characterized in that: The terrain tile shader rendering program calculates the terrain rendering color value of each fragment to achieve the custom area terrain rendering in the current map window space, including: Get the texture coordinates of each fragment; Calculate the mountain shadow grayscale value of each fragment; Sample the color band texture image and calculate the gradient color value of each fragment; Calculate the terrain rendering color value of each fragment according to the mountain shadow grayscale value and gradient color value of each fragment; The terrain tile shader rendering program renders each fragment based on the terrain rendering color value to achieve terrain rendering.

7. A real-time rendering system for terrain shading of a custom area, characterized in that: include: The terrain service publishing module is used to obtain the original digital elevation model raster data of the area that needs terrain expression, convert it into Terrain-RGB raster data, and publish it as WMS and WMTS map services; The color band configuration module is used to build a custom area, request the WMS map service, obtain the elevation value list in the custom area, and create a color band configuration table that matches the custom area based on the elevation value list, including: Build custom regions in areas where terrain expression is required; Calculate the bounding box of the custom area and request the WMS map service to obtain the WMS map image data Terrain-RGB-WMS; Get a list of elevation values ​​within a custom area based on WMS map image data, including: Convert the vertex coordinates of the custom area to the image coordinate space of Terrain-RGB-WMS to obtain the image vertex coordinates of the custom area; Crop Terrain-RGB-WMS based on the image vertex coordinates of the custom area to obtain an image containing only the custom area data; Traverse all pixels in the image that only contains custom area data, convert the pixel value of each pixel into an elevation value, and obtain a list of elevation values ​​within the custom area; Create a color band configuration table that matches the custom area based on the elevation value list in the custom area, including: Calculate segmentation points according to the elevation value list in the custom area to obtain a segmentation point list; Creating a color band configuration table according to the segmentation point list, including: assigning a color value to a value of each segmentation point in the segmentation point list, and saving the value as the color band configuration table; The color ribbon texture map rendering module is used to render the color ribbon configuration table into a color ribbon texture map using Canvas drawing method; The terrain rendering module is used to request WMTS terrain tiles according to the map level and window space range of the current map, pass the terrain tiles and the color band texture map as parameters to the terrain tile shader rendering program, and use the three-dimensional rendering engine to realize the custom area terrain rendering in the current map window space; The window update module is used to return to the terrain rendering module when the map window is updated; The area range update module is used to return the ribbon configuration module when the range of the custom area is updated.

Citation Information

Patent Citations

  • Three-dimensional terrain rendering method and device based on Threejs and Geoserver

    CN117333631A

  • Raster data color matching publishing system and method and computer readable storage medium

    CN116342820A

  • Realistic water surface rendering method and system fusing multi-source tile map service

    CN117274466A