Universal programming implementation method and device for generating terrain analysis report as doc document

By calling the function library to create the HTML main document when generating the terrain analysis report, dynamically generate delimiters and intelligently control empty lines, the complexity and cross-platform problems of generating doc documents in the existing technology are solved, and a simple and easy-to-use doc document generation method is realized.

CN120491949APending Publication Date: 2025-08-15CHINESE PEOPLES LIBERATION ARMY UNIT 61540 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510590343.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing technology methods for generating doc documents have steep learning curves, difficulty in maintenance, complex development environment configuration, poor cross-platformity and security issues, especially when using open source libraries, commercial libraries, and Microsoft Office automation.

Method used

By calling pre-configured general functions in the function library, create the HTML main document corresponding to the terrain analysis results, and encode the HTML main document and image content, dynamically generate delimiters and intelligently control the number of blank lines, and generate a terrain analysis report in the doc document format recognized by the office software.

Benefits of technology

It realizes good cross-platform support, few dependencies, simple development environment configuration, easy generation and debugging, and dynamically generates delimiters and intelligently controls blank lines, improving the readability and parsing accuracy of the terrain analysis report in the doc document format.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120491949A_ABST
    Figure CN120491949A_ABST
Patent Text Reader

Abstract

The invention provides a universal programming implementation method and device for generating a terrain analysis report as a doc document. The method comprises the following steps: acquiring a terrain analysis result to be processed; calling a general function pre-configured in a function library, and creating an HTML main document corresponding to the terrain analysis result; the method comprises the following steps: encoding an HTML main document and image contents to obtain a document character string and an image character string, integrating the document character string and the image character string, dynamically generating a demarcation symbol and intelligently controlling the number of inserted empty lines in the integration process to obtain an identifiable file of office software; and the office software analyzes the recognizable file to obtain the terrain analysis report in the doc document format. The method has the advantages of good cross-platform support, few dependent libraries, simple development environment configuration, easiness in generation and debugging and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer programming, and in particular to a general programming implementation method and device for generating a terrain analysis report as a doc document. Background Art

[0002] Currently, doc documents can be generated using a variety of programming languages and tools. Common methods include using open source libraries, commercial libraries, and Microsoft Office automation. These methods have the following issues:

[0003] (1) The main problems with using open source libraries are as follows: The learning curve is relatively steep: The API is relatively complex, and beginners need time to familiarize themselves with it before they can master the usage skills; Difficult to maintain: It usually requires multiple dependent libraries. Taking LibreOffice as an example, it is necessary to install LibreOffice and related dependent libraries, which increases the complexity and build time of the project and is not conducive to project maintenance; The development environment configuration is complex and integration and adaptation are difficult: For the existing terrain analysis process, the development environment configuration is complex, especially on different operating systems. Integration and adaptation are difficult. Common open source libraries are generally based on Python or Java. If they are integrated into programs developed using C++, they need to use technologies such as middle layers and service layers, which increases the complexity of the project.

[0004] (2) The main problems with using commercial libraries are as follows: the need to purchase a license, which is costly; the need to install multiple libraries and dependencies; commercial libraries often only provide secondary development packages, and the source code cannot be obtained. Subsequent upgrades require further solutions to upgrade adaptation issues.

[0005] (3) The main problems with using Microsoft Office automation are as follows: dependence on Microsoft Office: generating doc format documents must be run in an environment where Microsoft Office is installed; poor cross-platform capability: usually it can only be run on Windows; security issues: enabling macros will bring security risks. Summary of the Invention

[0006] In view of this, the purpose of the present invention is to provide a general programming implementation method and device for generating a terrain analysis report as a doc document, which has the advantages of good cross-platform support, few dependent libraries, simple development environment configuration, and easy generation and debugging.

[0007] In a first aspect, the present invention provides a general programming implementation method for generating a terrain analysis report as a doc document, comprising:

[0008] Obtain terrain analysis results to be processed;

[0009] Call the pre-configured general function in the function library to create the HTML main document corresponding to the terrain analysis results. The content described in the HTML main document includes the storage path of each text content and each image content in the terrain analysis results. The image content is stored in the path of the directory with the same name as the HTML main document;

[0010] The HTML main document and image content are encoded to obtain document strings and image strings, which are then integrated. Delimiters are dynamically generated during the integration process, and the number of inserted blank lines is intelligently controlled to obtain a recognizable file for office software, so that the office software can parse the recognizable file to obtain a terrain analysis report in the doc document format.

[0011] In one embodiment, the delimiter is used to identify the boundary between the document string and the image string; the delimiter is dynamically generated during the integration process, including:

[0012] generating a feature string based on key parameters corresponding to the terrain analysis result, where the key parameters include one or more of a geographic coordinate range, an analysis timestamp, and a terrain data type;

[0013] Merge the feature string and the document string, and use a cryptographic hash function to generate a unique hash value for the merged string;

[0014] Extract a string of the specified length from the unique hash value and combine the extracted string with the structured prefix to generate a delimiter.

[0015] In one embodiment, after dynamically generating the delimiter during the integration process, the method further includes:

[0016] Detect delimiter conflicts based on document strings and image strings;

[0017] If the delimiter fails to pass the conflict detection, the delimiter is adaptively adjusted;

[0018] Continue to perform conflict detection on the adaptively adjusted delimiter based on the document string and the image string until the adaptively adjusted delimiter passes the conflict detection.

[0019] In one embodiment, conflict detection of delimiters is performed based on document strings and image strings, including:

[0020] Detect the overlap rate between the character string contained in the delimiter and the document string and image string;

[0021] If the overlap rate is greater than a preset overlap rate threshold, it is determined that there is a conflict between the delimiter and the document character string or the image character string, and the delimiter fails the conflict detection.

[0022] In one embodiment, adaptively adjusting the delimiter includes:

[0023] Append one or more specified characters to the end of the delimiter to obtain an adaptively adjusted delimiter.

[0024] In one embodiment, the number of blank rows inserted during the integration process is intelligently controlled, including:

[0025] During the integration process, context awareness is performed on the content category of the current string to be integrated and its corresponding previous string, so as to determine the number of blank lines between the current string and the previous string based on the content category of the current string and the content category of the previous string, and insert blank lines between the current string and the previous string according to the number of blank lines.

[0026] In one embodiment, a pre-configured general function in a function library is called to create an HTML main document corresponding to the terrain analysis result, including:

[0027] Call the document creation function in the function library to generate a blank HTML main document;

[0028] Call the property setting function in the function library to set the page properties of the blank HTML main document;

[0029] Calling the format setting function in the function library to set the content format of the blank HTML main document, so as to write each text content in the terrain analysis result into the blank HTML main document according to the content format;

[0030] Call the image adding function in the function library to write the storage path of each image content stored in the directory with the same name as the HTML main document into the HTML main document.

[0031] In a second aspect, the present invention further provides a general programming implementation device for generating a terrain analysis report as a doc document, comprising:

[0032] A result acquisition module is used to obtain the terrain analysis results to be processed;

[0033] The document creation module is used to call the pre-configured general functions in the function library to create an HTML main document corresponding to the terrain analysis results. The content described in the HTML main document includes the storage path of each text content and each image content in the terrain analysis results. The image content is stored in the path of the directory with the same name as the HTML main document;

[0034] The document encoding module is used to encode the HTML main document and image content to obtain document strings and image strings, integrate the document strings and image strings, and dynamically generate delimiters and intelligently control the number of inserted blank lines during the integration process to obtain a recognizable file for office software, so that the office software can parse the recognizable file to obtain a terrain analysis report in the doc document format.

[0035] In a third aspect, the present invention further provides a terminal comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement any one of the methods provided in the first aspect.

[0036] In a fourth aspect, the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement any one of the methods provided in the first aspect.

[0037] The present invention provides a general programming implementation method and device for generating a terrain analysis report in the form of a doc document. The method first obtains a terrain analysis result to be processed; then calls a general function pre-configured in a function library to create an HTML main document corresponding to the terrain analysis result. The content described in the HTML main document includes the storage path of each text content and each image content in the terrain analysis result. The image content is stored in a directory with the same name as the HTML main document. Finally, the HTML main document and the image content are encoded to obtain a document string and an image string. The document string and the image string are integrated. During the integration process, delimiters are dynamically generated and the number of blank lines inserted is intelligently controlled to obtain a file recognizable by office software, so that the office software parses the recognizable file to obtain a terrain analysis report in the doc document format. The above method creates an HTML main document corresponding to the terrain analysis results, and encodes and integrates the HTML main document and image content to obtain a file that can be recognized by office software, thereby generating a terrain analysis report in the doc document format. The present invention has the advantages of good cross-platform support, few dependent libraries, simple development environment configuration, easy generation and debugging, etc. In addition, by dynamically generating delimiters, the entire process can have strong domain relevance and uniqueness. By intelligently controlling the number of inserted blank lines, it can effectively avoid parsing errors caused by fixed blank lines and other problems, and also help to improve the readability of the terrain analysis report in the doc document format.

[0038] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or understood by practicing the present invention. The objectives and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0039] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the specific embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0041] Figure 1 A flowchart of generating a doc document using C# is provided in an embodiment of the present invention;

[0042] Figure 2 A flowchart of a general programming implementation method for generating a terrain analysis report as a doc document provided by an embodiment of the present invention;

[0043] Figure 3 A technical framework diagram of a general programming implementation method for generating a terrain analysis report as a doc document provided by an embodiment of the present invention;

[0044] Figure 4 A flowchart of saving multiple files as doc documents provided by an embodiment of the present invention;

[0045] Figure 5 A schematic diagram of the structure of a general programming implementation device for generating a terrain analysis report as a doc document provided by an embodiment of the present invention;

[0046] Figure 6 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0048] Currently, doc documents can be generated using a variety of programming languages and tools. The following are some common methods:

[0049] (1) Use open source libraries. There are three common methods for generating doc documents through open source libraries:

[0050] Use the python-docx library implemented in Python. python-docx is a popular Python library for creating, modifying, and reading doc files.

[0051] Use the SDK provided by LibreOffice. The LibreOffice SDK is a development toolkit provided by LibreOffice that supports multiple programming languages (such as Java, C++, Python, etc.) for generating and operating Office documents.

[0052] (2) Use commercial libraries. There are two common methods for using commercial libraries to generate doc documents:

[0053] Use the Aspose.Words library. Aspose.Words supports multiple programming languages (such as .NET, Java, and C++), is powerful, and is suitable for enterprise-level applications.

[0054] Use Syncfusion DOCIO. Syncfusion DOCIO provides a rich API to create and edit doc files and supports multiple platforms.

[0055] (3) Use Microsoft Office Automation. There are two main methods for using Microsoft Office Automation to generate doc documents:

[0056] Use VBA to write macros to automate tasks and control document creation and editing. VBA is a built-in programming language in Microsoft Office that allows users to write macros to automate tasks. With VBA, you can write scripts directly within Office applications to control document creation and editing.

[0057] COM Interop technology is used to call the Word object model to create and edit doc files. COM Interop (Component Object Model Interoperability) is a technology provided by the Microsoft.NET framework that is used to achieve interoperability between .NET applications and COM (Component Object Model)-based technologies. COM is a standard for building software components and is mainly used in various applications on the Windows platform, especially Microsoft Office applications. Through COM Interop, you can write code in C# or VB.NET to call the Word object model to create and edit doc files, such as Figure 1 The flowchart shown is a method of generating a doc document using C#, including steps such as starting a Word application, creating a new document, adding a title, adding a paragraph, adding a picture, saving the document, closing the document, and exiting the Word application.

[0058] However, the main problems with using open source libraries are: a steep learning curve, difficulty in maintenance, complex development environment configuration, and difficulty in integration and adaptation; the main problems with using commercial libraries are: high cost, the need to install multiple libraries and dependencies, and the need to resolve upgrade and adaptation issues; the main problems with using Microsoft Office automation are: dependence on Microsoft Office, poor cross-platform performance, and security issues.

[0059] Based on this, the present invention provides a general programming implementation method and device for generating a terrain analysis report as a doc document, which has the advantages of good cross-platform support, few library dependencies, simple development environment configuration, and easy generation and debugging.

[0060] To facilitate understanding of this embodiment, firstly, a general programming implementation method for generating a terrain analysis report as a doc document disclosed in an embodiment of the present invention is described in detail. Figure 2 The flowchart of a general programming implementation method for generating a terrain analysis report as a doc document is shown. The method mainly includes the following steps S202 to S206:

[0061] Step S202: Obtain terrain analysis results to be processed.

[0062] Among them, the terrain analysis results may include the analysis conclusions and visualization pictures of the analysis results of the landform analysis within the selected range, the analysis conclusions and visualization pictures of the analysis results of the residential areas within the selected range, the analysis conclusions and visualization pictures of the analysis results of the water and land within the selected range, and the analysis conclusions and visualization pictures of the analysis results of the road traffic within the selected range.

[0063] Step S204: calling a pre-configured general function in the function library to create an HTML main document corresponding to the terrain analysis result.

[0064] The content described in the HTML main document includes the storage path for each text content and each image content within the terrain analysis results. The image content is stored in a directory with the same name as the HTML main document. In one example, a blank HTML main document is first created; then the text content within the terrain analysis results is added to the HTML main document; and finally, the storage path for the image content within the terrain analysis results is added to the HTML main document.

[0065] Step S206, encode the HTML main document and image content to obtain a document string and an image string, integrate the document string and the image string, and dynamically generate delimiters and intelligently control the number of inserted blank lines during the integration process to obtain a recognizable file for office software, so that the office software can parse the recognizable file to obtain a terrain analysis report in the doc document format.

[0066] Among them, dynamically generating delimiters refers to generating delimiters based on key parameters of terrain analysis results (such as geographic coordinate range, analysis timestamp and terrain data type, etc.) and the character string obtained by encoding the HTML main document. The delimiters are used to identify the boundaries between document strings and image strings; intelligently controlling the number of inserted blank lines refers to sensing the content types of the current string (document string or image string) and the previous string (document string or image string), and intelligently determining the number of blank lines to be inserted between the current string and the previous string according to the content type.

[0067] In one example, the HTML main document and image content can be Base64 encoded to obtain a document string and an image string. The document string and the image string are then concatenated, and delimiters and blank lines are inserted in the process of concatenating the two strings to obtain a file recognizable by office software. The office software parses the recognizable file to obtain a terrain analysis report in the doc document format.

[0068] The embodiment of the present invention provides a general programming implementation method for generating a terrain analysis report as a doc document. By creating an HTML main document corresponding to the terrain analysis results, and encoding and integrating the HTML main document and image content, a file that can be recognized by office software is obtained, thereby generating a terrain analysis report in the doc document format. The embodiment of the present invention has the advantages of good cross-platform support, few dependent libraries, simple development environment configuration, easy generation and debugging, etc. In addition, by dynamically generating delimiters, the entire process can have strong domain relevance and uniqueness. By intelligently controlling the number of inserted blank lines, it can effectively avoid parsing errors caused by fixed blank lines and other problems, and also helps to improve the readability of the terrain analysis report in the doc document format.

[0069] In the study of generating terrain analysis reports, the process from starting terrain analysis to achieving the generation of terrain analysis reports can be divided into the following steps: (1) loading vector and elevation data; (2) selecting the terrain analysis range; (3) using the terrain analysis algorithm to perform landform analysis on the selected range, and obtaining the analysis conclusions and visualization images of the landform analysis results within the selected range; (4) using the terrain analysis algorithm to perform residential area analysis on the selected range, and obtaining the analysis conclusions and visualization images of the residential area analysis results within the selected range; (5) using the terrain analysis algorithm to perform water and land analysis on the selected range, and obtaining the analysis conclusions and visualization images of the water and land analysis results within the selected range; (6) using the terrain analysis algorithm to perform road traffic analysis on the selected range, and obtaining the analysis conclusions and visualization images of the road traffic analysis results within the selected range; (7) integrating the analysis conclusions and analysis results in (3) to (6) to form a comprehensive conclusion for the range. (8) automatically generating a terrain analysis report that can be easily viewed and edited by users by organizing the comprehensive conclusions in (7) and the analysis results in (3) to (6), including the analysis conclusions and visualization images.

[0070] The embodiment of the invention mainly focuses on the above-mentioned (eight) process of automatically generating a terrain analysis report by organizing the analysis conclusions and visualization pictures in a certain form. Based on the project application scenario, the following requirements are imposed on the method for generating the terrain analysis report: (1) Automatically generated by the program, after generating the analysis conclusions and visualization pictures, the report can be generated with one click through the "Generate Report" button, avoiding the tedious operation of manually copying text and pictures to write a word document. (2) Support cross-platform, terrain analysis reports can be generated on both Windows and Linux platforms. (3) Easy to integrate, the provided API interface can support the use of C++ calls, and introduce as few other dependent libraries as possible. (4) The implementation method should be as simple, universal, and easy to use as possible, and can be called in different terrain analysis steps to realize report generation. (5) Do not use commercial libraries to avoid additional expenses such as copyright licenses.

[0071] On this basis, the embodiment of the present invention provides an implementation method of a general programming method for generating a terrain analysis report as a doc document, see Figure 3 The technical framework diagram of a general programming implementation method for generating a terrain analysis report as a doc document includes the following core steps:

[0072] Step 1: Create an HTML document as the main document to store the content of the terrain analysis report.

[0073] Step 2: Add text to the terrain analysis report. First, store the text generated during the terrain analysis process in an HTML document. Then, use specific HTML elements to set the font, size, color, and other characteristics of the text, dividing it into different headings and paragraphs. Finally, generate the main document that constitutes the terrain analysis report in HTML format.

[0074] Step 3: Add visualization images of the terrain analysis results to the terrain analysis report. First, store the visualization images generated during the terrain analysis process in the same directory as the HTML document as a separate file. Then, store them as a link to the main document.

[0075] Step 4: Organize the HTML and image files in memory. Load the HTML main document and individual images into memory as files, then encode the contents of these files using Base64. During the file organization process, use delimiters that can be parsed by Word to demarcate the file boundaries.

[0076] Step 5: Export the contents of the file in memory to a .doc file. Save the contents in memory that have been organized in doc format into a file with the suffix .doc. This file is the terrain analysis report that contains the terrain analysis conclusions and visualization results. Users can use common Office Word software or other document editing software to open, view and edit it.

[0077] For ease of understanding, the embodiment of the present invention further explains in more detail the general programming implementation method for generating a terrain analysis report as a doc document:

[0078] Step 1: Call the document creation function in the function library to generate a blank HTML main document.

[0079] In the generated HTML master document, set the basic properties for generating a terrain analysis report. To enable Word to recognize it, the HTML tags in the HTML master document need to have the following properties set. The property content must strictly follow the writing rules below.

[0080] ...

[0082]

[0083] Generating a terrain analysis report can be encapsulated into a general function for easy access by programmers. In this invention, it is encapsulated as int createReport(QString strReportPath, QString strReportName); the parameter strReportPath is used to store the storage path of the generated report file, and the parameter strReportName is used to store the file name of the generated report file. The return value indicates whether the document was created successfully. The implementation of this function can refer to the content organization of the HTML main document described above.

[0084] Step 2: Call the property setting function in the function library to set the page properties of the blank HTML main document.

[0085] You can use the @page element to set the page properties of a document. Where size is the paper size, such as A4 or B5. margin is the document margin. mso-page-orientation is the paper orientation, either portrait or landscape. The following example shows how to do this:

[0086]

[0087]

[0088] Based on this, the page settings for terrain analysis reports can be encapsulated into a universal function for easy call by report generators. In this embodiment, this function is encapsulated as int setReportPageSize(floatwidth, floatheight, intpageOrientation); the width parameter is the paper width, the height parameter is the paper height, and the pageOrientation parameter is the paper orientation. The return value indicates whether the document property settings were successful. The function implementation is organized similarly to the HTML content format described above.

[0089] Step 3: Call the format setting function in the function library to set the content format of the blank HTML main document, so as to write each text content in the terrain analysis result into the blank HTML main document according to the content format.

[0090] Standard HTML elements are used to format the contents of a terrain analysis report. Word accepts most standard HTML and CSS features, such as headings (h1, h2, h3...), lists (ul, li), tables, and colors. Based on this, different functions can be designed for adding titles and analysis content in a terrain analysis report and inserted into the main HTML document. In the embodiment of the present invention, the method for adding a title is encapsulated as int setReportTitle(QString strReportTitle, intLevel), where the parameter strReportTitle is the report title, the parameter Level is the display font size level for the report title, and the return value is whether the setting was successful. In the present invention, the method for adding general textual analysis conclusions is encapsulated as int addReportParagraph(QString strReportParagraph, int iLevel=3, Alignmentalignment=AlignLeft), where the parameter strReportParagraph is the analysis conclusion to be set, the parameter iLevel is the display font size level for the text, which defaults to size 4, the parameter alignment is the alignment of the text content, which defaults to left alignment, and the return value is whether the setting was successful. The implementation of the function is organized with reference to the HTML content format described above.

[0091] Step 4: Call the image adding function in the function library to write the storage path of each image content stored in the directory with the same name as the HTML main document into the HTML main document.

[0092] Using HTML The tag is added to the HTML main document. The method of adding pictures to the terrain analysis report is encapsulated into int addReportImg(QString strImgPath, QString strImgName, ImageType imgType=png, Alignment alignment=AlignHcenter) in the embodiment of the present invention. The parameter strImgPath is the storage path of the terrain analysis result picture, the parameter strImgName is the picture name, the parameter imgType is the picture type, the default is the picture in png format, the parameter alignment is the alignment of the picture, the default is center alignment, and the return value is the result of whether the setting is successful. When implementing the function, you first need to copy the picture to the path of the directory with the same name as the generated HTML main document. If there is no directory with the same name, you need to create the directory. After the copy is completed, this path needs to be inserted into the main document as a link.

[0093] Step 5: Save the document as a doc document.

[0094] After creating the HTML main document, setting the title, adding terrain analysis content, and adding terrain analysis result images, you need to package the HTML main document, images, and other contents into a single .doc file. Taking the above document as an example, after the above steps, its organization is as follows:

[0095] Html2Doc.html: The main HTML document containing the title and content.

[0096] Html2Doc_files / hdq2025.png: One of the included images.

[0097] Html2Doc_files / ftq2025.png: One of the included images.

[0098] Read the above organization files into memory one by one and store them into doc files in Base64 encoding format. The main steps are as follows:

[0099] (I) Delimiters are needed to separate two documents where they connect. To ensure the uniqueness of the delimiters and their deep integration with the terrain analysis data, the present invention proposes a method for dynamically generating delimiters. The specific implementation steps are as follows:

[0100] (II) generating a feature string based on key parameters corresponding to the terrain analysis result, where the key parameters include one or more of a geographic coordinate range, an analysis timestamp, and a terrain data type.

[0101] In one example, a feature string is generated based on the key parameters of the terrain analysis results, including the geographic coordinate range (such as latitude and longitude boundaries, encoded in Base64), the analysis timestamp (accurate to milliseconds), the terrain data type (such as elevation, slope, and fill and cut volume), etc. Finally, the geographic coordinate range is converted into a Base64 string and concatenated with the timestamp and analysis type to form a feature string.

[0102] (I-II) Merge the feature string and the document string, and use a cryptographic hash function to generate a unique hash value for the merged string.

[0103] In one example, the signature string is merged with the document string of the main HTML document, and a unique hash value is generated using the SHA-256 hash algorithm. The SHA-256 hash algorithm is a cryptographic hash function that converts input data into a fixed-length string. This unique string is unique, and even slight changes in the input data will result in a completely different hash value. This ensures that hash values generated by different analysis tasks are unique, improving the uniqueness of the delimiter. To shorten the length, the first 12 hexadecimal characters are truncated as the identifier.

[0104] (I-III) A character string of a specified length is truncated from the unique hash value, and the truncated character string is combined with the structured prefix to generate a delimiter.

[0105] In one example, the first 12 hexadecimal characters of the unique hash value are truncated as part of the delimiter and combined with the structured prefix to generate a delimiter that complies with the MIME standard. For example, the format is ---=_NextPart_TERRAIN_[hash value], where the prefix ---= is the MIME standard start character, TERRAIN indicates domain relevance, and [hash value] is the unique identifier generated by (I-II). This format is compatible with the parsing rules of software such as Word and WPS.

[0106] (I-IV) Conflict detection and adaptive adjustment, including:

[0107] (a) Conflict detection is performed on the delimiter based on the document string and the image string. Specifically, the overlap ratio between the character string contained in the delimiter and the document string and the image string is detected. If the overlap ratio is greater than a preset overlap ratio threshold, it is determined that the delimiter conflicts with the document string and the image string, and the delimiter fails the conflict detection.

[0108] (b) If the delimiter fails the conflict detection, the delimiter is adaptively adjusted. Specifically, one or more specified characters are appended to the end of the delimiter to obtain an adaptively adjusted delimiter.

[0109] (c) Continuing to perform conflict detection on the adaptively adjusted delimiter based on the document character string and the image character string until the adaptively adjusted delimiter passes the conflict detection.

[0110] In an embodiment of the present invention, after the delimiter is generated, it is necessary to detect whether it is repeated with existing characters in the HTML content or image binary data. String matching technology can be used to perform a string search to determine whether the delimiter appears as ordinary text. If there is a conflict, an increasing serial number is appended to the end of the original delimiter (such as the initial delimiter is a delimiter generated based on a hash value---=_NextPart_TERRAIN_AB123, and a new delimiter can be generated by appending an underscore and an increasing serial number (such as _1, _2) to the end of the initial delimiter. ---=_NextPart_TERRAIN_AB123_1) until the conflict is eliminated. This process is performed automatically without manual intervention.

[0111] (II) When two files are joined, special attention should be paid to the delimiters and blank lines before and after the boundary. Not adding or adding too few blank lines may cause parsing errors in software such as Word. To this end, the present invention proposes an intelligent blank line management method. The specific implementation steps are as follows:

[0112] During the integration process, context awareness is performed on the content category of the current string to be integrated and its corresponding previous string, so as to determine the number of blank lines between the current string and the previous string based on the content category of the current string and the content category of the previous string, and insert blank lines between the current string and the previous string according to the number of blank lines.

[0113] This embodiment of the present invention uses context-aware blank line insertion rules to dynamically adjust the number of blank lines based on the type of surrounding content. Two blank lines are inserted between text and images to ensure compatibility with Word parsing. One blank line is inserted between images to reduce redundancy.

[0114] Furthermore, the embodiment of the present invention also supports cross-platform blank line format standardization, uniformly uses \r\n as line break characters, and is compatible with Windows / Linux systems.

[0115] Furthermore, embodiments of the present invention also support fault tolerance mechanisms and format self-repair. Among them, delimiter format automatic verification verifies whether the delimiter format conforms to the MIME standard (such as starting and ending with --) when generating documents. Missing blank lines are dynamically supplemented. If blank lines are detected before and after the delimiter, they are automatically supplemented.

[0116] Furthermore, embodiments of the present invention also support cross-platform compatibility optimization. Delimiters and blank line specifications are unified. Delimiter and blank line processing rules for mainstream software (Word, WPS, and LibreOffice) are experimentally verified (see Table 1), and a unified format is established. A universal delimiter template (e.g., ----=_NextPart_TERRAIN_[HASH]) is designed to meet multi-platform requirements; the number of blank lines inserted dynamically adapts to different software.

[0117] Table 1 Mainstream software delimiter and blank line processing rules

[0118] software Delimiter requirements Blank line requirement Microsoft Word Starts with -- and has a length of ≤70 characters At least 1 blank line WPS Any character is allowed, recommended to include = Strictly 2 blank lines required LibreOffice Must contain _ and = No strict requirements

[0119] (III) Before a file is read into memory, a description of the file contents needs to be added, including the file location, file encoding format, and file type.

[0120] In the embodiment of the present invention, the method for saving multiple documents in a terrain analysis report into a single document is encapsulated into intaddFile2Mhtml(QString filePathAndName, QString fileType). The first parameter is the file address and name to be encoded, such as D:\file\terrain analysis report\terrain analysis report.html. The second parameter is the file type, such as text / html, image / png, image / jpg. The return value is the result of whether the setting is successful.

[0121] Finally, save the Base64-encoded string content as a file with a .doc suffix. To this end, you can design a function that saves the string content as a doc document: int saveFile2Mhtml(QString strReportName). The parameter is the name with a suffix to save the terrain analysis report, such as terrain analysis report.doc. The return value is whether the save is successful. Figure 4 The flowchart shown is for saving multiple files as doc documents, including: reading in the file save name; obtaining the Base64-encoded string strData for storing documents and pictures; calling the intelligent blank line management method to add blank lines; calling the generate delimiter method to add delimiters; using QFile to open the file; using QTextStream to write strData to the opened file; closing the file, etc.

[0122] In summary, the core points of the general programming implementation method for generating a terrain analysis report as a doc document provided by the embodiment of the present invention are:

[0123] (1) Generate the main document containing the text content required for the terrain analysis report using HTML standard elements.

[0124] (2) Dynamically generate unique delimiter technology.

[0125] (2.1) Strong Domain Correlation and Uniqueness. Delimiter generation is directly tied to terrain analysis data features (such as geographic coordinates and analysis data), ensuring that delimiters for different analysis tasks are naturally unique. A composite hash (terrain features + document content) is used to reduce collision probability, and a 12-bit hash value can support up to 2^48 unique combinations.

[0126] (2.2) Dynamic conflict avoidance mechanism. Real-time detection of the presence of delimiters in document content and image data; automatic addition of sequence numbers to resolve conflicts without manual intervention.

[0127] (2.3) Cross-platform compatibility. Uses standard hashing algorithms (SHA-256) and pure string operations, without relying on platform-specific libraries; the delimiter format strictly follows the MIME standard to ensure compatibility with Word, WPS, LibreOffice, and other software.

[0128] (3) Intelligent empty row management strategy:

[0129] (3.1) Context-aware blank line insertion rules to avoid parsing errors caused by fixed blank lines; optimize document size and improve readability.

[0130] (3.2) Standardize the blank line format to resolve cross-platform line break differences (such as \n in Linux and \r\n in Windows); ensure that generated documents render consistently across various Office software.

[0131] (3.3) Fault-tolerance and formatting self-repair automatically correct formatting errors (e.g., missing dashes), preventing Word parsing failures caused by formatting errors. Dynamically fills in missing blank lines, improving document generation robustness and compatibility with parsers that have strict blank line requirements (e.g., older versions of LibreOffice).

[0132] (3.4) Cross-platform compatibility optimization, design a universal delimiter template (such as ----=_NextPart_TERRAIN_[HASH]) to meet multi-platform requirements; dynamically insert the number of blank lines to adapt to different software.

[0133] On this basis, the general programming implementation method for generating a terrain analysis report as a doc document provided by the embodiment of the present invention has at least the following characteristics:

[0134] (1) Good cross-platform support. Using the same set of code, it is not dependent on a specific operating system and can be compiled on different platforms (such as Windows and Linux) to generate doc format documents without making any changes.

[0135] (2) It relies on few libraries. It only relies on QtCore, a core library of Qt, when packaging the main document and image files. The toBase64 function in this library is used for document and image encoding. Specifically, the terrain analysis method of the present invention is implemented in C++, using the Qt interface framework. The newly added terrain analysis report generation method has no other dependent libraries, and the provided API interface is also implemented in C++. It only requires a header file and a dynamic library to be integrated into the existing terrain analysis function implementation.

[0136] (3) The implementation method of the embodiment of the present invention is simple, universal, and requires simple environment configuration. Specifically, the development environment configuration is simple. For C++ projects, only a header file and a dynamic library need to be added to complete the process. It has been called in different terrain analysis algorithms (such as slope analysis, aspect analysis, cut-and-fill analysis, etc.), and all of them can generate reports in .doc format.

[0137] (4) Complete autonomy, without the need for commercial licensing or subsequent difficulties in independent upgrades.

[0138] (5) Easy to generate and debug, with rich report styles. Using HTML standard format, HTML documents are easy to set styles. Word accepts most HTML and CSS instructions, including font, size, color, table, alignment, etc.

[0139] Based on the above embodiment, the present invention provides a general programming implementation device for generating a terrain analysis report as a doc document. Figure 5 The structure diagram of a general programming implementation device for generating a terrain analysis report as a doc document is shown. The device mainly includes the following parts:

[0140] Result acquisition module 502, used to obtain terrain analysis results to be processed;

[0141] The document creation module 504 is configured to call a pre-configured general function in the function library to create an HTML main document corresponding to the terrain analysis results. The content described in the HTML main document includes the storage path of each text content and each image content in the terrain analysis results. The image content is stored in a directory with the same name as the HTML main document.

[0142] The document encoding module 506 is used to encode the HTML main document and image content to obtain a document string and an image string, integrate the document string and the image string, and dynamically generate delimiters and intelligently control the number of blank lines inserted during the integration process to obtain a file that can be recognized by the office software, so that the office software can parse the recognizable file to obtain a terrain analysis report in the doc document format.

[0143] The embodiment of the present invention provides a general programming implementation device for generating a terrain analysis report as a doc document. By creating an HTML main document corresponding to the terrain analysis results, and encoding and integrating the HTML main document and image content, a file that can be recognized by office software is obtained, thereby generating a terrain analysis report in the doc document format. The embodiment of the present invention has the advantages of good cross-platform support, few dependent libraries, simple development environment configuration, easy generation and debugging, etc. In addition, by dynamically generating delimiters, the entire process can have strong domain relevance and uniqueness. By intelligently controlling the number of inserted blank lines, it can effectively avoid problems such as parsing errors caused by fixed blank lines, and also helps to improve the readability of the terrain analysis report in the doc document format.

[0144] In one embodiment, the delimiter is used to identify the boundary between the document string and the image string; the document encoding module 506 is specifically used to:

[0145] generating a feature string based on key parameters corresponding to the terrain analysis result, where the key parameters include one or more of a geographic coordinate range, an analysis timestamp, and a terrain data type;

[0146] Merge the feature string and the document string, and use a cryptographic hash function to generate a unique hash value for the merged string;

[0147] Extract a string of the specified length from the unique hash value and combine the extracted string with the structured prefix to generate a delimiter.

[0148] In one embodiment, the document encoding module 506 is specifically configured to:

[0149] Detect delimiter conflicts based on document strings and image strings;

[0150] If the delimiter fails to pass the conflict detection, the delimiter is adaptively adjusted;

[0151] Continue to perform conflict detection on the adaptively adjusted delimiter based on the document string and the image string until the adaptively adjusted delimiter passes the conflict detection.

[0152] In one embodiment, the document encoding module 506 is specifically configured to:

[0153] Detect the overlap rate between the character string contained in the delimiter and the document string and image string;

[0154] If the overlap rate is greater than a preset overlap rate threshold, it is determined that there is a conflict between the delimiter and the document character string or the image character string, and the delimiter fails the conflict detection.

[0155] In one embodiment, the document encoding module 506 is specifically configured to:

[0156] Append one or more specified characters to the end of the delimiter to obtain an adaptively adjusted delimiter.

[0157] In one embodiment, the document encoding module 506 is specifically configured to:

[0158] During the integration process, context awareness is performed on the content category of the current string to be integrated and its corresponding previous string, so as to determine the number of blank lines between the current string and the previous string based on the content category of the current string and the content category of the previous string, and insert blank lines between the current string and the previous string according to the number of blank lines.

[0159] In one embodiment, the document creation module 504 is specifically configured to:

[0160] Call the document creation function in the function library to generate a blank HTML main document;

[0161] Call the property setting function in the function library to set the page properties of the blank HTML main document;

[0162] Calling the format setting function in the function library to set the content format of the blank HTML main document, so as to write each text content in the terrain analysis result into the blank HTML main document according to the content format;

[0163] Call the image adding function in the function library to write the storage path of each image content stored in the directory with the same name as the HTML main document into the HTML main document.

[0164] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those in the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference can be made to the corresponding content in the aforementioned method embodiment.

[0165] An embodiment of the present invention provides a terminal. Specifically, the terminal includes a processor and a storage device. The storage device stores a computer program, and when the computer program is executed by the processor, it executes the method described in any one of the above embodiments.

[0166] Figure 6 A structural diagram of a terminal provided in an embodiment of the present invention is provided, wherein the terminal 100 includes: a processor 60, a memory 61, a bus 62 and a communication interface 63, wherein the processor 60, the communication interface 63 and the memory 61 are connected via the bus 62; the processor 60 is used to execute an executable module stored in the memory 61, such as a computer program.

[0167] The memory 61 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage. The system network element communicates with at least one other network element via at least one communication interface 63 (which may be wired or wireless), and may utilize the Internet, a wide area network, a local area network, a metropolitan area network, or the like.

[0168] The bus 62 may be an ISA bus, a PCI bus, or an EISA bus. The bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0169] Among them, the memory 61 is used to store programs, and the processor 60 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any embodiment of the above-mentioned embodiment of the present invention can be applied to the processor 60 or implemented by the processor 60.

[0170] The processor 60 may be an integrated circuit chip with signal processing capabilities. During implementation, the steps of the above method may be performed by hardware integrated logic circuits or software instructions within the processor 60. The processor 60 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present invention may be directly executed by a hardware decoding processor or by a combination of hardware and software modules within the decoding processor. The software modules may be located in storage media well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or the like. The storage medium is located in the memory 61 , and the processor 60 reads the information in the memory 61 and completes the steps of the above method in combination with its hardware.

[0171] The computer program product of the readable storage medium provided in the embodiment of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can be referred to the previous method embodiment and will not be repeated here.

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

[0173] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed by the present invention, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.

Claims

1. A general programming implementation method for generating a terrain analysis report as a doc document, characterized in that: include: Obtain terrain analysis results to be processed; Calling a pre-configured general function in a function library to create an HTML main document corresponding to the terrain analysis result, wherein the content described in the HTML main document includes the storage path of each text content and each image content in the terrain analysis result, and the image content is stored in a directory with the same name as the HTML main document; The HTML main document and the image content are encoded to obtain a document string and an image string, the document string and the image string are integrated, and delimiters are dynamically generated and the number of inserted blank lines is intelligently controlled during the integration process to obtain a recognizable file for office software, so that the office software can parse the recognizable file to obtain a terrain analysis report in the doc document format.

2. The general programming implementation method for generating a terrain analysis report as a doc document according to claim 1, characterized in that: The delimiter is used to identify the boundary between the document character string and the image character string; Delimiters are dynamically generated during the integration process, including: generating a characteristic character string based on key parameters corresponding to the terrain analysis result, wherein the key parameters include one or more of a geographic coordinate range, an analysis timestamp, and a terrain data type; Merging the characteristic character string with the document character string, and generating a unique hash value for the merged character string using a cryptographic hash function; A character string of a specified length is truncated from the unique hash value, and the truncated character string is combined with a structured prefix to generate a delimiter.

3. The general programming implementation method for generating a terrain analysis report as a doc document according to claim 2, characterized in that: After dynamically generating the delimiter during the integration process, the method further includes: Performing conflict detection on the delimiter based on the document character string and the image character string; In the case where the delimiter fails the conflict detection, adaptively adjusting the delimiter; Continuing to perform conflict detection on the adaptively adjusted delimiter based on the document character string and the image character string until the adaptively adjusted delimiter passes the conflict detection.

4. The general programming implementation method for generating a terrain analysis report as a doc document according to claim 3, characterized in that: Performing conflict detection on the delimiter based on the document character string and the image character string includes: detecting an overlap rate between a character string contained in the delimiter, the document character string, and the image character string; If the overlap rate is greater than a preset overlap rate threshold, it is determined that there is a conflict between the delimiter and the document character string or the image character string, and the delimiter fails the conflict detection.

5. The general programming implementation method for generating a terrain analysis report as a doc document according to claim 3, characterized in that: Adaptively adjusting the delimiter includes: One or more specified characters are appended to the end of the delimiter to obtain the adaptively adjusted delimiter.

6. The general programming implementation method for generating a terrain analysis report as a doc document according to claim 1, characterized in that: Intelligently control the number of blank rows inserted during the integration process, including: During the integration process, context awareness is performed on the content categories of the current string to be integrated and its corresponding previous string, so as to determine the number of blank lines between the current string and the previous string based on the content category of the current string and the content category of the previous string, and insert blank lines between the current string and the previous string according to the number of blank lines.

7. The general programming implementation method for generating a terrain analysis report as a doc document according to claim 1, characterized in that: Call the pre-configured general function in the function library to create the HTML main document corresponding to the terrain analysis results, including: Call the document creation function in the function library to generate a blank HTML main document; Calling the attribute setting function in the function library to set the page attributes of the blank HTML main document; calling a formatting function in the function library to set the content format of the blank HTML main document, so as to write each text content in the terrain analysis result into the blank HTML main document according to the content format; The image adding function in the function library is called to write the storage path of each image content stored in the directory with the same name as the HTML main document into the HTML main document.

8. A general programming implementation device for generating a terrain analysis report as a doc document, characterized in that: include: A result acquisition module is used to obtain the terrain analysis results to be processed; a document creation module, configured to call a pre-configured general function in a function library to create an HTML main document corresponding to the terrain analysis result, wherein the content described in the HTML main document includes the storage path of each text content and each image content in the terrain analysis result, and the image content is stored in a directory with the same name as the HTML main document; The document encoding module is used to encode the HTML main document and the image content to obtain a document string and an image string, integrate the document string and the image string, and dynamically generate delimiters and intelligently control the number of inserted blank lines during the integration process to obtain a recognizable file for office software, so that the office software can parse the recognizable file to obtain a terrain analysis report in the doc document format.

9. A terminal, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 7.