Terrain file generation method and device, electronic equipment and storage medium

By cutting DEM data into multiple areas and generating terrain files, the front and back end page error problem is solved, real-time and consistency of data is achieved, and the response time of data transmission is reduced.

CN119513047APending Publication Date: 2025-02-25LONGI GREEN ENERGY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310994601.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-08
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, there is an error in the 3D map tile data provided by the front-end JS interface and the real terrain modeled by the back-end based on its own DEM data, and the 3D map tile data is large in size, and real-time transmission increases the response time.

Method used

By obtaining the digital elevation model DEM data, cutting it into multiple regional DEM data and storing it to the cloud, obtaining map tile data and reading target terrain data from the target area DEM data, generating terrain files to solve page errors, and reducing data transmission through cloud optimization GeoTIFF format.

Benefits of technology

It solves the problem of front-end page error, ensures real-time data, reduces the response time of data transmission, and achieves data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513047A_ABST
    Figure CN119513047A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a terrain file generation method and device, electronic equipment and a storage medium. The terrain file generation method comprises the steps of obtaining DEM data, cutting the DEM data into multiple pieces of regional DEM data, and storing the multiple pieces of regional DEM data to a cloud; obtaining map tile data, determining target area DEM data corresponding to the map tile data from the multiple pieces of area DEM data, and reading target terrain data corresponding to the map tile data from the target area DEM data; and based on the target topographic data, generating a topographic file corresponding to the map tile data. In the embodiment of the invention, the page error problem of the front end and the rear end can be solved, the data consistency of the front end and the rear end is ensured, and the map tile data does not need to be transmitted in real time, so that the response time for acquiring the data is shortened, and the real-time performance of the data is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of GIS (Geographic Information System), and in particular to a terrain file generation method, device, electronic device and storage medium. Background Art

[0002] The mapping industry is a rapidly developing and critical information technology field that provides users with applications such as geographic information systems and map data analysis by collecting, processing and visualizing geographic information. With the digital transformation of the industrial field, some companies have begun to develop their own digital design software, and map information is an indispensable part of the research and development process.

[0003] In the prior art, although most map service providers can provide 3D (three-dimensional) map tile data, what they provide are generally front-end JS (JavaScript) interfaces. When the back-end models the real terrain based on its own DEM (Digital Elevation Model) data, errors will occur with the front-end page. In addition, the volume of 3D map tile data is large, and real-time transmission through the network will increase the response time. Summary of the invention

[0004] In view of the above problems, the embodiments of the present application propose a terrain file generation method, device, electronic device and storage medium, which can solve the page error problem between the front-end and the back-end, and can ensure the real-time performance of the data.

[0005] According to one aspect of an embodiment of the present application, a method for generating a terrain file is provided, the method comprising:

[0006] Acquire digital elevation model (DEM) data, cut the DEM data into multiple regional DEM data, and store the multiple regional DEM data in the cloud;

[0007] Acquire map tile data, determine target area DEM data corresponding to the map tile data from the multiple area DEM data, and read target terrain data corresponding to the map tile data from the target area DEM data;

[0008] Based on the target terrain data, a terrain file corresponding to the map tile data is generated.

[0009] Optionally, storing the multiple regional DEM data in the cloud includes: for each of the regional DEM data, converting the regional DEM data into regional DEM data in a cloud-optimized GeoTIFF format; and storing the regional DEM data in the cloud-optimized GeoTIFF format in the cloud.

[0010] Optionally, reading the target terrain data corresponding to the map tile data from the target area DEM data includes: calculating the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data; and reading, from the target area DEM data, terrain data of the amount of data starting from the relative position index as the target terrain data.

[0011] Optionally, the calculation of the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data, includes: calculating the range of the map tile data, and reading the first affine matrix information of the target area DEM data; based on the range and the first affine matrix information, calculating the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data.

[0012] Optionally, the relative position index includes a longitude index and a latitude index, the data volume includes the number of rows and columns, the range includes the minimum longitude, the maximum longitude, the minimum latitude and the maximum latitude, and the first affine matrix information includes the first longitude coordinate and the first latitude coordinate of the first reference starting point of the target area DEM data, as well as the horizontal pixel resolution and the vertical pixel resolution of the target area DEM data.

[0013] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area;

[0014] The relative position index is calculated by the following formula:

[0015] x_offset=floor((minx-origin_x) / pixel_width)

[0016] y_offset=floor((maxy-origin_y) / pixel_height)

[0017] Among them, x_offset represents the longitude index, y_offset represents the latitude index, minx represents the minimum longitude, maxy represents the maximum latitude, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, and floor represents the rounding down operation.

[0018] Optionally,

[0019] The data volume is calculated by the following formula:

[0020] cols=ceil((maxx-minx) / pixel_width)

[0021] rows=ceil((maxy-miny) / abs(pixel_height))

[0022] Among them, cols represents the number of columns, rows represents the number of rows, minx represents the minimum longitude, maxx represents the maximum longitude, miny represents the minimum latitude, maxy represents the maximum latitude, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, ceil represents the rounding operation, and abs represents the absolute value operation.

[0023] Optionally, after calculating the amount of data covered by the map tile data in the target area DEM data, it also includes: calculating the proportion of column edges of the target terrain data exceeding the map tile data, and when the column edge proportion is less than 0, increasing the number of columns by 1; calculating the proportion of row edges of the target terrain data exceeding the map tile data, and when the row edge proportion is less than 0, increasing the number of rows by 1.

[0024] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area;

[0025] The column edge ratio is calculated by the following formula:

[0026] right=(x_offset+cols)-((maxx-origin_x) / pixel_width)

[0027] Wherein, right represents the column edge ratio, x_offset represents the longitude index, cols represents the number of columns, maxx represents the maximum longitude, origin_x represents the first longitude coordinate, and pixel_width represents the horizontal pixel resolution;

[0028] The row edge ratio is calculated by the following formula:

[0029] lower=(y_offset+rows)-((miny-origin_y) / pixel_height)

[0030] Among them, lower represents the row edge ratio, y_offset represents the latitude index, rows represents the number of rows, miny represents the minimum latitude, origin_y represents the first latitude coordinate, and pixel_height represents the vertical pixel resolution.

[0031] Optionally, generating a terrain file corresponding to the map tile data based on the target terrain data includes: obtaining first affine matrix information of the DEM data of the target area, and a relative position index between the map tile data and the DEM data of the target area; calculating the coordinates of a second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; calculating elevation point data corresponding to the target terrain data based on the target terrain data, the coordinates and the first affine matrix information; generating an irregular triangulated network TIN file based on the elevation point data, and using the TIN file as the terrain file.

[0032] Optionally, the first affine matrix information includes a first longitude coordinate and a first latitude coordinate of a first reference starting point of the target area DEM data, and a horizontal pixel resolution and a vertical pixel resolution of the target area DEM data, the relative position index includes a longitude index and a latitude index, and the coordinates include a second longitude coordinate and a second latitude coordinate.

[0033] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data;

[0034] The coordinates are calculated by the following formula:

[0035] x=origin_x+pixel_width*x_offset

[0036] y=origin_y+pixel_height*y_offset

[0037] Among them, x represents the second longitude coordinate, y represents the second latitude coordinate, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, x_offset represents the longitude index, and y_offset represents the latitude index.

[0038] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data;

[0039] The elevation point data is calculated by the following formula:

[0040] points=[x+i*pixel_width,yj*abs(pixel_height),im_data[j,i]]

[0041] Among them, points represents the elevation point data, x represents the second longitude coordinate, y represents the second latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, im_data represents the target terrain data, i represents an arithmetic array with a step size of 1 corresponding to the number of columns of the target terrain data, j represents an arithmetic array with a step size of 1 corresponding to the number of rows of the target terrain data, and abs represents an absolute value operation.

[0042] Optionally, generating a terrain file corresponding to the map tile data based on the target terrain data includes: reading projection information of the DEM data of the target area, and obtaining second affine matrix information of the target terrain data; writing the projection information of the DEM data of the target area, the second affine matrix information of the target terrain data, and the target terrain data into a GeoTIFF file in geographic tag image file format, and using the GeoTIFF file as the terrain file.

[0043] Optionally, the obtaining of the second affine matrix information of the target terrain data includes: obtaining the first affine matrix information of the target area DEM data, and the relative position index between the map tile data and the target area DEM data; calculating the coordinates of the second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; and generating the second affine matrix information based on the coordinates and the first affine matrix information.

[0044] Optionally, generating a terrain file corresponding to the map tile data based on the target terrain data includes: obtaining a three-dimensional zero matrix and a height matrix corresponding to the target terrain data, the three-dimensional zero matrix and the height matrix having the same number of rows and columns as the target terrain data; filling the color values ​​corresponding to each position in the three-dimensional zero matrix based on a preset conversion relationship between height and color value and the height matrix to obtain a color matrix; generating a portable network graphics PNG file based on the color matrix, and using the PNG file as the terrain file.

[0045] Optionally, the height matrix is ​​obtained by the following formula, including:

[0046] data = (im_data + 10000) / 0.1

[0047] Among them, data represents the height matrix, and im_data represents the target terrain data.

[0048] According to another aspect of an embodiment of the present application, a terrain file generation device is provided, the device comprising:

[0049] A storage module is used to obtain digital elevation model DEM data, cut the DEM data into multiple regional DEM data, and store the multiple regional DEM data in the cloud;

[0050] An acquisition module, used for acquiring map tile data, determining target area DEM data corresponding to the map tile data from the multiple area DEM data, and reading target terrain data corresponding to the map tile data from the target area DEM data;

[0051] A generation module is used to generate a terrain file corresponding to the map tile data based on the target terrain data.

[0052] Optionally, the storage module includes: a format conversion unit, used for converting the regional DEM data into regional DEM data in cloud-optimized GeoTIFF format for each regional DEM data; and a data storage unit, used for storing the regional DEM data in cloud-optimized GeoTIFF format to the cloud.

[0053] Optionally, the acquisition module includes: an information calculation unit, used to calculate the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data; a data reading unit, used to read the terrain data of the amount of data starting from the relative position index from the target area DEM data as the target terrain data.

[0054] Optionally, the information calculation unit includes: an information acquisition subunit, used to calculate the range of the map tile data, and to read the first affine matrix information of the target area DEM data; an information calculation subunit, used to calculate the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data based on the range and the first affine matrix information.

[0055] Optionally, the relative position index includes a longitude index and a latitude index, the data volume includes the number of rows and columns, the range includes the minimum longitude, the maximum longitude, the minimum latitude and the maximum latitude, and the first affine matrix information includes the first longitude coordinate and the first latitude coordinate of the first reference starting point of the target area DEM data, as well as the horizontal pixel resolution and the vertical pixel resolution of the target area DEM data.

[0056] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area;

[0057] The information calculation subunit is specifically used to calculate the relative position index by the following formula:

[0058] x_offset=floor((minx-origin_x) / pixel_width)

[0059] y_offset=floor((maxy-origin_y) / pixel_height)

[0060] Among them, x_offset represents the longitude index, y_offset represents the latitude index, minx represents the minimum longitude, maxy represents the maximum latitude, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, and floor represents the rounding down operation.

[0061] Optionally,

[0062] The information calculation subunit is specifically used to calculate the data volume using the following formula:

[0063] cols=ceil((maxx-minx) / pixel_width)

[0064] rows=ceil((maxy-miny) / abs(pixel_height))

[0065] Among them, cols represents the number of columns, rows represents the number of rows, minx represents the minimum longitude, maxx represents the maximum longitude, miny represents the minimum latitude, maxy represents the maximum latitude, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, ceil represents the rounding operation, and abs represents the absolute value operation.

[0066] Optionally, the information calculation unit also includes: a first processing sub-unit, used to calculate the column edge ratio of the target terrain data exceeding the map tile data, and when the column edge ratio is less than 0, the number of columns is increased by 1; a second processing sub-unit, used to calculate the row edge ratio of the target terrain data exceeding the map tile data, and when the row edge ratio is less than 0, the number of rows is increased by 1.

[0067] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area;

[0068] The first processing subunit is specifically configured to calculate the column edge ratio by the following formula:

[0069] right=(x_offset+cols)-((maxx-origin_x) / pixel_width)

[0070] Wherein, right represents the column edge ratio, x_offset represents the longitude index, cols represents the number of columns, maxx represents the maximum longitude, origin_x represents the first longitude coordinate, and pixel_width represents the horizontal pixel resolution;

[0071] The second processing subunit is specifically configured to calculate the row edge ratio by the following formula:

[0072] lower=(y_offset+rows)-((miny-origin_y) / pixel_height)

[0073] Among them, lower represents the row edge ratio, y_offset represents the latitude index, rows represents the number of rows, miny represents the minimum latitude, origin_y represents the first latitude coordinate, and pixel_height represents the vertical pixel resolution.

[0074] Optionally, the generation module includes: a first acquisition unit, used to acquire the first affine matrix information of the target area DEM data, and the relative position index between the map tile data and the target area DEM data; a first calculation unit, used to calculate the coordinates of the second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; a second calculation unit, used to calculate the elevation point data corresponding to the target terrain data based on the target terrain data, the coordinates and the first affine matrix information; a first generation unit, used to generate an irregular triangulated network TIN file based on the elevation point data, and use the TIN file as the terrain file.

[0075] Optionally, the first affine matrix information includes a first longitude coordinate and a first latitude coordinate of a first reference starting point of the target area DEM data, and a horizontal pixel resolution and a vertical pixel resolution of the target area DEM data, the relative position index includes a longitude index and a latitude index, and the coordinates include a second longitude coordinate and a second latitude coordinate.

[0076] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data;

[0077] The first calculation unit is specifically configured to calculate the coordinates using the following formula:

[0078] x=origin_x+pixel_width*x_offset

[0079] y=origin_y+pixel_height*y_offset

[0080] Among them, x represents the second longitude coordinate, y represents the second latitude coordinate, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, x_offset represents the longitude index, and y_offset represents the latitude index.

[0081] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data;

[0082] The second calculation unit is specifically used to calculate the elevation point data by the following formula:

[0083] points=[x+i*pixel_width,yj*abs(pixel_height),im_data[j,i]]

[0084] Among them, points represents the elevation point data, x represents the second longitude coordinate, y represents the second latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, im_data represents the target terrain data, i represents an arithmetic array with a step size of 1 corresponding to the number of columns of the target terrain data, j represents an arithmetic array with a step size of 1 corresponding to the number of rows of the target terrain data, and abs represents an absolute value operation.

[0085] Optionally, the generation module includes: a second acquisition unit, used to read the projection information of the DEM data of the target area and obtain the second affine matrix information of the target terrain data; a second generation unit, used to write the projection information of the DEM data of the target area, the second affine matrix information of the target terrain data and the target terrain data into a GeoTIFF file in the geographic tag image file format, and use the GeoTIFF file as the terrain file.

[0086] Optionally, the second acquisition unit includes: a first acquisition subunit, used to acquire the first affine matrix information of the target area DEM data, and the relative position index between the map tile data and the target area DEM data; a first calculation subunit, used to calculate the coordinates of the second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; an information generation subunit, used to generate the second affine matrix information based on the coordinates and the first affine matrix information.

[0087] Optionally, the generation module includes: a third acquisition unit, used to acquire a three-dimensional zero matrix and a height matrix corresponding to the target terrain data, wherein the three-dimensional zero matrix and the height matrix have the same number of rows and columns as the target terrain data; a third calculation unit, used to fill the color values ​​corresponding to each position in the three-dimensional zero matrix based on a preset conversion relationship between height and color value and the height matrix to obtain a color matrix; and a third generation unit, used to generate a portable network graphics PNG file based on the color matrix, and use the PNG file as the terrain file.

[0088] Optionally, the third acquisition unit is specifically configured to acquire the height matrix by using the following formula:

[0089] data = (im_data + 10000) / 0.1

[0090] Among them, data represents the height matrix, and im_data represents the target terrain data.

[0091] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising: one or more processors; and one or more computer-readable storage media having instructions stored thereon; when the instructions are executed by the one or more processors, the processors execute a terrain file generation method as described in any one of the above items.

[0092] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the terrain file generation method as described in any one of the above items.

[0093] In the embodiment of the present application, the DEM data is divided into regional storage, and based on the stored regional DEM data, the map tile data is matched to the corresponding target terrain data offline, and then a terrain file is generated from the target terrain data. The terrain file can be directly read for rendering later. Therefore, the page error problem between the front and back ends can be solved, the consistency of the front and back end data is ensured, and there is no need to transmit the map tile data in real time, thereby reducing the response time for obtaining data and ensuring the real-time nature of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] In order to more clearly illustrate the technical solution of the embodiment of the present application, the drawings required for use in the description of the embodiment of the present application will be briefly introduced below. Obviously, the drawings described below are only some drawings of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0095] Figure 1 It is a flowchart of the steps of a terrain file generation method in an embodiment of the present application.

[0096] Figure 2 It is a schematic diagram of target terrain data in an embodiment of the present application.

[0097] Figure 3 It is a schematic diagram of a TIN file in an embodiment of the present application.

[0098] Figure 4 It is a schematic diagram of a GeoTIFF file of an embodiment of the present application.

[0099] Figure 5 It is a schematic diagram of a PNG file according to an embodiment of the present application.

[0100] Figure 6 It is a structural block diagram of a terrain file generating device according to an embodiment of the present application.

[0101] Figure 7 It is a structural schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0102] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0103] Reference Figure 1, showing a flow chart of the steps of a terrain file generation method in an embodiment of the present application.

[0104] like Figure 1 As shown, the terrain file generation method may include the following steps:

[0105] Step 101, obtain DEM data, cut the DEM data into multiple regional DEM data, and store the multiple regional DEM data in the cloud.

[0106] DEM data is collected by the PALSAR (Phase-array L-band synthetic aperture radar) sensor of the ALOS satellite. PALSAR is not affected by clouds, weather, and day and night, and can observe the earth around the clock. It can obtain data in three observation modes: high resolution, scanning synthetic aperture radar, and polarization. For example, DEM data can be 12.5m (meter) DEM data, etc., and the format of DEM data can be GeoTIFF (Geographic Tagged Image File Format).

[0107] In the embodiment of the present application, considering that the original DEM data is projection data and is not organized according to administrative regions, for the convenience of data processing, the original DEM data can be cut into multiple regional DEM data according to the set regional range.

[0108] For example, in the embodiment of the present application, tools such as ArcGIS software and SuperMap software can be used to cut the original DEM data into multiple regional DEM data according to the set regional range. The specific cutting process can be processed according to actual experience, and this embodiment will not be discussed in detail here.

[0109] Exemplarily, the above-mentioned regional range can be set according to actual needs. For example, the regional range can be set to a province, city, district, etc., and the embodiments of the present application do not limit this.

[0110] In the embodiment of the present application, considering that the amount of DEM data is large and not suitable for storage in a local computer, the DEM data of the multiple regions obtained by the above cutting can be stored in the cloud.

[0111] However, if DEM data is stored in the original GeoTIFF format, a large amount of DEM data will face the following challenges after being stored in the cloud: ① Remote parsing of cloud files requires full access to the entire file content through the network, but the storage ratio of the entire file corresponding to the currently cut regional DEM data is very large; ② Even if part of the data in the regional DEM data is read separately, the entire file needs to be fully accessed.

[0112] Therefore, in order to solve the above challenges, in the embodiment of the present application, the DEM data of the multiple regions can be stored in the cloud through the following steps A1 to A2:

[0113] Step A1: for each of the regional DEM data, convert the regional DEM data into regional DEM data in a Cloud Optimized GeoTIFF (COG) format.

[0114] In order to solve the above challenges, in the embodiment of the present application, the regional DEM data in GeoTIFF format can be cloud optimized, that is, the regional DEM data can be converted into regional DEM data in cloud-optimized GeoTIFF format. Since cloud-optimized GeoTIFF utilizes the Byte Serving function of HTTP (Hyper Text Transfer Protocol), allowing users to access only the required part of the raster data, when accessing the regional DEM data later, partial access can be performed without full access to the entire file.

[0115] Exemplarily, considering that the DEM data is projection data, the original coordinate system of the regional DEM data is a Cartesian coordinate system. In an embodiment of the present application, for each of the regional DEM data, before converting it into a cloud-optimized GeoTIFF format, the coordinate system of the regional DEM data can also be converted into a geocentric coordinate system, and then the regional DEM data after the coordinate conversion is converted into a cloud-optimized GeoTIFF format. Among them, the coordinate origin of the geocentric coordinate system is the center of mass of the earth. The geocentric coordinate system can be a WGS84 coordinate system, etc. The specific process of coordinate system conversion can be processed according to actual experience, and this embodiment will not be discussed in detail here.

[0116] Step A2: storing the regional DEM data in the cloud-optimized GeoTIFF format in the cloud.

[0117] Exemplarily, the regional DEM data in the cloud-optimized GeoTIFF format is stored in the cloud in the form of a regional cloud-optimized GeoTIFF file, and each regional DEM data can be stored as a regional cloud-optimized GeoTIFF file.

[0118] Exemplarily, in implementation, any applicable cloud storage service may be selected to store the regional DEM data, such as S3 (Simple Storage Service) and the like.

[0119] Step 102: Obtain map tile data, determine the target area DEM data corresponding to the map tile data from the multiple area DEM data, and read the target terrain data corresponding to the map tile data from the target area DEM data.

[0120] The map tile data can be provided by map service providers (such as AutoNavi Map, Baidu Map, Google Map, etc.). One map tile data corresponds to a relatively small area, such as a certain community, a certain shopping mall, a certain office building, etc.

[0121] In the embodiments of this application, for each map tile data, the target terrain data corresponding to the map tile data is respectively matched. Hereinafter, an example of one map tile data will be used for introduction.

[0122] First, determine the target area DEM data corresponding to the map tile data from the above-mentioned multiple area DEM data.

[0123] Exemplarily, if the map tile data belongs to a certain area, the target area DEM data corresponding to the map tile data is the area DEM data corresponding to that area. For example, if the above area DEM data is cut by province, and the map tile data is the map tile data of a certain shopping mall in Xi'an, then the target area DEM data corresponding to this map tile data is the area DEM data corresponding to Shaanxi Province.

[0124] Then, read the target terrain data corresponding to the map tile data from the target area DEM data corresponding to the map tile data.

[0125] Exemplarily, in the embodiments of this application, the underlying library GDAL (Geospatial Data Abstraction Library) can be used for remote reading and remote parsing of DEM data. GDAL is an open-source raster spatial data conversion library under the X / MIT license agreement. It can read, write, convert, and process various raster data formats. GDAL can access DEM data stored on a remote network. Taking S3 as an example, the recognized file name form is / vsis3 / bucket / key, where vsis3 is the file system handler, bucket is the name of the S3 bucket, and key is the S3 file object, that is, the file name that may contain subdirectories. Taking Shaanxi Province as an example, the file name is / vsis3 / dem / 12.5 / Shaanxi Province.tif. GDAL can also perform remote parsing on the remotely read DEM data. The following is a specific introduction.

[0126] In an optional implementation, the process of reading the target terrain data corresponding to the map tile data from the target area DEM data may include the following steps B1 to B2:

[0127] Step B1, calculating the relative position index between the map tile data and the DEM data of the target area, and the amount of data covered by the map tile data in the DEM data of the target area.

[0128] Exemplarily, step B1 may include the following steps B11 to B14:

[0129] Step B11, calculating the range of the map tile data.

[0130] The map tile data contains multiple longitude and latitude coordinates, and the range of the map tile data can be calculated through these longitude and latitude coordinates.

[0131] Exemplarily, the range of the map tile data is calculated by the following formula 1:

[0132] bounds = (minx,miny,maxx,maxy) Formula 1

[0133] Among them, bounds represents the range of the map tile data, minx represents the minimum longitude in the map tile data, miny represents the minimum latitude in the map tile data, maxx represents the maximum longitude in the map tile data, and maxy represents the maximum latitude in the map tile data.

[0134] Step B12, reading the first affine matrix information of the DEM data of the target area.

[0135] The regional DEM data stored in the cloud also includes the first affine matrix information of the regional DEM data. In the embodiment of the present application, the first affine matrix information of the target regional DEM data can be remotely read through GDAL.

[0136] Exemplarily, the first affine matrix information of the target area DEM data is expressed by the following formula 2:

[0137] im_geotrans=(origin_x,pixel_width,0,origin_y,0,pixel_height) Formula 2

[0138] Among them, im_geotrans represents the first affine matrix information of the target area DEM data, origin_x represents the first longitude coordinate of the first reference starting point of the target area DEM data, origin_y represents the first latitude coordinate of the first reference starting point of the target area DEM data, pixel_width represents the horizontal pixel resolution of the target area DEM data, and pixel_height represents the vertical pixel resolution of the target area DEM data.

[0139] Exemplarily, the first reference starting point of the target area DEM data may be the upper left corner, upper right corner, lower left corner, lower right corner, etc. of the target area DEM data, which is not limited in this embodiment.

[0140] Step B13: Calculate the relative position index between the map tile data and the target area DEM data based on the range of the map tile data and the first affine matrix information.

[0141] The relative position index between the map tile data and the target area DEM data refers to the offset position of the map tile data relative to the first reference starting point of the target area DEM data. The relative position index between the map tile data and the target area DEM data can include the relative position index in longitude, i.e., the longitude index, and the relative position index in latitude, i.e., the latitude index.

[0142] Taking into account that under normal circumstances, the first reference starting point of the target area DEM data is the upper left corner of the target area DEM data, the following will take the upper left corner of the target area DEM data as an example for the first reference starting point. For other situations, the first reference point can be processed in accordance with the processing method of the upper left corner of the target area DEM data.

[0143] Exemplarily, when the first reference starting point is the upper left corner of the DEM data of the target area, the relative position index is calculated by the following formula 3 and formula 4:

[0144] x_offset = floor((minx - origin_x) / pixel_width) Formula 3

[0145] y_offset =floor((maxy - origin_y) / pixel_height) Formula 4

[0146] Among them, x_offset represents the longitude index, y_offset represents the latitude index, minx represents the minimum longitude, maxy represents the maximum latitude, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, and floor represents the rounding down operation. In order to ensure that the left and upper sides of the target terrain data completely contain the map tile data, the rounding down operation needs to be performed when calculating the relative position index.

[0147] Step B14: Calculate the amount of data covered by the map tile data in the target area DEM data based on the range of the map tile data and the first affine matrix information.

[0148] The amount of data covered by the map tile data in the target area DEM data refers to the range covered by the map tile data in the target area DEM data. The amount of data covered by the map tile data in the target area DEM data may include the number of rows and columns covered.

[0149] Exemplarily, the data volume is calculated by the following formula 5 and formula 6:

[0150] cols = ceil((maxx - minx) / pixel_width) Formula 5

[0151] rows = ceil((maxy - miny) / abs(pixel_height)) Formula 6

[0152] Among them, cols represents the number of columns, rows represents the number of rows, minx represents the minimum longitude, maxx represents the maximum longitude, miny represents the minimum latitude, maxy represents the maximum latitude, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, ceil represents the rounding operation, and abs represents the absolute value operation.

[0153] In an optional implementation manner, in order to ensure that the map tile data is completely contained at the edge of the target terrain data, the number of rows and columns obtained above may be further optimized.

[0154] Exemplarily, the number of columns is optimized in the following manner: the column edge ratio of the target terrain data exceeding the map tile data is calculated, and when the column edge ratio is less than 0, the number of columns is increased by 1.

[0155] Exemplarily, the number of rows is optimized in the following manner: the row edge ratio of the target terrain data exceeding the map tile data is calculated, and when the row edge ratio is less than 0, the number of rows is increased by 1.

[0156] Exemplarily, when the first reference starting point is the upper left corner of the target area DEM data, the column edge ratio corresponds to the right side ratio, and the row edge ratio corresponds to the bottom side ratio. The column edge ratio is calculated by the following formula 7:

[0157] right = (x_offset + cols) - ((maxx - origin_x) / pixel_width) Formula 7

[0158] Among them, right represents the column edge ratio, x_offset represents the longitude index, cols represents the number of columns, maxx represents the maximum longitude, origin_x represents the first longitude coordinate, and pixel_width represents the horizontal pixel resolution.

[0159] The row edge ratio is calculated by the following formula 8:

[0160] lower = (y_offset + rows) - ((miny - origin_y) / pixel_height) Formula 8

[0161] Among them, lower represents the row edge ratio, y_offset represents the latitude index, rows represents the number of rows, miny represents the minimum latitude, origin_y represents the first latitude coordinate, and pixel_height represents the vertical pixel resolution.

[0162] The number of rows and columns is optimized by the following formula 9:

[0163] if right < 0: cols += 1; if lower < 0: rows += 1 Formula 9

[0164] Among them, right represents the column edge ratio, cols represents the number of columns, lower represents the row edge ratio, and rows represents the number of rows.

[0165] Step B2: reading the terrain data of the data volume starting from the relative position index from the target area DEM data as the target terrain data.

[0166] The regional DEM data stored in the cloud also includes the terrain data of the region. In the embodiment of the present application, after obtaining the relative position index between the map tile data and the target region DEM data, and the amount of data covered by the map tile data in the target region DEM data, GDAL can be used to remotely read the terrain data of the amount of data starting from the relative position index from the target region DEM data as the target terrain data (specifically raster data).

[0167] Exemplarily, the target terrain data is read by the following formula 10:

[0168] im_data=gdal(x_offset,y_offset,cols,rows) Formula 10

[0169] Among them, im_data represents the target terrain data corresponding to the map tile data, x_offset represents the longitude index, y_offset represents the latitude index, cols represents the number of columns, and rows represents the number of rows.

[0170] If the first reference starting point is the upper left corner of the DEM data of the target area, then starting from the relative position index, the terrain data of the data volume is read toward the lower right; if the first reference starting point is the upper right corner of the DEM data of the target area, then starting from the relative position index, the terrain data of the data volume is read toward the lower left; if the first reference starting point is the lower left corner of the DEM data of the target area, then starting from the relative position index, the terrain data of the data volume is read toward the upper right; if the first reference starting point is the lower right corner of the DEM data of the target area, then starting from the relative position index, the terrain data of the data volume is read toward the upper left.

[0171] The following is an example. Taking a certain map tile data of Shaanxi Province as an example, the specific latitude and longitude coordinates of the map tile data are given, and the calculation is as follows according to the above steps:

[0172] The latitude and longitude coordinates of the map tile data are:

[0173] [[108.56414794921875,34.404643571070956],

[0174] [108.56689453125,34.404643571070956],

[0175] [108.56689453125,34.40237742424137],

[0176] [108.56414794921875,34.40237742424137],

[0177] [108.56414794921875,34.404643571070956]]

[0178] After the above calculation, we get:

[0179] minx is 108.56414794921875,

[0180] miny is 34.40237742424137,

[0181] maxx is 108.56689453125,

[0182] maxy is 34.404643571070956,

[0183] The upper left corner origin_x is 104.3145452448609,

[0184] The upper left corner origin_y is 39.94389450034582,

[0185] pixel_width is 0.00012213340837881153,

[0186] pixel_height is 0.00012213340837881153,

[0187] x_offset is 34794, y_offset is 45354,

[0188] cols is 24, rows is 19.

[0189] Therefore, the matrix data of 19 rows and 24 columns from the upper left corner position index (34794, 45354) to the lower right can be taken from the regional DEM data source file corresponding to Shaanxi Province as the target terrain data corresponding to the map tile data. Figure 2 This is a schematic diagram of the target terrain data. Figure 2 The star in the middle represents the coordinate of the upper left corner of the map tile data, and the moon represents the coordinate of the upper left corner of the target terrain data. Since the map tile data cannot completely overlap with the target terrain data, the target terrain data will expand a little bit outward, and the error is basically within 1 pixel.

[0190] Step 103: Generate a terrain file corresponding to the map tile data based on the target terrain data.

[0191] After obtaining the target terrain data corresponding to the map tile data, a terrain file corresponding to the map tile data may be generated based on the target terrain data, so as to perform rendering based on the terrain file in subsequent use.

[0192] For example, in the embodiments of the present application, considering that the data of different map service providers may support different types of terrain files, different types of terrain files can be generated based on the target terrain data, and then the appropriate type can be selected for rendering according to the map service provider used. For example, the types of terrain files may include but are not limited to: TIN (Triangulated Irregular Network) format, GeoTIFF format, Terrain-RGB (Terrain-R (Red), G (Green), B (Blue), terrain RGB) format, and the like.

[0193] In an optional implementation, for the TIN format, the process of generating the terrain file corresponding to the map tile data based on the target terrain data may include the following steps C1 to C4:

[0194] Step C1, obtaining first affine matrix information of the DEM data of the target area, and a relative position index between the map tile data and the DEM data of the target area.

[0195] For the specific process of step C1, reference may be made to the relevant description of step B1 in the above embodiment, and this embodiment will not be discussed in detail here.

[0196] Step C2: Calculate the coordinates of a second reference starting point of the target terrain data based on the first affine matrix information and the relative position index.

[0197] The coordinates of the second reference starting point of the target terrain data may include a second longitude coordinate and a second latitude coordinate.

[0198] Exemplarily, similar to the first reference starting point of the target area DEM data mentioned above, the second reference starting point of the target terrain data can be the upper left corner, upper right corner, lower left corner, lower right corner, etc. of the target terrain data, and this embodiment does not limit this.

[0199] Exemplarily, taking the case where the first reference starting point is the upper left corner of the target area DEM data and the second reference starting point is the upper left corner of the target terrain data as an example, the coordinates of the upper left corner of the target terrain data are calculated by the following formulas 11 and 12:

[0200] x = origin_x + pixel_width * x_offset Formula 11

[0201] y = origin_y + pixel_height * y_offset Formula 12

[0202] Among them, x represents the second longitude coordinate, y represents the second latitude coordinate, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, x_offset represents the longitude index, and y_offset represents the latitude index.

[0203] Step C3, calculating the elevation point data corresponding to the target terrain data based on the target terrain data, the coordinates of the second reference point of the target terrain data and the first affine matrix information.

[0204] Exemplarily, taking the case where the first reference starting point is the upper left corner of the target area DEM data and the second reference starting point is the upper left corner of the target terrain data, the elevation point data is calculated by the following formula 13:

[0205] points = [x+i*pixel_width,yj*abs(pixel_height),im_data[j,i]] Formula 13

[0206] Among them, points represents the elevation point data, x represents the second longitude coordinate, y represents the second latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, im_data represents the target terrain data, abs represents the absolute value operation, i represents the arithmetic array with a step length of 1 corresponding to the number of columns of the target terrain data, and j represents the arithmetic array with a step length of 1 corresponding to the number of rows of the target terrain data. For example, if the number of columns is 24, then i is [0,1,2…23], and if the number of rows is 19, then j is [0,1,2…18].

[0207] Step C4, generating a TIN file based on the elevation point data, and using the TIN file as the terrain file.

[0208] The TIN model uses a series of linked triangles to fit the ground surface or other irregular surfaces and is often used to construct digital ground models.

[0209] In the embodiment of the present application, the Delaunay algorithm (triangulation algorithm) can be used to generate a TIN file based on the elevation point data. Of course, other applicable algorithms can also be used to generate a TIN file. The specific process of generating a TIN file can be processed according to actual experience, and this embodiment will not be discussed in detail here.

[0210] Figure 3 Based on Figure 2 The schematic diagram of the TIN file generated by the target terrain data shown is about 128kb in size.

[0211] In an optional implementation, for the GeoTIFF format, the process of generating the terrain file corresponding to the map tile data based on the target terrain data may include the following steps D1 to D2:

[0212] Step D1, reading the projection information of the DEM data of the target area, and obtaining the second affine matrix information of the target terrain data.

[0213] The regional DEM data stored in the cloud also includes projection information of the regional DEM data. In the embodiment of the present application, the projection information of the target regional DEM data can be read remotely through GDAL.

[0214] Exemplarily, the process of obtaining the second affine matrix information of the target terrain data may include the following steps D11 to D13:

[0215] Step D11, obtaining the first affine matrix information of the DEM data of the target area, and the relative position index between the map tile data and the DEM data of the target area.

[0216] For the specific process of step D11, reference may be made to the relevant description of step B1 in the above embodiment, and this embodiment will not be discussed in detail here.

[0217] Step D12: Calculate the coordinates of a second reference starting point of the target terrain data based on the first affine matrix information and the relative position index.

[0218] The coordinates of the second reference starting point of the target terrain data may include a second longitude coordinate and a second latitude coordinate. For the specific process of step D12, reference may be made to the relevant description of step C2 in the above embodiment, which will not be discussed in detail in this embodiment.

[0219] Step D13: Generate the second affine matrix information based on the coordinates of the second reference starting point of the target terrain data and the first affine matrix information.

[0220] The second affine matrix information of the target terrain data can be expressed as follows:

[0221] im_geotrans ′ =(x,pixel_width,0,y,0,pixel_height)

[0222] Among them, im_geotrans ′ Represents the second affine matrix information of the target terrain data, x represents the second longitude coordinate of the second reference starting point of the target terrain data, y represents the second latitude coordinate of the second reference starting point of the target terrain data, pixel_width represents the horizontal pixel resolution of the DEM data of the target area (that is, the horizontal pixel resolution of the target terrain data), and pixel_height represents the vertical pixel resolution of the DEM data of the target area (that is, the vertical pixel resolution of the target terrain data).

[0223] Step D2, writing the projection information of the DEM data of the target area, the second affine matrix information of the target terrain data and the target terrain data into a GeoTIFF file, and using the GeoTIFF file as the terrain file.

[0224] The GeoTIFF type takes advantage of the scalability of TIFF and adds a series of tags to indicate geographic information. It can be used to describe DEM data. Most GIS software supports images in this format.

[0225] Figure 4 Based on Figure 2 A schematic diagram of a GeoTIFF file generated from the target terrain data is shown. The size of the GeoTIFF file is approximately 2.1 kb.

[0226] In an optional implementation, for the Terrain-RGB format, the process of generating the terrain file corresponding to the map tile data based on the target terrain data may include the following steps E1 to E3:

[0227] Terrain-RGB is a digital elevation data encoded in PNG (Portable Network Graphic) raster tiles, which uses 256-bit numbers per color channel to represent the height. These color values ​​can be decoded into raw heights in meters.

[0228] Step E1, obtaining a three-dimensional zero matrix and a height matrix corresponding to the target terrain data.

[0229] In the embodiment of the present application, in order to improve the computing performance, matrix operation can be adopted.

[0230] Initialize a three-dimensional zero matrix with a shape of 3*number of rows*number of columns, where the three-dimensional zero matrix has the same number of rows and columns as the target terrain data.

[0231] Exemplarily, the three-dimensional zero matrix can be expressed by the following formula 13:

[0232] rgb = zeros((3,rows,cols)) Formula 13

[0233] Among them, rgb represents the three-dimensional zero matrix, rows represents rows, and cols represents columns.

[0234] Initialize a height matrix having the same number of rows and columns as the target terrain data.

[0235] For example, the height matrix can be expressed by the following formula 14:

[0236] data = (im_data +10000) / 0.1 Formula 14

[0237] Among them, data represents the height matrix, and im_data represents the target terrain data.

[0238] Step E2, based on the preset conversion relationship between height and color value and the height matrix, fill in the color value corresponding to each position in the three-dimensional zero matrix to obtain a color matrix.

[0239] The conversion relationship between the height and the color value can be set according to actual experience, and this embodiment does not impose any limitation on this.

[0240] Take the decoding of the color value of an image into a height value as shown in the following formula 15 as an example:

[0241] height=-10000+((R*256*256+G*256+B)*0.1) Formula 15

[0242] Among them, height represents the height value, R represents the red channel value, G represents the green channel value, and B represents the blue channel value.

[0243] By performing an inverse transformation on the above formula 15, a formula for converting height values ​​into color values ​​can be obtained.

[0244] For example, a possible inverse transformation of Formula 15 is shown in Formulas 16 to 18 below:

[0245] rgb[0]=((((data / / 256) / / 256) / 256)-(((data / / 256) / / 256) / / 256))*256 Formula 16

[0246] rgb[1]=(((data / / 256) / 256)-((data / / 256) / / 256))*256 Formula 17

[0247] rgb[2]=((data / 256)-(data / / 256))*256 Formula 18

[0248] Among them, data represents the height matrix, rgb[0] represents the red channel value, rgb[1] represents the green channel value, and rgb[2] represents the blue channel value.

[0249] Therefore, based on the height matrix shown in the above formula 14, the color value corresponding to each position in the three-dimensional zero matrix can be calculated through formulas 16 to 18, and then the color value is filled into the three-dimensional zero matrix to obtain a color matrix.

[0250] Step E3, generating a PNG file based on the color matrix, and using the PNG file as the terrain file.

[0251] In the embodiment of the present application, PIL (Python Imaging Library) can be used to generate a PNG file based on the color matrix. Of course, other applicable algorithms can also be used to generate a PNG file. The specific process of generating a PNG file can be processed according to actual experience, and this embodiment will not be discussed in detail here.

[0252] Exemplarily, in the embodiment of the present application, metadata may also be added to the PNG file, and the metadata information may be the second mapping information of the target terrain file.

[0253] Figure 5 Based on Figure 2 The schematic diagram of the PNG file (ie, Terrain-RGB file) generated by the target terrain data shown is about 0.37 kb in size.

[0254] In the embodiment of the present application, the DEM data is divided into regional storage, and based on the stored regional DEM data, the map tile data is matched to the corresponding target terrain data offline, and then a terrain file is generated from the target terrain data. The terrain file can be directly read for rendering later. Therefore, the page error problem between the front and back ends can be solved, the consistency of the front and back end data is ensured, and there is no need to transmit the map tile data in real time, thereby reducing the response time for obtaining data and ensuring the real-time nature of the data.

[0255] Reference Figure 6 , shows a structural block diagram of a terrain file generating device in an embodiment of the present application.

[0256] like Figure 6 As shown, the terrain file generating device may include the following modules:

[0257] Storage module 601, used for acquiring digital elevation model DEM data, cutting the DEM data into multiple regional DEM data, and storing the multiple regional DEM data in the cloud;

[0258] The acquisition module 602 is used to acquire map tile data, determine the target area DEM data corresponding to the map tile data from the multiple area DEM data, and read the target terrain data corresponding to the map tile data from the target area DEM data;

[0259] The generating module 603 is used to generate a terrain file corresponding to the map tile data based on the target terrain data.

[0260] Optionally, the storage module 601 includes: a format conversion unit, used to convert the regional DEM data into regional DEM data in cloud-optimized GeoTIFF format for each regional DEM data; and a data storage unit, used to store the regional DEM data in cloud-optimized GeoTIFF format to the cloud.

[0261] Optionally, the acquisition module 602 includes: an information calculation unit, used to calculate the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data; a data reading unit, used to read the terrain data of the amount of data starting from the relative position index from the target area DEM data as the target terrain data.

[0262] Optionally, the information calculation unit includes: an information acquisition subunit, used to calculate the range of the map tile data, and to read the first affine matrix information of the target area DEM data; an information calculation subunit, used to calculate the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data based on the range and the first affine matrix information.

[0263] Optionally, the relative position index includes a longitude index and a latitude index, the data volume includes the number of rows and columns, the range includes the minimum longitude, the maximum longitude, the minimum latitude and the maximum latitude, and the first affine matrix information includes the first longitude coordinate and the first latitude coordinate of the first reference starting point of the target area DEM data, as well as the horizontal pixel resolution and the vertical pixel resolution of the target area DEM data.

[0264] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area;

[0265] The information calculation subunit is specifically used to calculate the relative position index by the following formula:

[0266] x_offset=floor((minx-origin_x) / pixel_width)

[0267] y_offset=floor((maxy-origin_y) / pixel_height)

[0268] Among them, x_offset represents the longitude index, y_offset represents the latitude index, minx represents the minimum longitude, maxy represents the maximum latitude, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, and floor represents the rounding down operation.

[0269] Optionally,

[0270] The information calculation subunit is specifically used to calculate the data volume using the following formula:

[0271] cols=ceil((maxx-minx) / pixel_width)

[0272] rows=ceil((maxy-miny) / abs(pixel_height))

[0273] Among them, cols represents the number of columns, rows represents the number of rows, minx represents the minimum longitude, maxx represents the maximum longitude, miny represents the minimum latitude, maxy represents the maximum latitude, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, ceil represents the rounding operation, and abs represents the absolute value operation.

[0274] Optionally, the information calculation unit also includes: a first processing sub-unit, used to calculate the column edge ratio of the target terrain data exceeding the map tile data, and when the column edge ratio is less than 0, the number of columns is increased by 1; a second processing sub-unit, used to calculate the row edge ratio of the target terrain data exceeding the map tile data, and when the row edge ratio is less than 0, the number of rows is increased by 1.

[0275] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area;

[0276] The first processing subunit is specifically configured to calculate the column edge ratio by the following formula:

[0277] right=(x_offset+cols)-((maxx-origin_x) / pixel_width)

[0278] Wherein, right represents the column edge ratio, x_offset represents the longitude index, cols represents the number of columns, maxx represents the maximum longitude, origin_x represents the first longitude coordinate, and pixel_width represents the horizontal pixel resolution;

[0279] The second processing subunit is specifically configured to calculate the row edge ratio by the following formula:

[0280] lower=(y_offset+rows)-((miny-origin_y) / pixel_height)

[0281] Among them, lower represents the row edge ratio, y_offset represents the latitude index, rows represents the number of rows, miny represents the minimum latitude, origin_y represents the first latitude coordinate, and pixel_height represents the vertical pixel resolution.

[0282] Optionally, the generation module 603 includes: a first acquisition unit, used to acquire the first affine matrix information of the target area DEM data, and the relative position index between the map tile data and the target area DEM data; a first calculation unit, used to calculate the coordinates of the second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; a second calculation unit, used to calculate the elevation point data corresponding to the target terrain data based on the target terrain data, the coordinates and the first affine matrix information; a first generation unit, used to generate an irregular triangulated network TIN file based on the elevation point data, and use the TIN file as the terrain file.

[0283] Optionally, the first affine matrix information includes a first longitude coordinate and a first latitude coordinate of a first reference starting point of the target area DEM data, and a horizontal pixel resolution and a vertical pixel resolution of the target area DEM data, the relative position index includes a longitude index and a latitude index, and the coordinates include a second longitude coordinate and a second latitude coordinate.

[0284] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data;

[0285] The first calculation unit is specifically configured to calculate the coordinates using the following formula:

[0286] x=origin_x+pixel_width*x_offset

[0287] y=origin_y+pixel_height*y_offset

[0288] Among them, x represents the second longitude coordinate, y represents the second latitude coordinate, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, x_offset represents the longitude index, and y_offset represents the latitude index.

[0289] Optionally, the first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data;

[0290] The second calculation unit is specifically used to calculate the elevation point data by the following formula:

[0291] points=[x+i*pixel_width,yj*abs(pixel_height),im_data[j,i]]

[0292] Among them, points represents the elevation point data, x represents the second longitude coordinate, y represents the second latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, im_data represents the target terrain data, i represents an arithmetic array with a step size of 1 corresponding to the number of columns of the target terrain data, j represents an arithmetic array with a step size of 1 corresponding to the number of rows of the target terrain data, and abs represents an absolute value operation.

[0293] Optionally, the generation module 603 includes: a second acquisition unit, used to read the projection information of the DEM data of the target area and obtain the second affine matrix information of the target terrain data; a second generation unit, used to write the projection information of the DEM data of the target area, the second affine matrix information of the target terrain data and the target terrain data into a GeoTIFF file in the geographic tag image file format, and use the GeoTIFF file as the terrain file.

[0294] Optionally, the second acquisition unit includes: a first acquisition subunit, used to acquire the first affine matrix information of the target area DEM data, and the relative position index between the map tile data and the target area DEM data; a first calculation subunit, used to calculate the coordinates of the second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; an information generation subunit, used to generate the second affine matrix information based on the coordinates and the first affine matrix information.

[0295] Optionally, the generation module 603 includes: a third acquisition unit, used to acquire a three-dimensional zero matrix and a height matrix corresponding to the target terrain data, wherein the three-dimensional zero matrix and the height matrix have the same number of rows and columns as the target terrain data; a third calculation unit, used to fill the color values ​​corresponding to each position in the three-dimensional zero matrix based on a preset conversion relationship between height and color value and the height matrix to obtain a color matrix; and a third generation unit, used to generate a portable network graphics PNG file based on the color matrix, and use the PNG file as the terrain file.

[0296] Optionally, the third acquisition unit is specifically configured to acquire the height matrix by using the following formula:

[0297] data = (im_data + 10000) / 0.1

[0298] Among them, data represents the height matrix, and im_data represents the target terrain data.

[0299] In the embodiment of the present application, the DEM data is divided into regional storage, and based on the stored regional DEM data, the map tile data is matched to the corresponding target terrain data offline, and then a terrain file is generated from the target terrain data. The terrain file can be directly read for rendering later. Therefore, the page error problem between the front and back ends can be solved, the consistency of the front and back end data is ensured, and there is no need to transmit the map tile data in real time, thereby reducing the response time for obtaining data and ensuring the real-time nature of the data.

[0300] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0301] In an embodiment of the present application, an electronic device is also provided. The electronic device may include one or more processors and one or more computer-readable storage media storing instructions thereon, the instructions being, for example, application programs. When the instructions are executed by the one or more processors, the processors execute the terrain file generation method of any of the above embodiments.

[0302] Reference Figure 7 , shows a schematic diagram of an electronic device structure according to an embodiment of the present application. Figure 7 As shown, the electronic device includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704. The processor 701, the communication interface 702 and the memory 703 communicate with each other through the communication bus 704.

[0303] The memory 703 is used to store computer programs.

[0304] The processor 701 is used to implement the terrain file generation method of any of the above embodiments when executing the program stored in the memory 703.

[0305] The communication interface 702 is used for communication between the electronic device and other devices.

[0306] The communication bus 704 mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0307] The processor 701 mentioned above may include but is not limited to: a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0308] The memory 703 mentioned above may include but is not limited to: Read Only Memory (ROM), Random Access Memory (RAM), Compact Disc Read Only Memory (CD-ROM), Electronic Erasable Programmable Read Only Memory (EEPROM), hard disk, floppy disk, flash memory, and the like.

[0309] In an embodiment of the present application, a computer-readable storage medium is also provided, on which a computer program is stored. The program can be executed by a processor of an electronic device. When the computer program is executed by the processor, the processor executes the terrain file generation method described in any of the above embodiments.

[0310] The various embodiments in this specification are interrelated, and each embodiment is described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referenced to each other.

[0311] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0312] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM, RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0313] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

[0314] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0315] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0316] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0317] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0318] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0319] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard drives, ROM, RAM, magnetic disks, or optical disks.

[0320] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. In summary, the content of this specification should not be understood as limiting the present application.

Claims

1. A method for generating a terrain file, characterized in that: The method comprises: Acquire digital elevation model (DEM) data, cut the DEM data into multiple regional DEM data, and store the multiple regional DEM data in the cloud; Acquire map tile data, determine target area DEM data corresponding to the map tile data from the multiple area DEM data, and read target terrain data corresponding to the map tile data from the target area DEM data; Based on the target terrain data, a terrain file corresponding to the map tile data is generated.

2. The method according to claim 1, characterized in that The storing of the plurality of regional DEM data to the cloud comprises: For each of the regional DEM data, converting the regional DEM data into regional DEM data in a cloud-optimized GeoTIFF format; The regional DEM data in the cloud-optimized GeoTIFF format is stored in the cloud.

3. The method according to claim 1, characterized in that The step of reading target terrain data corresponding to the map tile data from the target area DEM data includes: Calculating the relative position index between the map tile data and the DEM data of the target area, and the amount of data covered by the map tile data in the DEM data of the target area; The terrain data of the data amount starting from the relative position index is read from the target area DEM data as the target terrain data.

4. The method according to claim 3, characterized in that The calculating the relative position index between the map tile data and the target area DEM data, and the amount of data covered by the map tile data in the target area DEM data, includes: Calculating the range of the map tile data, and reading the first affine matrix information of the DEM data of the target area; Based on the range and the first affine matrix information, a relative position index between the map tile data and the target area DEM data, and an amount of data covered by the map tile data in the target area DEM data are calculated.

5. The method according to claim 4, characterized in that The relative position index includes a longitude index and a latitude index, the data volume includes the number of rows and columns, the range includes the minimum longitude, the maximum longitude, the minimum latitude and the maximum latitude, and the first affine matrix information includes the first longitude coordinate and the first latitude coordinate of the first reference starting point of the target area DEM data, as well as the horizontal pixel resolution and the vertical pixel resolution of the target area DEM data.

6. The method according to claim 5, characterized in that The first reference starting point is the upper left corner of the DEM data of the target area; the relative position index is calculated by the following formula: x_offset=floor((minx-origin_x) / pixel_width) y_offset=floor((maxy-origin_y) / pixel_height) Among them, x_offset represents the longitude index, y_offset represents the latitude index, minx represents the minimum longitude, maxy represents the maximum latitude, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, and floor represents the rounding down operation.

7. The method according to claim 5, characterized in that The data volume is calculated by the following formula: cols=ceil((maxx-minx) / pixel_width) rows=ceil((maxy-miny) / abs(pixel_height)) Among them, cols represents the number of columns, rows represents the number of rows, minx represents the minimum longitude, maxx represents the maximum longitude, miny represents the minimum latitude, maxy represents the maximum latitude, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, ceil represents the rounding operation, and abs represents the absolute value operation.

8. The method according to claim 7, characterized in that After calculating the amount of data covered by the map tile data in the target area DEM data, the method further includes: Calculate the column edge ratio of the target terrain data exceeding the map tile data, and when the column edge ratio is less than 0, increase the number of columns by 1; The row edge ratio of the target terrain data exceeding the map tile data is calculated, and when the row edge ratio is less than 0, the number of rows is increased by 1.

9. The method according to claim 8, characterized in that The first reference starting point is the upper left corner of the DEM data of the target area; The column edge ratio is calculated by the following formula: right=(x_offset+cols)-((maxx-origin_x) / pixel_width) Wherein, right represents the column edge ratio, x_offset represents the longitude index, cols represents the number of columns, maxx represents the maximum longitude, origin_x represents the first longitude coordinate, and pixel_width represents the horizontal pixel resolution; The row edge ratio is calculated by the following formula: lower=(y_offset+rows)-((miny-origin_y) / pixel_height) Among them, lower represents the row edge ratio, y_offset represents the latitude index, rows represents the number of rows, miny represents the minimum latitude, origin_y represents the first latitude coordinate, and pixel_height represents the vertical pixel resolution.

10. The method according to claim 1, characterized in that The step of generating a terrain file corresponding to the map tile data based on the target terrain data includes: Acquire first affine matrix information of the DEM data of the target area, and a relative position index between the map tile data and the DEM data of the target area; Calculating the coordinates of a second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; Calculate the elevation point data corresponding to the target terrain data based on the target terrain data, the coordinates and the first affine matrix information; An irregular triangulated network (TIN) file is generated based on the elevation point data, and the TIN file is used as the terrain file.

11. The method according to claim 10, characterized in that The first affine matrix information includes the first longitude coordinate and the first latitude coordinate of the first reference starting point of the target area DEM data, and the horizontal pixel resolution and the vertical pixel resolution of the target area DEM data, the relative position index includes the longitude index and the latitude index, and the coordinates include the second longitude coordinate and the second latitude coordinate.

12. The method according to claim 11, characterized in that The first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data; The coordinates are calculated by the following formula: x=origin_x+pixel_width*x_offset y=origin_y+pixel_height*y_offset Among them, x represents the second longitude coordinate, y represents the second latitude coordinate, origin_x represents the first longitude coordinate, origin_y represents the first latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, x_offset represents the longitude index, and y_offset represents the latitude index.

13. The method according to claim 11, characterized in that The first reference starting point is the upper left corner of the DEM data of the target area, and the second reference starting point is the upper left corner of the target terrain data; The elevation point data is calculated by the following formula: points=[x+i*pixel_width,yj*abs(pixel_height),im_data[j,i]] Among them, points represents the elevation point data, x represents the second longitude coordinate, y represents the second latitude coordinate, pixel_width represents the horizontal pixel resolution, pixel_height represents the vertical pixel resolution, im_data represents the target terrain data, i represents an arithmetic array with a step size of 1 corresponding to the number of columns of the target terrain data, j represents an arithmetic array with a step size of 1 corresponding to the number of rows of the target terrain data, and abs represents an absolute value operation.

14. The method according to claim 1, characterized in that The step of generating a terrain file corresponding to the map tile data based on the target terrain data includes: Reading projection information of the DEM data of the target area, and obtaining second affine matrix information of the target terrain data; The projection information of the target area DEM data, the second affine matrix information of the target terrain data and the target terrain data are written into a GeoTIFF file in a geographic tag image file format, and the GeoTIFF file is used as the terrain file.

15. The method according to claim 14, characterized in that The step of obtaining the second affine matrix information of the target terrain data includes: Acquire first affine matrix information of the DEM data of the target area, and a relative position index between the map tile data and the DEM data of the target area; Calculating the coordinates of a second reference starting point of the target terrain data based on the first affine matrix information and the relative position index; The second affine matrix information is generated based on the coordinates and the first affine matrix information.

16. The method according to claim 1, characterized in that The step of generating a terrain file corresponding to the map tile data based on the target terrain data includes: Acquire a three-dimensional zero matrix and a height matrix corresponding to the target terrain data, wherein the three-dimensional zero matrix and the height matrix have the same number of rows and columns as the target terrain data; Filling the color values ​​corresponding to each position in the three-dimensional zero matrix based on the preset conversion relationship between height and color value and the height matrix to obtain a color matrix; A portable network graphics (PNG) file is generated based on the color matrix, and the PNG file is used as the terrain file.

17. The method according to claim 16, characterized in that The height matrix is ​​obtained by the following formula, including: data = (im_data + 10000) / 0.1 Among them, data represents the height matrix, and im_data represents the target terrain data.

18. A terrain file generating device, characterized in that: The device comprises: A storage module is used to obtain digital elevation model DEM data, cut the DEM data into multiple regional DEM data, and store the multiple regional DEM data in the cloud; An acquisition module, used for acquiring map tile data, determining target area DEM data corresponding to the map tile data from the multiple area DEM data, and reading target terrain data corresponding to the map tile data from the target area DEM data; A generation module is used to generate a terrain file corresponding to the map tile data based on the target terrain data.

19. An electronic device, characterized in that: include: one or more processors; and one or more computer-readable storage media having instructions stored thereon; When the instructions are executed by the one or more processors, the processors are enabled to execute the terrain file generating method according to any one of claims 1 to 17.

20. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the processor is caused to execute the terrain file generation method as claimed in any one of claims 1 to 17.