CN111966876A - Method for generating disaster map at fixed time based on NodeJs - Google Patents
Method for generating disaster map at fixed time based on NodeJs Download PDFInfo
- Publication number
- CN111966876A CN111966876A CN202010762703.3A CN202010762703A CN111966876A CN 111966876 A CN111966876 A CN 111966876A CN 202010762703 A CN202010762703 A CN 202010762703A CN 111966876 A CN111966876 A CN 111966876A
- Authority
- CN
- China
- Prior art keywords
- task
- picture
- disaster
- map
- canvas
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 16
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 claims description 8
- 230000009286 beneficial effect Effects 0.000 abstract description 3
- 238000009877 rendering Methods 0.000 description 4
- 230000002265 prevention Effects 0.000 description 2
- 230000000694 effects Effects 0.000 description 1
- 230000008676 import Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/907—Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
- G06F16/909—Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using geographical or spatial information, e.g. location
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Library & Information Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Alarm Systems (AREA)
- Processing Or Creating Images (AREA)
Abstract
The invention relates to a method for generating disaster maps at regular time based on NodeJs, which comprises the following steps: a built-in timer generates a special task at regular time; meanwhile, receiving an external request, judging whether the picture exists or not, if so, returning the disaster picture to the request, and otherwise, creating a custom task; transmitting all tasks into a task scheduling queue, and processing according to the priority; the main thread creates a sub-thread for each task, starts a headless browser in the sub-thread and creates a map canvas, and zooms the map to a task-designated level; reading related data in a database, drawing a picture and loading the picture on canvas; reading a relevant basic layer from a file system and loading the basic layer onto canvas; reading a relevant online service layer from an online map service and loading the relevant online service layer onto a canvas; intercepting a task map area to generate a disaster picture; saving the disaster picture to a file system; and returning the disaster picture to an external request. The method is beneficial to providing disaster pictures for users, has low requirements on user networks and equipment, and is easy to operate and use.
Description
Technical Field
The invention belongs to the technical field of flood prevention informatization, and particularly relates to a method for generating disaster maps at regular time based on NodeJs.
Background
In the field of flood prevention, if the map of the disaster change at different moments such as water conditions, rain conditions, flood conditions and the like can be rapidly manufactured, stored, released and displayed in real time, the situation of the disaster can be more accurately judged, and the public can know the development of the disaster in time.
At present, the real-time display of flood, rain and water conditions systems of each province is realized after data is processed at a web end, the requirements of the rendering mode on network performance and equipment performance are high, the rendering speed cannot be guaranteed under the condition of overlarge data amount, and the page is blocked or crashed when the disaster changes fast and the refresh rate is high. In addition, if a real-time disaster change map needs to be presented to the public, manual screenshots or additional renderings of the map are also needed.
In order to solve the problem of image rendering failure of equipment with poor performance, a disaster picture can be generated in advance from real-time data on a server, and then an imaged picture is returned to access equipment.
Disclosure of Invention
The invention aims to provide a method for generating disaster maps at regular time based on NodeJs, which is beneficial to providing disaster pictures for users, has low requirements on user networks and equipment, and is easy to operate and use.
The technical scheme adopted by the invention is as follows: a method for generating disaster maps at regular time based on NodeJs comprises the following steps:
1) a timer arranged in the system is used for automatically generating a special task at regular time; meanwhile, the system monitors an external request, if the external request for requesting the disaster picture is received, whether the picture exists is judged, if yes, the required disaster picture is taken out from the file system and returned to the external request, and if not, a self-defined task is created;
2) all the picture generation tasks are transmitted into a task scheduling queue, and each task is processed according to the task priority;
3) the main thread creates a sub-thread for each task, starts a headless browser in the sub-thread, creates a map canvas, zooms the map to a task designated level, and prepares to draw the map; reading longitude and latitude inflection point data of a task related area in a database and corresponding real-time data thereof, drawing a graph and loading the graph onto canvas; reading a task related basic layer from a file system, and loading the layer on canvas; reading a task-related online service layer from an online map service, and loading the layer onto canvas;
4) after all the image layers are loaded, intercepting a task image area to generate a disaster picture;
5) saving the disaster picture to a file system according to the task type and the generation time so as to read the disaster picture for the next time;
6) and if the task type is an external request, returning the generated disaster picture to the external request.
Further, in step 1, a plurality of timers are built in the system, and include a rain condition map task generation timer, a water condition map task generation timer and a flood condition map task generation timer, and the special tasks automatically generated at regular time correspondingly include a rain condition picture generation task, a water condition picture generation task and a flood condition picture generation task.
Further, in step 2, in all the picture generation tasks, the processing priority of the custom task is higher than that of the thematic task.
Further, in step 3, the main thread creates a Node word thread sub-thread for each task.
Further, in step 3, a map canvas is created using a LEAFLETjs library.
Further, in the step 4, the html2canvas is used to intercept the task map area.
Compared with the prior art, the invention has the following beneficial effects: the method utilizes the characteristics of NodeJs such as high concurrency, multithreading and the like to support the presetting of a plurality of timing generation tasks and external import tasks and improve the plotting efficiency. In addition to consuming server computing resources when generating the picture for the first time, for a later request, only the generated picture needs to be read and returned to the access party, so that the network bandwidth of the user is consumed little, and no performance requirement is basically required on the user access equipment. In addition, the picture is generated at the server side by adopting NodeJs, so that the manual screenshot misoperation can be avoided, and the limit of the limited manual screenshot area can be broken through. Therefore, the invention has strong practicability and wide application prospect.
Drawings
FIG. 1 is a flow chart of a method implementation of an embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the figures and the embodiments.
The invention provides a method for generating disaster maps at regular time based on NodeJs, which comprises the following steps as shown in figure 1:
1) a timer arranged in the system is used for automatically generating a special task at regular time; meanwhile, the system monitors an external request, if the external request requesting the disaster picture is received, whether the picture exists is judged, if yes, the required disaster picture is taken out from the file system and returned to the external request, and if not, a custom task is created.
In this embodiment, the system is provided with a plurality of timers, including a rain condition map task generation timer, a water condition map task generation timer and a flood condition map task generation timer, and the special tasks automatically generated at regular time correspondingly include a rain condition picture generation task, a water condition picture generation task and a flood condition picture generation task.
2) And transmitting all the picture generation tasks into a task scheduling queue, and processing each task according to the task priority.
Because the user who initiates the external request generally has higher urgency for the needs of the disaster pictures, the processing priority of the custom task is higher than that of the thematic task in all the picture generation tasks.
3) The main thread creates a Node word thread sub-thread for each task, starts a headless browser in the sub-thread, creates a map canvas by using a leafletjs library, then zooms the map to a task specified level, and prepares to draw the map; reading longitude and latitude inflection point data of a task related area in a database and corresponding real-time data thereof, drawing a graph and loading the graph onto canvas; reading a task related basic layer from a file system, and loading the layer on canvas; and reading a task related online service layer from the online map service, and loading the layer onto a canvas.
4) And after all the layers are loaded, intercepting the task graph area by using html2canvas to generate a disaster picture.
5) And saving the disaster picture to a file system according to the task type and the generation time so as to read the disaster picture next time.
6) And if the task type is an external request, returning the generated disaster picture to the external request.
The above are preferred embodiments of the present invention, and all changes made according to the technical scheme of the present invention that produce functional effects do not exceed the scope of the technical scheme of the present invention belong to the protection scope of the present invention.
Claims (6)
1. A method for generating disaster maps at regular time based on NodeJs is characterized by comprising the following steps:
1) a timer arranged in the system is used for automatically generating a special task at regular time; meanwhile, the system monitors an external request, if the external request for requesting the disaster picture is received, whether the picture exists is judged, if yes, the required disaster picture is taken out from the file system and returned to the external request, and if not, a self-defined task is created;
2) all the picture generation tasks are transmitted into a task scheduling queue, and each task is processed according to the task priority;
3) the main thread creates a sub-thread for each task, starts a headless browser in the sub-thread, creates a map canvas, zooms the map to a task designated level, and prepares to draw the map; reading longitude and latitude inflection point data of a task related area in a database and corresponding real-time data thereof, drawing a graph and loading the graph onto canvas; reading a task related basic layer from a file system, and loading the layer on canvas; reading a task-related online service layer from an online map service, and loading the layer onto canvas;
4) after all the image layers are loaded, intercepting a task image area to generate a disaster picture;
5) saving the disaster picture to a file system according to the task type and the generation time so as to read the disaster picture for the next time;
6) and if the task type is an external request, returning the generated disaster picture to the external request.
2. The method for generating the disaster map at regular time based on the NodeJs as claimed in claim 1, wherein in step 1, a plurality of timers are arranged in the system, the timers comprise a rain condition map task generation timer, a water condition map task generation timer and a flood condition map task generation timer, and the special tasks automatically generated at regular time correspondingly comprise a rain condition picture generation task, a water condition picture generation task and a flood condition picture generation task.
3. The method for generating disaster maps at regular time based on NodeJs as claimed in claim 1, wherein in step 2, the processing priority of the custom task is higher than that of the thematic task in all the picture generation tasks.
4. The method of claim 1, wherein in step 3, the main thread creates a Node work _ thread sub-thread for each task.
5. The method of claim 1, wherein in step 3, a map canvas is created using a leafletjs library.
6. The method of claim 1, wherein in step 4, task graph areas are intercepted using html2 canvas.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010762703.3A CN111966876A (en) | 2020-07-31 | 2020-07-31 | Method for generating disaster map at fixed time based on NodeJs |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010762703.3A CN111966876A (en) | 2020-07-31 | 2020-07-31 | Method for generating disaster map at fixed time based on NodeJs |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111966876A true CN111966876A (en) | 2020-11-20 |
Family
ID=73364173
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010762703.3A Pending CN111966876A (en) | 2020-07-31 | 2020-07-31 | Method for generating disaster map at fixed time based on NodeJs |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111966876A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115469959A (en) * | 2022-11-11 | 2022-12-13 | 成都摹客科技有限公司 | Page rendering method, rendering device and computer storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2013041088A (en) * | 2011-08-15 | 2013-02-28 | Nec Corp | Map data providing system, server, and map data providing method |
CN103177577A (en) * | 2011-12-26 | 2013-06-26 | 北京掌城科技有限公司 | Dynamic traffic information service providing method based on map layer overlapping |
CN107480211A (en) * | 2017-07-26 | 2017-12-15 | 南京邮电大学 | A kind of implementation method for issuing quality of road construction information map automatically based on GeoServer |
CN108600373A (en) * | 2018-04-26 | 2018-09-28 | 广州沐思信息科技有限公司 | A kind of Picture Generation Method, server and computer readable storage medium |
CN110990515A (en) * | 2019-12-05 | 2020-04-10 | 中国南方电网有限责任公司 | Power grid graph browsing method, system, device, computer equipment and storage medium |
-
2020
- 2020-07-31 CN CN202010762703.3A patent/CN111966876A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2013041088A (en) * | 2011-08-15 | 2013-02-28 | Nec Corp | Map data providing system, server, and map data providing method |
CN103177577A (en) * | 2011-12-26 | 2013-06-26 | 北京掌城科技有限公司 | Dynamic traffic information service providing method based on map layer overlapping |
CN107480211A (en) * | 2017-07-26 | 2017-12-15 | 南京邮电大学 | A kind of implementation method for issuing quality of road construction information map automatically based on GeoServer |
CN108600373A (en) * | 2018-04-26 | 2018-09-28 | 广州沐思信息科技有限公司 | A kind of Picture Generation Method, server and computer readable storage medium |
CN110990515A (en) * | 2019-12-05 | 2020-04-10 | 中国南方电网有限责任公司 | Power grid graph browsing method, system, device, computer equipment and storage medium |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115469959A (en) * | 2022-11-11 | 2022-12-13 | 成都摹客科技有限公司 | Page rendering method, rendering device and computer storage medium |
CN115469959B (en) * | 2022-11-11 | 2023-01-31 | 成都摹客科技有限公司 | Page rendering method, rendering device and computer storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11755452B2 (en) | Log data collection method based on log data generated by container in application container environment, log data collection device, storage medium, and log data collection system | |
US10454855B2 (en) | System and method for predicting availability status changes of instant messenger users | |
CN111385129A (en) | Globalization content auditing method and device, computer equipment and storage medium | |
CN112511580B (en) | Message pushing method, device, storage medium and equipment | |
CN109117244B (en) | Method for implementing virtual machine resource application queuing mechanism | |
WO2021184724A1 (en) | Method and apparatus and device for automatically adjusting timing backup operation initiation time, and medium | |
CN112333282A (en) | Service providing method, device, medium and electronic equipment based on hybrid cloud | |
CN105404547A (en) | Fusion method and device of operating system | |
US20170083387A1 (en) | High-performance computing framework for cloud computing environments | |
CN115757611A (en) | Big data cluster switching method and device, electronic equipment and storage medium | |
CN110532060B (en) | Hybrid network environment data acquisition method and system | |
CN111966876A (en) | Method for generating disaster map at fixed time based on NodeJs | |
CN104158833A (en) | Method for constructing intelligent desktop system | |
CN112667180B (en) | Service data display method and device, computer equipment and storage medium | |
CN113806097A (en) | Data processing method and device, electronic equipment and storage medium | |
CN110955504B (en) | Method, server, system and storage medium for intelligently distributing rendering tasks | |
CN102882709A (en) | Monitoring system and monitoring method in cloud computing environment | |
CN113961323B (en) | Hybrid cloud-oriented security perception task scheduling method and system | |
CN111192339B (en) | Geographic position data rendering method and device | |
CN114201508A (en) | Data processing method, data processing apparatus, electronic device, and storage medium | |
CN113763552A (en) | Three-dimensional geographic model display method and device, computer equipment and storage medium | |
CN112491974A (en) | Remote browsing method and device, storage medium, terminal equipment and server | |
CN114637566B (en) | Method, device, equipment and storage medium for publishing multimedia resources | |
CN114185682B (en) | Log output method and device, electronic equipment and storage medium | |
CN104158835A (en) | Method for intelligent desktop system server to control clients |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |