A method for drawing plotted graphics, a terminal device, and a storage medium.
By splitting the drawing graphics into the smallest basic primitives and generating the GeoJSON data structure, the problem of restricted usage scenarios in the existing technology is solved, and flexible rendering and generation in multiple map frames is realized, which improves users Experience and development efficiency.
Patent Information
- Application Number
- CN202310654691.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-05
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2043-06-05
AI Technical Summary
The existing map drawing technology limits the use scenarios for drawing graphics, especially the drawing of multi-point graphics requires multiple mouse clicks, which causes inconvenience to users and can only be used in specific map frames.
Split the drawn figure into the smallest basic primitives, and generate the graphic data based on coordinate points and graphic types. Use GeoJSON or TopoJSON data structures to separate the generation and rendering process, suitable for various WebGIS map frameworks.
It realizes flexible generation and rendering of drawing graphics, overcomes the shortcomings that the existing technology can only be used in a specific map, improves development efficiency and convenience, and is suitable for multiple map frameworks.
Smart Images

Figure CN116824104B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of map drawing, and in particular to a method for drawing a plotted graphic, a terminal device and a storage medium. Background Art
[0002] In existing map drawing, it is often necessary to load the plotted graphics into a specific map, such as using OpenLayers for map drawing. Plotted graphics are divided into single-point graphics and multi-point graphics. Single-point graphics only require loading an icon, selecting a specific coordinate, and directly rendering the graphic on the map; while multi-point icons require clicking the mouse on the map multiple times to draw specific graphics according to different plotting types. The diversity of commonly used map types currently limits the use scenarios of plotting, which brings great inconvenience to users. Summary of the invention
[0003] In order to solve the above problems, the present invention proposes a plotting graphics drawing method, a terminal device and a storage medium.
[0004] The specific plan is as follows:
[0005] A method for plotting a graph comprises the following steps:
[0006] S1: Select the plotting graphics to be loaded into the map;
[0007] S2: split the plotted graphics into multiple minimum basic primitives;
[0008] S3: Select multiple coordinate points on the map, use the coordinate points and the graphic types of all the minimum basic primitives after the plotted graphics are split as input parameters, and generate graphic data corresponding to each minimum basic primitive based on the input parameters and the graphic generation algorithm corresponding to each minimum basic primitive; the graphic data includes the coordinate data of each minimum basic primitive;
[0009] S4: Filling the graphic data corresponding to all the minimum basic graphic elements constituting the plotted graphic into the data structure of the plotted graphic drawing data to obtain the plotted graphic drawing data;
[0010] S5: Based on the drawing data of the plotted graphics, the plotted graphics are rendered and drawn through the map frame container.
[0011] Furthermore, the plotted graph is a single-point plotted graph having only one input coordinate point or a multi-point plotted graph having multiple input coordinate points.
[0012] Furthermore, the coordinate data in the graphic data uses longitude and latitude as coordinate units.
[0013] Furthermore, the field names of the input parameters include a graphics type field plotType and an input coordinate point field positions.
[0014] Furthermore, the input coordinate point field positions is stored in an array format, each element in the array corresponds to a coordinate point, and the value of each element is composed of its longitude value and latitude value.
[0015] Furthermore, the data structures of the plotted graphics and drawing data include GeoJSON and TopoJSON.
[0016] A terminal device for plotting and drawing graphics comprises a processor, a memory and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method described above in the embodiment of the present invention are implemented.
[0017] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described above in an embodiment of the present invention are implemented.
[0018] The present invention adopts the above technical solution to separate the generation and rendering of plotted graphics and mouse operation, and can be conveniently applied to various WebGIS map frameworks, thus overcoming the defect that the prior art can only be applied to a specific map. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 Shown is a flow chart of Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0020] To further illustrate various embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementations and advantages of the present invention.
[0021] The present invention will now be further described with reference to the accompanying drawings and specific implementation methods.
[0022] Embodiment 1:
[0023] The present invention provides a method for plotting graphics.
[0024] like Figure 1 As shown, the method comprises the following steps:
[0025] S1: Select the plotting graphic to be loaded into the map.
[0026] Plotted graphics are divided into single-point plotted graphics and multi-point plotted graphics; single-point plotting refers to plotting with only one input coordinate point, usually including various pictures and text annotations with practical significance; multi-point plotting refers to specific plotted graphics generated by multiple input coordinate points. For different multi-point plotted graphics, its input points may be fixed or uncertain (for example, a circle has only two points, and a line segment has at least two points, which are not specific). The method of this embodiment involves a method for drawing plotted graphics, mainly for multi-point plotted graphics.
[0027] S2: Split the plotted graphics into multiple minimum basic primitives.
[0028] The graphic types of the minimum basic primitives include points, circles, triangles, lines, curves, squares, rectangles, ellipses, trapezoids or various irregular graphics. The minimum basic primitives are the basis for various plotting graphics. Various plotting graphics can be generated by splicing basic primitives. The generation of graphics is based on certain rules. For example, two points generate a rectangle. The starting point startPoint is a vertex of the rectangle, and the end point endPoint is another vertex on the diagonal of the starting point startPoint. Two points cannot generate a fixed rectangle, but if the latitude or longitude of the other two vertices of the specified rule is consistent with the first two vertices (that is, the four sides of the rectangle are parallel to the longitude and latitude lines), a fixed rectangle can be generated. The same is true for other basic graphics, but the rules are not fixed and are ultimately determined by the type of plotting graphics selected. Splitting into the minimum primitives can not only be reused in different plotting graphics to improve development efficiency, but also meet the requirements of GeoJSON structure type data storage. Each basic graphic can be filled into the corresponding point, line and surface field attributes in GeoJSON data.
[0029] S3: Select multiple coordinate points on the map, use the coordinate points and the graphic types of all the smallest basic primitives after the plotted graphics are split as input parameters, and generate graphic data corresponding to each smallest basic primitive based on the input parameters and the graphic generation algorithm corresponding to each smallest basic primitive; the graphic data includes the coordinate data of each smallest basic primitive.
[0030] The coordinate point selected on the map can be selected by clicking the map with the mouse. Different map frames have different methods for obtaining coordinate points. This embodiment does not limit the map frame. It is only necessary to pass the obtained coordinate points into the plot generation function generatePlot. The coordinate points are stored in an array, that is, [[lon1,lat1],[lon2,lat2],...], where lon1 represents the longitude value of the first element in the array, lat1 represents the latitude value of the first element in the array, and so on. The specific contents of the input parameters set in this embodiment are as follows:
[0031] Input parameter field name:
[0032] plotType: string, graph type;
[0033] positions: array, input coordinate points;
[0034] options: optional parameters, such as arrow angle, scale length, etc., depending on the type of plotting graph.
[0035] The generatePlot method is a general function for generating plotted graphics. It calls specific types of graphics calculation functions according to plotType, such as generateRectangle. generateRectangle calls the basic primitive generation function rectangle to finally generate point, line and surface data.
[0036] Different minimum basic primitives correspond to different graphics algorithms. The graphics data generated by the graphics algorithm uses longitude and latitude as coordinate units, and the data types include point (Point), line (LineString), polygon (Polygon), etc.
[0037] S4: Filling the graphic data corresponding to all the minimum basic graphic elements constituting the plotted graphic into the data structure of the plotted graphic drawing data to obtain the plotted graphic drawing data.
[0038] All the minimum basic primitives can be assembled to obtain the target plotting graphics. For example, a plotting graphics consists of a circle plus a wavy curve. According to the graphic data type of the minimum basic primitive, the graphic data is filled into the corresponding position of the GeoJSON data structure. For example, if the graphic data is a point type, the data should be filled into the Point position, thereby constructing the drawing data required for drawing the plotting graphics. The following is the filled GeoJSON data structure. There are three types of filled data types: point type Point, line string type LineString, and polygon Polygon, as shown below.
[0039]
[0040]
[0041]
[0042] S5: Based on the drawing data of the plotted graphics, the plotted graphics are rendered and drawn through a map framework.
[0043] Since GeoJSON is a common data structure in GIS, basically different map frameworks can load GeoJSON structure data to render and draw graphics.
[0044] In this embodiment, the drawing data is rendered through the plotting rendering function renderPlot. Since the generated graphics may require various style effects or need to add text, the rendering function renderPlot contains various attribute fields to modify the graphics. The specific contents of the attribute fields are as follows.
[0045] id: unique id of the graphic;
[0046] name: string, graphic name;
[0047] font: string, graphic name character style, same as css style;
[0048] fontSize: string size;
[0049] fontColor: string color;
[0050] fill: Boolean type, whether to display the graphic fill surface;
[0051] color: graphic color;
[0052] outline: Boolean type, whether to display the graphic border;
[0053] outlineColor: graphic border color;
[0054] outlineWidth: the size of the graphic border;
[0055] callback: rendering callback function. Since it is not limited to the map framework, this callback function is provided to each map framework to call its own rendering function to perform the final rendering of the plotted graphics.
[0056] The embodiment of the present invention separates the generation of plotted graphics from rendering and mouse operation, and can be conveniently applied to various WebGIS map frameworks, overcoming the defect that the prior art can only be applied to a specific map (such as OpenLayers). In actual applications, the map mouse operation provides input parameters, and the plotted graphics data of the GeoJSON structure is finally generated through the previous steps. As for how the map mouse is operated and how the plotted graphics are rendered, it is completely determined by the type of map framework. Therefore, it can be widely applied to different map frameworks, realizing the convenience of sharing multiple maps in one plotting library.
[0057] Taking Cesium as an example, the mouse operation uses the ScreenSpaceEventHandler method to register mouse events, and obtains the input parameter positions longitude and latitude coordinates through the callback function. Pass in the input parameters positions and the graphics type plotType, and the plotting graphics generation function createPlot generates the GeoJSON structure data of the graphics. The createPlot function contains various plotting graphics generation algorithms. Cesium loads GeoJSON data GeoJsonDataSource.load, and then renders the graphics through the method viewer.dataSources.add. If you need to modify the graphics properties, such as color, you can set the corresponding attribute fields.
[0058] In addition, although this embodiment is applied to WebGIS, it is mainly aimed at browser clients, and the implementation process of the technical solution is implemented using Javascript, but the same concept is also applicable to the client, and the method of this embodiment can also be used in different client frameworks, such as QT, .net, etc. At the same time, the generated data format is GeoJSON, but the TopoJSON data format can also be used, so the TopoJSON format solution is also within the protection scope of this patent.
[0059] In this embodiment, various plotting graphics are first defined, and each plotting corresponds to a graphic. The plotting graphics are generated by combining the basic graphic structures of points, lines, and surfaces. When plotting, control points are generated by mouse operation, and then the relevant graphic generation algorithm is used according to the type of plotting graphics to generate plotting graphics containing various basic graphic structures of points, lines, and surfaces. This embodiment uses the GeoJSON format to store the plotting graphics data, and the data can be rendered and displayed in different map frames.
[0060] This embodiment is implemented based on Web page technology, using JavaScript or TypeScript development language, not limited to GIS map engine frameworks such as Cesium, OpenLayers, etc., using GeoJSON as the data storage format, and does not need to rely on background services. Development, deployment and application are very simple.
[0061] Embodiment 2:
[0062] The present invention also provides a terminal device for plotting graphics, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above method embodiment of embodiment 1 of the present invention when executing the computer program.
[0063] Further, as an executable solution, the plotting and drawing terminal device can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The plotting and drawing terminal device can include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the composition structure of the above-mentioned plotting and drawing terminal device is only an example of the plotting and drawing terminal device, and does not constitute a limitation on the plotting and drawing terminal device. It can include more or less components than the above, or combine certain components, or different components. For example, the plotting and drawing terminal device can also include input and output devices, network access devices, buses, etc., and the embodiments of the present invention do not limit this.
[0064] Further, as an executable solution, the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the plotting and drawing terminal device, and uses various interfaces and lines to connect various parts of the entire plotting and drawing terminal device.
[0065] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the plotting and drawing terminal device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system and an application required for at least one function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0066] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above method in the embodiment of the present invention are implemented.
[0067] If the module / unit integrated in the plotting graphics drawing terminal device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory) and software distribution medium, etc.
[0068] Although the present invention has been specifically shown and described in conjunction with the preferred embodiments, it should be understood by those skilled in the art that various changes may be made to the present invention in form and details without departing from the spirit and scope of the present invention as defined by the appended claims, all of which are within the scope of protection of the present invention.
Claims
1. A method for plotting a graph, It is characterized in that The following steps are involved: S1: Select the plotting graphics to be loaded into the map; S2: split the plotted graphics into multiple minimum basic primitives; S3: Select multiple coordinate points on the map, use the coordinate points and the graphic types of all the minimum basic graphic elements after the plotted graphics are split as input parameters, and generate graphic data corresponding to each minimum basic graphic element based on the input parameters and the graphic generation algorithm corresponding to each minimum basic graphic element; Graphics data includes coordinate data of each minimum basic graphic element; S4: Filling the graphic data corresponding to all the minimum basic graphic elements constituting the plotted graphic into the data structure of the plotted graphic drawing data to obtain the drawing data of the plotted graphic; the data structure of the plotted graphic drawing data includes GeoJSON and TopoJSON; S5: Based on the drawing data of the plotted graphics, the plotted graphics are rendered and drawn through the map frame container.
2. The method for plotting a graph according to claim 1, Features: The plotted graph is a single-point plotted graph having only one input coordinate point or a multi-point plotted graph having multiple input coordinate points.
3. The plotting method according to claim 1, Features: The coordinate data in the graphic data uses longitude and latitude as coordinate units.
4. The plotting method according to claim 1, Features: The field names of the input parameters include the graphics type field plotType and the input coordinate point field positions.
5. The method for plotting a graph according to claim 4, Features: The input coordinate point field positions is stored in an array. Each element in the array corresponds to a coordinate point, and the value of each element consists of its longitude and latitude values.
6. A terminal device for plotting graphics, Features: The method comprises a processor, a memory and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any one of the methods of claims 1 to 5 when executing the computer program.
7. A computer-readable storage medium storing a computer program, Features: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
