A method, device, and medium for separating ocean and land in tile maps.

By calculating the intersection of tile maps using vector tiling tools and polygon algorithm libraries, PNG tile maps are generated and displayed in layers, solving the problem of incorrect display of grid data and achieving effective separation of ocean and land and optimal visualization effects.

CN116310181BActive Publication Date: 2026-03-10CHENGDUSCEON TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing technologies for grid data visualization, ocean data is mistakenly displayed on land, resulting in poor visualization effects. Furthermore, increasing grid precision leads to an exponential increase in data volume, impacting user experience.

Method used

Vector tile map services are generated using vector tiling tools, and the intersection areas of the tile maps are calculated using a polygon algorithm library to generate PNG tile maps that only contain land or ocean portions. These maps are then layered and overlaid in the map engine for display.

Benefits of technology

It achieves effective separation of ocean and land, improves visualization, reduces computational load, and enhances running speed and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116310181B_ABST
    Figure CN116310181B_ABST
Patent Text Reader

Abstract

This invention relates to the field of GIS visualization technology and discloses a method for separating land and ocean in tile maps. The method includes the following steps: S1, using a vector tiling tool to slice global coastline data into vector tiles, generating a vector tile map service, and simultaneously establishing a tile map service; S2, obtaining a vector tile map based on the vector tile map service; S3, using a polygon algorithm library to calculate the intersection area between the vector tile map and the tile map at the same tile coordinates, cutting out the land or ocean portion of the tile map, and generating a PNG tile map containing only the land or ocean portion. This invention enables optimal visualization of grid data.
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 visualization, and particularly relates to a tile map ocean-land separation method, device and medium. BACKGROUND

[0002] When visualizing marine data with a map, the most common form is the visualization of longitude-latitude grid data. However, the grid data visualization has a significant disadvantage that the grid precision problem causes a part of data that should cover the ocean surface to appear on land, thereby affecting the visualization effect. When the map is zoomed in to a certain level, the visualization effect of the 0.25-degree grid data of the sea surface temperature obviously invades the land, which is unacceptable to users. Although the method of improving the grid data precision can be used for optimization, the effect is always relatively poor, and improving the grid data precision also causes the grid data volume to grow exponentially, thereby bringing new problems. Therefore, how to successfully separate the tile map ocean-land and make the grid data visualization achieve the best display effect has become a problem to be solved. SUMMARY

[0003] The present application provides a tile map ocean-land separation method, device and medium to solve the above problems.

[0004] The present application is implemented by the following technical solutions:

[0005] A tile map ocean-land separation method, specifically comprising the following steps:

[0006] S1, using a vector slicing tool to slice the global coastline data to generate a vector tile map service, and establishing a tile map service at the same time;

[0007] S2, obtaining a vector tile map according to the vector tile map service;

[0008] S3, using a polygon algorithm library to calculate the intersection area of the vector tile map and the tile map under the same tile coordinate, cutting out the land or ocean part of the tile map, and generating a PNG tile map containing only the land part or the ocean part.

[0009] As an optimization, the specific steps of S1 are as follows:

[0010] S1.1, slicing the global coastline data by using a vector slicing tool to generate vector tile map data;

[0011] S1.2, publishing the vector tile map data as a vector tile map service through nginx;

[0012] S1.3, establishing a tile map service according to actual needs.

[0013] As an optimization, the specific steps of S2 are:

[0014] S2.1, obtain the vector tile map service through the API interface, and the vector tile map service is calibrated according to tile coordinates to obtain a vector tile map;

[0015] S2.2, convert the file format of the vector tile map into a format readable by the polygon algorithm library.

[0016] As an optimization, the specific steps of S3 are:

[0017] S3.1, convert the vector tile map into a polygon A through a vector tile map analysis library and the polygon algorithm library;

[0018] S3.2, convert the tile coordinates in S2.1 into a polygon B through a tile coordinate conversion formula and the polygon algorithm library;

[0019] S3.3, calculate the intersection of the polygon A and the polygon B through the polygon algorithm library to obtain a polygon C;

[0020] S3.4, create a canvas and draw the polygon C on the canvas to obtain a png image about the polygon C;

[0021] S3.5, find a tile map corresponding to the tile coordinates of S2.1 from the tile map service, replace the pixel block with black color in the png image generated by the polygon C with a pixel block of the tile map through a loop of pixel points, obtain a tile map containing only land parts, and finally generate a PNG tile map containing only land parts.

[0022] As an optimization, the specific steps of S3 are:

[0023] S3.1, convert the vector tile map into a polygon A through a vector tile map analysis library and the polygon algorithm library;

[0024] S3.2, convert the tile coordinates in S2.1 into a polygon B through a tile coordinate conversion formula and the polygon algorithm library;

[0025] S3.3, calculate the intersection of the polygon A and the polygon B through the polygon algorithm library to obtain a polygon C;

[0026] S3.4, create a canvas and draw the polygon C on the canvas to obtain a png image about the polygon C;

[0027] S3.5, find the tile map corresponding to the tile coordinates of S2.1 from the tile map service, replace the pixel blocks with transparent color in the png image generated by the polygon C with the pixel blocks of the tile map by looping the pixel points, and set the pixel blocks with black color to 0, finally generate the PNG tile map containing only the ocean part.

[0028] As an optimization, S4, selectively cache the PNG tile map according to the level of the PNG tile map.

[0029] As an optimization, the specific steps of S3.4 are:

[0030] S3.4.1, convert the longitude and latitude coordinates of the top-left corner of the polygon B into screen coordinates by the screen coordinate conversion formula to obtain the minimum screen coordinates P of the tile map min (X min, , Y min );

[0031] S3.4.2, convert one of the current longitude and latitude coordinate points of the polygon C into the first screen coordinates P tmp (X tmp , Y tmp ) by the screen coordinate conversion formula;

[0032] S3.4.3, subtract the minimum screen coordinates from the first screen coordinates P tmp to obtain the second screen coordinates P(X tmp -X min , Y tmp -Y min ) of the current longitude and latitude coordinate points of the polygon C in the tile map;

[0033] S3.4.4, loop S3.4.2-S3.4.3 until all the longitude and latitude coordinate points of the polygon C are converted into screen coordinates to obtain the second screen coordinates P(X tmp -X min , Y tmp -Y min ) of all the longitude and latitude coordinate points of the polygon C in the tile map;

[0034] S3.4.5, create a first picture with the same size as the tile map, and the first picture format is png, then draw all the polygons in the polygon C converted by the screen coordinate conversion in the first picture;

[0035] S3.4.6, fill the closed figure surrounded by all the polygons of the first picture with black color, and finally obtain the png image about the polygon C.

[0036] As optimization, S5, using a map engine, placing the grid data layer to be displayed on the lower layer of the map engine, and placing the matching PNG tile map on the upper layer of the map engine for display, finally realizing the visualization of the separated tile map and the land and sea data, wherein the grid data layer and the matching PNG tile map are different geographical structures.

[0037] The application further discloses an electronic device, including at least one processor, and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the visualization method of the tile map.

[0038] The application further discloses a storage medium storing a computer program, and the computer program is executed by a processor to realize the visualization method of the tile map.

[0039] Compared with the prior art, the application has the following advantages and beneficial effects:

[0040] The application separates the tile map land and sea, and places the meteorological and hydrological element grid data layer on the lower layer and the tile map land layer on the upper layer by the method of layering and superimposing the tile map land layer and the grid data layer, so that the meteorological and hydrological element grid data achieves the best display effect, or places the land meteorological element grid data layer on the bottom layer and the tile map sea layer on the upper layer, so that the land meteorological element grid data achieves the best display effect.

[0041] The application uses a flexible interface, so that the land and sea can be separated regardless of the type of tile map as input, such as satellite map tile map, terrain tile map, electronic chart tile map, etc.

[0042] The application uses an image caching technology, reduces the amount of calculation, improves the running speed, and makes the loading of the tile map by the map engine more fast and smooth. BRIEF DESCRIPTION OF DRAWINGS

[0043] In order to more clearly illustrate the technical scheme of the exemplary embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the application, and therefore should not be considered as a limitation to the scope, and for those skilled in the art, other related drawings can also be obtained without creative labor. In the drawings:

[0044] Figure 1A flow chart of a tile map sea-land separation method according to the present application;

[0045] Figure 2 For Figure 1 The specific implementation method flow chart. Specific embodiments

[0046] In order to make the purpose, technical scheme and advantages of the present application clearer, further detailed description of the present application will be given below in combination with examples and drawings, the schematic embodiments of the present application and the description thereof are only used to explain the present application, and do not limit the present application.

[0047] Example 1 discloses a tile map sea-land separation method, as shown in Figure 1 Specifically comprising the following steps:

[0048] S1, using a vector cutting tool to cut the global coastline data into vectors, generating a vector tile map service, and establishing a tile map service.

[0049] Step 1, vector tile map service and tile map service.

[0050] The present application realizes the separation of tile map sea-land by relying on vector tile map service and tile map service, so the construction of the above services is completed first, and the above tile map services all use WGS84 coordinate system.

[0051] Step 1.1, vector tile map service construction.

[0052] The global coastline geojson data is cut by tippecanoe vector cutting tool to generate vector tile map data;

[0053] The vector tile map data is published as a vector tile map service through nginx;

[0054] Step 1.2, tile map service construction:

[0055] The tile map service includes satellite map, electronic chart, topographic map, etc., which can be constructed by oneself according to the needs, and some tile map services can be directly called by using related service API interface in the Internet.

[0056] S2, obtaining a vector tile map according to the vector tile map service.

[0057] S3, using a polygon algorithm library to calculate the intersection area of the vector tile map and the tile map under the same tile coordinate, cutting out the land or sea part of the tile map, and generating a PNG tile map containing only the land part or the sea part.

[0058] Specifically comprising the following steps:

[0059] Step 2, vector tile map to polygon A.

[0060] Step 2.1, get vector tile map from vector tile map service by tile coordinates.

[0061] The vector tile map service is built through step 1.1, and here the vector tile map is directly obtained through the API interface according to the tile coordinates;

[0062] Step 2.2, parse the vector tile map to get the geojson format vector tile map data through the pbf library and the vector-tile library;

[0063] The file format of the vector tile map is pbf, so the pbf library is used to read the pbf file and the vector-tile library (vector tile map parsing library) is used to convert the pbf file content to geojson format vector tile map data;

[0064] Step 2.3, convert the geojson format vector tile map data to polygon A through the polybool library.

[0065] Since the geojson data type cannot directly use the polygon calculation algorithm in the polybool library, it is necessary to first perform polygon conversion to convert the polygon of the geojson type related to the vector tile map to a polygon that can be used by the polybool library.

[0066] For 0 to 5 level vector tile geojson data, the number of vertices of the polygon with less internal vertices can be appropriately reduced according to the level of the corresponding vector tile map to reduce the calculation amount and improve the polygon intersection operation speed.

[0067] For example, in the 0-5 level vector tile map, the corresponding level can use the following strategy to discard which polygons:

[0068] If it is level 0, 8-vertex polygons can be discarded;

[0069] If it is level 1, 7-vertex polygons can be discarded;

[0070] If it is level 2, 6-vertex polygons can be discarded;

[0071] If it is level 3, 5-vertex polygons can be discarded;

[0072] If it is level 4, 4-vertex polygons can be discarded;

[0073] If it is level 5, 3-vertex polygons can be discarded.

[0074] Step 3: Convert tile coordinates to polygon B.

[0075] Using tile coordinates, the latitude and longitude coordinates of the four vertices of the tile map are calculated using the tile coordinate transformation formula. These coordinates are then converted into polygon B using the polybool library. The tile coordinate transformation formula is shown in Table 1.

[0076] Step 4: Calculate the intersection polygon C of polygons A and B.

[0077] Using the polygon intersection algorithm from the polybool library, polygon C is obtained by calculating the intersection of polygons A and B.

[0078] Step 5: Draw the filled polygon C.

[0079] Step 5.1: Calculate the minimum screen coordinates of the tile map.

[0080] Let the screen coordinates of the top-left corner of the tile map be the minimum screen coordinates of the current tile map. Using the screen coordinate conversion formula, convert the latitude and longitude coordinates of the top-left vertex of polygon B to screen coordinates to obtain the minimum screen coordinates P of the tile map. min (X) min, Y min The screen coordinate transformation formula is shown in Table 2.

[0081] Table 1. Tile Coordinate Transformation Formula

[0082]

[0083] Table 2 Screen coordinate transformation formula

[0084]

[0085] Step 5.2: Convert the latitude and longitude coordinates of the polygon C into the screen coordinates of the current tile map.

[0086] First, using the screen coordinate transformation formula, convert one of the latitude and longitude coordinates of the current polygon C into screen coordinates P. tmp (X) tmp Y tmp Then, subtract the minimum screen coordinate of the tile map from the screen coordinate of one of the latitude and longitude coordinates of the current polygon C. This gives the screen coordinate P(X) of that point on the current tile map. tmp -X min Y tmp -Y min By applying the above method to all points of polygon C, the screen coordinate transformation can be completed.

[0087] Step 5.3: Create a new canvas and draw a filled polygon C.

[0088] Since the tile map size is 256x256, first, a png picture with a size of 256x256 is newly created, and then all the polygons in polygon C converted by screen coordinates are drawn in the newly created png (the polygons A, B, and C described here are all complex polygons, and a complex polygon is a figure composed of n polygons), and the polygon C is drawn by using the polygon drawing method of Java.

[0089] Step 6: Separate tile map land and sea

[0090] First, the tile map corresponding to the tile coordinates is obtained through the tile map service, and since the size of the png image generated by polygon C and the downloaded tile map is both 256x256, only the pixel points need to be replaced, that is, the pixel blocks with black color in the png image generated by polygon C are replaced by the pixel blocks of the tile map, so as to obtain the tile map containing only the land part, or the pixel blocks without color (transparent color) are replaced by the pixel blocks of the tile map and the black pixel blocks are set to 0, so as to obtain the tile map containing only the sea part.

[0091] In the embodiment, S4, selectively caching the PNG tile map according to the level of the PNG tile map, is further included.

[0092] Step 7: Tile map caching

[0093] Since the 0-10 level vector tile map information data volume is relatively large, and the process of calculating the polygon intersection is time-consuming, after the calculation is completed, the tile land map and the tile sea map need to be cached, and generally, the caching is performed to the 10th level. For the vector tile map higher than the 10th level, the calculation speed is similar to the ordinary operation database speed, and therefore, the caching is not needed. The level of the vector tile map is the level of the tile map, and only in this way, the cutting of the tile map corresponding to each level of the vector tile map can be realized.

[0094] Tile map Figure 1Generally, the level is from 0 to tens or twenties, and the number of tile maps corresponding to each level increases exponentially. The level of a tile map is a property of the tile map, and a higher level indicates more detailed information, that is, the level of map zooming in or out. For the low-level tile map cache mentioned in the present application, the low-level vector tile map contains a large amount of geojson data and is time-consuming to calculate, so the calculation result needs to be cached. For example, the 0-level vector tile map involves global coastline geojson data, which takes about 5-10 seconds to calculate the 0-level separated PNG tile map. The cache can be directly taken without further calculation. For high-level vector tile maps, the amount of geojson data involved is small, and direct calculation is similar to database query calculation speed, so caching is not needed.

[0095] In the embodiment, S5, using a map engine, placing the grid data layer to be displayed in the lower layer of the map engine and placing the matching PNG tile map in the upper layer of the map engine for display, finally realizing the visualization of the separated tile map and the marine and land data, wherein the grid data layer and the matching PNG tile map are different geographical structures. The different geographical structures refer to that if the grid data layer is marine latitude and longitude grid data, then the matching PNG tile map is the tile map land layer; if the grid data layer is land latitude and longitude grid data, then the matching PNG tile map is the tile map ocean layer. Such grid data generally refers to hydrological or meteorological data of certain elements, such as temperature, ocean current, PM2.5, etc.

[0096] Step 8: Tile map and data layer display

[0097] When using a leaflet, cesium or other map engine, the grid data layer to be displayed is placed in the lower layer, and then the matching tile map is placed in the upper layer.

[0098] Embodiment 2 further discloses an electronic device comprising at least one processor and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned visualization method of a tile map.

[0099] Embodiment 3 further discloses a storage medium storing a computer program, wherein the computer program is executed by a processor to implement the above-mentioned visualization method of a tile map.

[0100] The above detailed description of the specific embodiments of the present application has been given to understand the purpose, technical solutions and beneficial effects of the present application. It should be understood that the above description is only a specific embodiment of the present application and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method of separating land and sea in a tile map, characterized by, Specifically comprising the following steps: S1, the global coastline data is cut by a vector cutting tool to generate a vector tile map service, and a tile map service is established; S2, a vector tile map is obtained according to the vector tile map service; S3, a polygon algorithm library is used to calculate the intersection area of the vector tile map and the tile map under the same tile coordinates, cut out the land or sea part of the tile map, and generate a PNG tile map containing only the land part or the sea part; The specific steps of S3 are: S3.1, the vector tile map is converted into a polygon A through a vector tile map analysis library and the polygon algorithm library; S3.2, the tile coordinates are converted into a polygon B through a tile coordinate conversion formula and the polygon algorithm library; S3.3, the intersection of the polygon A and the polygon B is calculated through the polygon algorithm library to obtain a polygon C; S3.4, a new canvas is created and the polygon C is drawn on the canvas to obtain a png image about the polygon C; S3.5, the tile map corresponding to the tile coordinates is found from the tile map service, the pixel block with black color in the png image generated by the polygon C is replaced by the pixel block of the tile map through a loop of pixel points, a tile map containing only the land part is obtained, and finally a PNG tile map containing only the land part is generated; the pixel block with transparent color in the png image generated by the polygon C is replaced by the pixel block of the tile map, and the pixel block with black color is set to 0, and finally a PNG tile map containing only the sea part is generated.

2. The method of claim 1, wherein the tile map is a sea-land separation map. The specific steps of S1 are: S1.1, the global coastline data is cut by a vector cutting tool to generate vector tile map data; S1.2, the vector tile map data is published as a vector tile map service through nginx; S1.3, a tile map service is established according to actual needs.

3. The method of claim 1, wherein the method further comprises: The specific steps of S2 are: S2.1, the vector tile map service is obtained through an API interface, and the vector tile map service is calibrated according to tile coordinates to obtain a vector tile map; S2.2, the file format of the vector tile map is converted into a format that can be read by the polygon algorithm library.

4. The method of claim 1, wherein the method further comprises: S4, the PNG tile map is selectively cached according to the level of the PNG tile map.

5. The method of claim 1, wherein the method further comprises: The specific steps of S3.4 are: S3.4.1, convert the longitude and latitude coordinates of the top vertex of the upper left corner of the polygon B into screen coordinates through the screen coordinate conversion formula to obtain the minimum screen coordinates P of the tile map min ; S3.4.2, convert one of the current latitude and longitude coordinate points of the polygon C into a first screen coordinate P through a screen coordinate conversion formula tmp ; S3.4.3、using the first screen coordinate P tmp Subtracting the minimum screen coordinate P min , to obtain the second screen coordinate P of the current latitude and longitude coordinate point of the polygon C in the tile map. S3.4.4, S3.4.2-S3.4.3 are looped until all the latitude and longitude coordinate points of the polygon C are converted into screen coordinates to obtain the second screen coordinates P corresponding to all the latitude and longitude coordinate points of the polygon C on the tile map; S3.4.5, a first picture with the same size as the tile map is newly created, the first picture is in png format, and then all the polygons in the polygon C converted by the screen coordinate conversion are drawn in the first picture; S3.4.6, the closed figure surrounded by all the polygons of the first picture is filled with black color, and finally a png image about the polygon C is obtained.

6. The method of claim 5, further comprising S5, using a map engine, placing the grid data layer to be displayed in a lower layer of the map engine, and placing the matching PNG tile map in an upper layer of the map engine for display, to ultimately achieve visualization of the separated tile map and the land and sea data. The grid data layer and the matched PNG tile map are different geographical structures.

7. An electronic device, comprising: The method comprises at least one processor, and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method for separating ocean and land of a tile map as claimed in claim 6.

8. A storage medium storing a computer program, characterized by The computer program is executed by the processor to implement the method for separating ocean and land of a tile map as claimed in claim 6.

Citation Information

Patent Citations

  • Mass vector data display method and device, electronic equipment and storage medium

    CN114528426A

  • Airborne vector map data processing method

    CN115687675A