Disclosure of Invention
In view of this, embodiments of the present invention provide an isobar drawing method, an apparatus, an electronic device, and a computer-readable storage medium, so as to solve the problems of low accuracy, long time consumption, and large computation amount in an isobar drawing process in the prior art.
Therefore, the embodiment of the invention provides the following technical scheme:
in a first aspect of the present invention, a method for drawing isobars is provided, including:
step 101: dividing an area to be drawn with isobars into a plurality of rectangular grids;
step 102: acquiring the air pressure value of the vertex of the rectangular grid;
step 103: screening the rectangular grids to be drawn with the isobaric line segments from the rectangular grids according to the air pressure values of the vertexes of the rectangular grids, and drawing the isobaric line segments in the rectangular grids to be drawn with the isobaric line segments;
step 104: acquiring an unmarked isobaric line segment as a current isobaric line and marking the current isobaric line segment as occupied, and executing the step 105 and the step 107;
step 105: judging whether an unmarked isobaric line segment matched with the left end point of the current isobaric line exists in eight rectangular grids adjacent to a first appointed rectangular grid, wherein the first appointed rectangular grid is the rectangular grid where the left end point of the current isobaric line is located;
step 106: if the judgment result in the step 105 is yes, inserting the isobaric line segment matched with the left end point of the current isobaric line into the current isobaric line, marking the segment as occupied, and returning to the step 105;
step 107: judging whether an unmarked isobaric line segment matched with the right end point of the current isobaric line exists in eight rectangular grids adjacent to a second specified rectangular grid, wherein the second specified rectangular grid is the rectangular grid where the right end point of the current isobaric line is located;
step 108: if the judgment result in the step 107 is yes, inserting the isobaric line segment matched with the right end point of the current isobaric line into the current isobaric line, marking the segment as occupied, and returning to the step 107;
step 109: when the judgment results of the step 105 and the step 107 are both negative, judging whether the isobar segments are both marked, and when the judgment results are negative, returning to the step 104;
step 110: if the determination result in step 109 is yes, the drawing is ended.
Further, step 103 comprises:
dividing the vertexes of the rectangular grid into two types, wherein one type is the vertex with the air pressure value smaller than a set threshold value, and the other type is the vertex with the air pressure value larger than the set threshold value;
determining the end points of the isobaric line segments on the edges where two adjacent and classified different vertexes are located; the smaller the difference value between the vertex and the set threshold value is, the closer the distance between the vertex and the endpoint is;
and connecting the end points of the isobaric line segments in the rectangular lattices to form the isobaric line segments.
Further, the coordinates of the end points of the isobar segments are
Where thres is a set threshold, (x0, y0) is a coordinate value of a vertex whose air pressure value is greater than the set threshold, val0 is an air pressure value of a vertex whose air pressure value is greater than the set threshold, (x1, y1) is a coordinate value of a vertex whose air pressure value is less than the set threshold, and val1 is an air pressure value of a vertex whose air pressure value is less than the set threshold.
Further, when the judgment results of step 105 and step 107 are both negative, the method further comprises:
judging whether the left end point and the right end point of the current isobaric line are overlapped or not to obtain a third judgment result;
if the third judgment result is yes, the current isobaric line is a closed isobaric line;
and if the third judgment result is negative, the current isobaric line is a non-closed isobaric line.
Further, when the determination result in step 109 is yes, the method further includes:
and deleting the isobars with the length less than the preset value.
In a second aspect of the present invention, there is provided an isobar drawing device, including:
the dividing module is used for dividing the area of the isobaric line to be drawn into a plurality of rectangular grids;
the first acquisition module is used for acquiring the air pressure value of the vertex of the rectangular grid;
the drawing module is used for screening the rectangular grids of the isobaric line segments to be drawn from the rectangular grids according to the air pressure values of the vertexes of the rectangular grids and drawing the isobaric line segments in the rectangular grids of the isobaric line segments to be drawn;
the second acquisition module is used for acquiring the unmarked isobaric line segment as the current isobaric line and marking the current isobaric line segment as occupied;
the first judgment module is used for judging whether an unmarked isobaric line segment matched with the left end point of the current isobaric line exists in eight rectangular grids adjacent to a first specified rectangular grid, wherein the first specified rectangular grid is the rectangular grid where the left end point of the current isobaric line is located;
the first inserting module is used for inserting the isobaric line segment matched with the left end point of the current isobaric line into the current isobaric line and marking the segment as occupied when the judgment result of the first judging module is yes, and returning to the first judging module;
the second judgment module is used for judging whether an unmarked isobaric line segment matched with the right end point of the current isobaric line exists in eight rectangular lattices adjacent to a second specified rectangular lattice, and the second specified rectangular lattice is the rectangular lattice where the right end point of the current isobaric line is located;
the second inserting module is used for inserting the isobaric line segment matched with the right end point of the current isobaric line into the current isobaric line and marking the segment as occupied when the judgment result of the second judging module is yes, and returning to the second judging module;
the third judging module is used for judging whether the isobaric line segments are marked or not when the judging results of the first judging module and the second judging module are both negative, and returning to the second obtaining module when the judging results are negative;
and the control module is used for finishing drawing when the judgment result of the third judgment module is yes.
Further, the rendering module includes:
the classification unit is used for classifying the vertexes of the rectangular grids into two types, wherein one type is the vertex with the air pressure value smaller than a set threshold value, and the other type is the vertex with the air pressure value larger than the set threshold value;
the computing unit is used for determining the end points of the isobaric line segments on the edges where two adjacent vertexes which are different in classification are located; the smaller the difference value between the vertex and the set threshold value is, the closer the distance between the vertex and the endpoint is;
and the drawing unit is used for connecting the end points of the isobaric line segments in the rectangular grids to form the isobaric line segments.
Further, the computing unit is also used for marking the coordinates of the end points of the isobar segments as the coordinates
Where thres is a set threshold, (x0, y0) is a coordinate value of a vertex whose air pressure value is greater than the set threshold, val0 is an air pressure value of a vertex whose air pressure value is greater than the set threshold, (x1, y1) is a coordinate value of a vertex whose air pressure value is less than the set threshold, and val1 is an air pressure value of a vertex whose air pressure value is less than the set threshold.
In a third aspect of the present invention, there is provided an electronic device comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor to cause the at least one processor to perform the isobar drawing method according to any one of the first aspect of the present invention.
In a fourth aspect of the present invention, there is provided a computer-readable storage medium having stored thereon computer instructions, wherein the instructions, when executed by a processor, implement the isobar drawing method according to any one of the first aspect of the present invention.
The technical scheme of the embodiment of the invention has the following advantages:
the embodiment of the invention provides an isobaric line drawing method, an isobaric line drawing device, electronic equipment and a computer readable storage medium. According to the method, the rectangular lattices are divided firstly, the isobaric line segments are drawn according to the vertexes of the rectangular lattices, and finally the isobaric line segments are connected into the isobaric line, so that the drawing difficulty of the isobaric line is reduced, and the calculated amount is reduced. The isobars in the rectangular grids can be grown at the left end and the right end simultaneously, and the speed of drawing the isobars is improved.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the description of the present application, it is to be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like indicate orientations or positional relationships based on those shown in the drawings, and are used merely for convenience of description and for simplicity of description, and do not indicate or imply that the referenced device or element must have a particular orientation, be constructed in a particular orientation, and be operated, and thus should not be considered as limiting the present application. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more features. In the description of the present application, "a plurality" means two or more unless specifically limited otherwise.
In this application, the word "exemplary" is used to mean "serving as an example, instance, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. The following description is presented to enable any person skilled in the art to make and use the application. In the following description, details are set forth for the purpose of explanation. It will be apparent to one of ordinary skill in the art that the present application may be practiced without these specific details. In other instances, well-known structures and processes are not set forth in detail in order to avoid obscuring the description of the present application with unnecessary detail. Thus, the present application is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
In accordance with an embodiment of the present invention, there is provided an isobar drawing method embodiment, it is noted that the steps illustrated in the flowchart of the figure may be performed in a computer system, such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
In this embodiment, a method for drawing isobars is provided, which may be used in an environment monitoring system, and the like, and fig. 1 is a flowchart of the method for drawing isobars according to the embodiment of the present invention, as shown in fig. 1, the process includes the following steps:
step S101: and dividing the area to be drawn with the isobars into a plurality of rectangular grids. In this embodiment, the rectangular grids may be selected as rectangles or squares having the same shape.
Step S102: and acquiring the air pressure value of the vertex of the rectangular grid. In this embodiment, the coordinates and the air pressure data of the multiple weather monitoring stations may be obtained first, the coordinates of the vertex of the rectangular grid may be obtained, and the air pressure value of the vertex of the rectangular grid may be calculated by an interpolation method.
Step S103: and screening out the rectangular lattices to be drawn with the isobaric line segments from the rectangular lattices according to the air pressure values at the vertexes of the rectangular lattices, and drawing the isobaric line segments in the rectangular lattices to be drawn with the isobaric line segments. In this embodiment, the vertices of the rectangular grid may be divided into two types, one type is a vertex whose air pressure value is smaller than a set threshold, and the other type is a vertex whose air pressure value is greater than the set threshold. And the rectangular lattices comprising the two types of vertexes are rectangular lattices to be drawn into isobaric line segments. And in the rectangular grid of the isobaric line segment to be drawn, taking the points on the edges where two adjacent and classified different vertexes are located as the end points of the isobaric line segment. And connecting the endpoints of the isobaric line segments in the rectangular lattices in a non-crossed manner to form the isobaric line segments. FIG. 2 is a schematic diagram of an isobar segment according to an embodiment of the invention. As shown in fig. 2, the middle point of the edge where two adjacent and classified different vertices are located may be selected as the end point of the isobar segment. And connecting the endpoints of the isobaric line segments in the rectangular lattices in a non-crossed manner to form the isobaric line segments. In the figure, the solid points are the peaks where the air pressure value is higher than the set threshold value, and the hollow points are the peaks where the air pressure value is lower than the set threshold value.
Step S104: acquiring an unmarked isobar segment as the current isobar and marking the segment as occupied, and executing the step S105 and the step S107. Preferably, step S105 and step S107 are performed simultaneously. In this embodiment, one end of the current isobar is the left end, and the other end is the right end. Left-end growth and right-end growth were performed simultaneously.
Step S105: and judging whether an unmarked isobaric line segment matched with the left end point of the current isobaric line exists in eight rectangular grids adjacent to the first appointed rectangular grid, wherein the first appointed rectangular grid is the rectangular grid where the left end point of the current isobaric line is located. In this embodiment, one end of the isobar segment in the rectangular lattice is overlapped with the left end point of the current isobar, and then the isobar segment is matched with the left end point of the current isobar.
Step S106: if the judgment result in the step S105 is yes, inserting the isobaric line segment matched with the left end point of the current isobaric line into the current isobaric line, marking the segment as occupied, and returning to the step S105; in this embodiment, the left end point of the inserted isobar segment replaces the original left end point to become the left end point of the current isobar.
Step S107: and judging whether an unmarked isobaric line segment matched with the right end point of the current isobaric line exists in eight rectangular grids adjacent to the second specified rectangular grid, wherein the second specified rectangular grid is the rectangular grid where the right end point of the current isobaric line is located. In this embodiment, one end of the isobar segment in the rectangular lattice coincides with the right end point of the current isobar, and then the isobar segment matches with the right end point of the current isobar.
Step S108: if the judgment result in the step S107 is yes, the isobaric segment matched with the right end point of the current isobaric is inserted into the current isobaric and marked as occupied, and the step S107 is returned. In this embodiment, the right end point of the inserted isobar segment replaces the original right end point to become the right end point of the current isobar.
Step S109: when the judgment results of the step S105 and the step S107 are both negative, judging whether the isobar segments are all marked, and if the judgment results are negative, returning to the step S104;
step S110: if the determination result in step S109 is yes, the drawing is ended.
In this embodiment, before finishing the drawing, deleting the isobars with the length smaller than the preset value.
According to the embodiment of the invention, the rectangular grids are divided firstly, the isobaric line segments are drawn according to the vertexes of the rectangular grids, and finally the isobaric line segments are connected into the isobaric line, so that the drawing difficulty of the isobaric line is reduced, and the calculated amount is reduced. The isobars in the rectangular grids can be grown at the left end and the right end simultaneously, and the speed of drawing the isobars is improved. Compared with the conventional irregular triangular mesh drawing method, the method saves a large amount of labor and time, has high accuracy and improves the drawing efficiency.
To ensure the accuracy of the air pressure data, in an alternative embodiment, step 103 includes: the vertexes of the rectangular grid are divided into two types, wherein one type is the vertex with the air pressure value smaller than the set threshold value, and the other type is the vertex with the air pressure value larger than the set threshold value. In this embodiment, the setting threshold is set according to actual requirements. Determining the end points of the isobaric line segments on the edges where two adjacent and classified different vertexes are located; the smaller the difference value between the vertex and the set threshold value is, the closer the distance between the vertex and the endpoint is; and connecting the end points of the isobaric line segments in the rectangular grids to form the isobaric line segments. In this embodiment, the isobar segments may be selected as straight lines or arcs.
In one embodiment, the coordinates of the endpoints of the isobar segments are
Where thres is a set threshold, (x0, y0) is a coordinate value of a vertex whose air pressure value is greater than the set threshold, val0 is an air pressure value of a vertex whose air pressure value is greater than the set threshold, (x1, y1) is a coordinate value of a vertex whose air pressure value is less than the set threshold, and val1 is an air pressure value of a vertex whose air pressure value is less than the set threshold.
Compared with the method of taking the middle point of the side where the adjacent and classified vertexes are located as the end point of the isobaric segment, the isobaric drawing method of the embodiment determines the position of the end point of the isobaric segment according to the difference value between the air pressure value of the adjacent vertex and the set threshold, the isobaric end point is closer to the actual value, and the accuracy of the isobaric is obviously improved.
In an optional embodiment, when the determination results in step 105 and step 107 are both no, the method further includes: judging whether the left end point and the right end point of the current isobaric line are overlapped or not to obtain a third judgment result; if the third judgment result is yes, the current isobaric line is a closed isobaric line; and if the third judgment result is negative, the current isobaric line is a non-closed isobaric line.
In this embodiment, an isobar drawing device is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and the description of the device is omitted for brevity. As used hereinafter, the term "module" is a combination of software and/or hardware that can implement a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
The present embodiment provides an isobar drawing device, including:
the dividing module 301 is configured to divide an area where an isobaric line is to be drawn into a plurality of rectangular grids;
a first obtaining module 302, configured to obtain an air pressure value at a vertex of the rectangular lattice;
the drawing module 303 is configured to screen out a rectangular lattice of the isobaric line segment to be drawn from the rectangular lattice according to the air pressure value at the vertex of the rectangular lattice, and draw the isobaric line segment in the rectangular lattice of the isobaric line segment to be drawn;
a second obtaining module 304, configured to obtain an unmarked isobar segment as a current isobar and mark the current isobar segment as occupied;
a first judging module 305, configured to judge whether an unmarked isobaric segment matching the left end point of the current isobaric exists in eight rectangular lattices adjacent to a first specified rectangular lattice, where the first specified rectangular lattice is a rectangular lattice in which the left end point of the current isobaric is located;
a first inserting module 306, configured to insert, when the determination result of the first determining module 305 is yes, the isobar segment matched with the left end point of the current isobar into the current isobar, mark the current isobar as occupied, and return to the first determining module 305;
a second judging module 307, configured to judge whether an unmarked isobaric line segment matching the right end point of the current isobaric line exists in eight rectangular lattices adjacent to a second specified rectangular lattice, where the second specified rectangular lattice is a rectangular lattice in which the right end point of the current isobaric line is located;
a second inserting module 308, configured to insert, when the determination result of the second determining module 307 is yes, the isobar segment matched with the right end point of the current isobar into the current isobar, mark the current isobar as occupied, and return to the second determining module 307;
a third judging module 309, configured to judge whether the isobar segments are both marked when the judgment results of the first judging module 305 and the second judging module 307 are both negative, and return to the second obtaining module 304 when the judgment results are negative;
and a control module 310, configured to end the drawing when the determination result of the third determining module 309 is yes.
The drawing module 303 includes:
the classification unit is used for classifying the vertexes of the rectangular grids into two types, wherein one type is the vertex with the air pressure value smaller than a set threshold value, and the other type is the vertex with the air pressure value larger than the set threshold value;
the computing unit is used for determining the end points of the isobaric line segments on the edges where two adjacent vertexes which are different in classification are located; the smaller the difference value between the vertex and the set threshold value is, the closer the distance between the vertex and the endpoint is;
and the drawing unit is used for connecting the end points of the isobaric line segments in the rectangular grids to form the isobaric line segments.
The computing unit is further configured to mark coordinates of end points of the isobar segments as
Where thres is a set threshold, (x0, y0) is a coordinate value of a vertex whose air pressure value is greater than the set threshold, val0 is an air pressure value of a vertex whose air pressure value is greater than the set threshold, (x1, y1) is a coordinate value of a vertex whose air pressure value is less than the set threshold, and val1 is an air pressure value of a vertex whose air pressure value is less than the set threshold.
The isobar rendering device in this embodiment is presented in the form of functional units, where a unit refers to an ASIC circuit, a processor and memory executing one or more software or fixed programs, and/or other devices that may provide the above-described functionality.
Further functional descriptions of the modules are the same as those of the corresponding embodiments, and are not repeated herein.
An embodiment of the present invention further provides an electronic device, which includes the isobaric drawing device shown in fig. 3.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an alternative embodiment of the present invention, and as shown in fig. 4, the terminal may include: at least one processor 401, such as a CPU (Central Processing Unit), at least one communication interface 403, memory 404, and at least one communication bus 402. Wherein a communication bus 402 is used to enable connective communication between these components. The communication interface 403 may include a Display (Display) and a Keyboard (Keyboard), and the optional communication interface 403 may also include a standard wired interface and a standard wireless interface. The Memory 404 may be a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The memory 404 may optionally be at least one memory device located remotely from the processor 401. Wherein the processor 401 may be combined with the apparatus described in fig. 3, an application program is stored in the memory 404, and the processor 401 calls the program code stored in the memory 404 for executing any of the above-mentioned isobar drawing methods.
The communication bus 402 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus 402 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 4, but this does not indicate only one bus or one type of bus.
The memory 404 may include a volatile memory (RAM), such as a random-access memory (RAM); the memory may also include a non-volatile memory (english: non-volatile memory), such as a flash memory (english: flash memory), a hard disk (english: hard disk drive, abbreviated: HDD) or a solid-state drive (english: SSD); the memory 404 may also comprise a combination of memories of the kind described above.
The processor 401 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of a CPU and an NP.
The processor 401 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Optionally, the memory 404 is also used to store program instructions. The processor 401 may call program instructions to implement the isobar drawing method as shown in the embodiment of fig. 1 of the present application.
The embodiment of the invention also provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the isobaric line drawing method in any method embodiment. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, abbreviated as HDD) or a Solid State Drive (SSD), etc.; the storage medium may also comprise a combination of memories of the kind described above.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.