Remote sensing and geographic information algorithm network service encapsulation method, device and equipment
By converting the descriptive information of remote sensing and geographic information algorithms into JSON format and using a template engine to generate network service code, the problem of high development difficulty in encapsulated code in existing technologies is solved, and efficient network service encapsulation and deployment are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU INST OF GEOGRAPHY GUANGDONG ACAD OF SCI
- Filing Date
- 2022-07-28
- Publication Date
- 2026-04-14
AI Technical Summary
When existing remote sensing and geographic information algorithms are packaged into network services, it is necessary to write dedicated encapsulation code for each one, which is difficult to develop and inefficient.
By acquiring the descriptive information of remote sensing and geographic information algorithms, converting it into JSON format files, and using a template engine to generate algorithm command-line parameters and network service encapsulation code, the network service files are automatically generated, avoiding the need for manual writing of encapsulation code one by one.
It improves the efficiency of encapsulating remote sensing and geographic information algorithm network services, enabling rapid deployment as network services that can be invoked over the network.
Smart Images

Figure CN115268938B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a method, apparatus, storage medium, and electronic device for encapsulating network services of remote sensing and geographic information algorithms. Background Technology
[0002] Remote sensing and geographic information system (GIS) algorithms are crucial tools for processing and analyzing remote sensing and geospatial data to obtain necessary information and knowledge. Currently, a large number of remote sensing and GIS algorithms have been developed, with applications ranging from simple data transformation to complex domain application models. However, these remote sensing image processing algorithms require cumbersome and complex installation and configuration processes, and each has different usage methods, which greatly limits their application.
[0003] Network services are distributed, self-contained, and modular application components that can be described, published, found, and invoked within a network. They represent a standardized method for communication between different applications via a network. Currently, encapsulating remote sensing and geographic information algorithms into network services, including network services based on the Simple Object Access Protocol (SOAP) and geoprocessing network services (WPS) based on the Open Geospatial Information Consortium (OGC) standard, requires writing dedicated encapsulation code for each remote sensing and geographic information algorithm individually. This approach is complex, labor-intensive, and inefficient. Summary of the Invention
[0004] Based on this, the purpose of the present invention is to provide a method, apparatus, storage medium, and electronic device for encapsulating network services of remote sensing and geographic information algorithms, which has the advantage of improving the efficiency of network service encapsulation.
[0005] According to a first aspect of the embodiments of this application, a method for encapsulating network services of remote sensing and geographic information algorithms is provided, comprising the following steps:
[0006] Obtain description information of remote sensing and geographic information algorithms, and convert the description information into a JSON format file;
[0007] The JSON file is deserialized to obtain the algorithm description POJO object;
[0008] Based on the preset algorithm command line parameter entity class template file, algorithm command line execution method template file, algorithm description POJO object, and template engine, generate the entity class code of the algorithm command line parameter and the Java execution code of the algorithm command line;
[0009] Based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine, generate network service encapsulation code;
[0010] The entity class code of the algorithm command line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code are copied to the preset network service skeleton project and compiled to generate network service files;
[0011] The network service file is deployed to the server to obtain the corresponding network service.
[0012] According to a second aspect of the embodiments of this application, a network service encapsulation device for remote sensing and geographic information algorithms is provided, comprising:
[0013] The description information acquisition module is used to acquire description information of remote sensing and geographic information algorithms and convert the description information into a JSON format file;
[0014] The POJO object acquisition module is used to deserialize the JSON format file to obtain the algorithm description POJO object;
[0015] The entity class code generation module is used to generate entity class code for algorithm command line parameters and Java execution code for algorithm command line based on preset algorithm command line parameter entity class template files, algorithm command line execution method template files, algorithm description POJO objects, and template engine.
[0016] The encapsulation code generation module is used to generate network service encapsulation code based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine.
[0017] The service file generation module is used to copy the entity class code of the algorithm command line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code to a preset network service skeleton project for compilation, thereby generating a network service file.
[0018] The network service acquisition module is used to deploy the network service file to the server to obtain the corresponding network service.
[0019] According to a third aspect of the embodiments of this application, an electronic device is provided, comprising: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute a network service encapsulation method for remote sensing and geographic information algorithms as described in any one of the preceding claims.
[0020] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the network service encapsulation method of remote sensing and geographic information algorithms as described in any of the preceding claims.
[0021] This application embodiment obtains the description information of remote sensing and geographic information algorithms, converts the description information into a JSON format file, deserializes the JSON format file to obtain an algorithm description POJO object, generates entity class code for algorithm command line parameters and Java execution code for algorithm command lines based on preset algorithm command line parameter entity class template files, algorithm command line execution method template files, the algorithm description POJO object, and a template engine, generates network service encapsulation code based on preset network service encapsulation interface template files, network service encapsulation implementation class template files, the algorithm description POJO object, and a template engine, copies the entity class code for algorithm command line parameters, the Java execution code for algorithm command lines, and the network service encapsulation code to a preset network service skeleton project for compilation, generates a network service file, and deploys the network service file to a server to obtain the corresponding network service. Based on the formatted algorithm description information, template engine, and network service skeleton project, this application embodiment constructs algorithm command line parameter entity class template files, algorithm command line execution method template files, network service encapsulation interface template files, and network service encapsulation implementation class template files. This allows remote sensing and geographic information algorithms to be quickly published as network services that can be called over the network, eliminating the need for manual writing of encapsulation code and improving the efficiency of algorithm network service encapsulation.
[0022] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application.
[0023] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description
[0024] Figure 1 A flowchart illustrating the network service encapsulation method for remote sensing and geographic information algorithms provided in this application embodiment;
[0025] Figure 2 A flowchart illustrating step S10 in the network service encapsulation method for remote sensing and geographic information algorithms provided in this application embodiment;
[0026] Figure 3 A flowchart illustrating step S20 in the network service encapsulation method for remote sensing and geographic information algorithms provided in this application embodiment;
[0027] Figure 4 A flowchart illustrating step S30 in the network service encapsulation method for remote sensing and geographic information algorithms provided in this application embodiment;
[0028] Figure 5A flowchart illustrating step S40 in the network service encapsulation method for remote sensing and geographic information algorithms provided in this application embodiment;
[0029] Figure 6 This is a structural block diagram of a network service encapsulation device for remote sensing and geographic information algorithms provided in the embodiments of this application. Detailed Implementation
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0031] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0032] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the embodiments of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0033] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims. In the description of this application, it should be understood that the terms "first," "second," "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0034] Furthermore, in the description of this application, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0035] Please see Figure 1 The network service encapsulation method for remote sensing and geographic information algorithms provided in this application includes:
[0036] S10: Obtain the description information of remote sensing and geographic information algorithms, and convert the description information into a JSON format file.
[0037] In this embodiment, the descriptive information includes a functional description of the remote sensing and geographic information algorithm, the executable program name, and algorithm command-line parameters. The algorithm command-line parameters include input parameters, output parameters, and optional parameters. The descriptive information is stored as a JSON file according to a standard algorithm description format. Optionally, the descriptive information can be stored as a JSON file according to a custom algorithm description format.
[0038] S20: Deserialize the JSON format file to obtain the algorithm description POJO object.
[0039] A plain Java object is abbreviated as POJO (Plain Ordinary Java Object). POJO is used to emphasize that it is a plain Java object, not a special object, in contrast to special Java objects. Special objects primarily refer to Java objects that conform to specific Java object models, conventions, or frameworks, while a POJO is a Java object that is not restricted by anything other than the Java language specification. Deserialization refers to converting binary content back into a Java object. In this embodiment, the JSON format file is deserialized into an algorithmically described POJO object.
[0040] S30: Based on the preset algorithm command line parameter entity class template file, algorithm command line execution method template file, the algorithm description POJO object, and the template engine, generate the entity class code of the algorithm command line parameter and the Java execution code of the algorithm command line.
[0041] In this embodiment, a pre-defined algorithm command-line parameter entity class template file is established based on the definition method of Java class member variables and the generator design pattern to generate the entity class code for the algorithm command-line parameters. Specifically, the data types and variable names of the Java class member variables in the algorithm command-line parameter entity class template file are represented by specific placeholders, corresponding to the data types and names of the algorithm command-line parameters, respectively.
[0042] Based on the function definition conventions in Java, a pre-defined algorithm command-line execution method template file is created to generate the Java execution code for the algorithm command line. The template file uses placeholders to represent various descriptive information of the algorithm command line, including the executable program name and command-line parameter names.
[0043] This method utilizes a template engine to parse the entity class template file for algorithm command-line arguments and the template file for algorithm command-line execution methods. It takes the algorithm description POJO object as input data, uses its attribute names to match placeholders in the template, and replaces the placeholders with the corresponding attribute values. This automatically and in batches generates entity class code for algorithm command-line arguments and Java execution code for algorithm command lines.
[0044] S40: Generate network service encapsulation code based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine.
[0045] In this embodiment, based on the definition method of service interfaces, the definition method of interface implementation classes, and the usage method of service annotations in the network service development framework used, preset network service encapsulation interface template files and network service encapsulation implementation class template files are established. Different network service types (e.g., SOAP, OGC WPS, or REST) and network service frameworks (e.g., Apache CXF and 52North WPS) have different definition methods for service interfaces and interface implementation classes; therefore, different template files must be established as needed. Placeholders are used in the template files to represent the name of the network service interface, the name of the method contained in the network service, the name of the parameter, and the data type, corresponding to the name of the encapsulated software, the name of the algorithm in the software, and the name and data type of the algorithm command-line parameters, respectively. The template engine parses the network service encapsulation interface template files and the network service encapsulation implementation class template files, taking the algorithm description POJO object as input data, and replacing the placeholders in the template files with the attribute values of the corresponding attributes in the algorithm description POJO object, thereby automatically generating the network service encapsulation code.
[0046] S50: Copy the entity class code of the algorithm command line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code to the preset network service skeleton project for compilation to generate a network service file.
[0047] In this embodiment, based on the basic project structure defined by the project management and automated build tool Apache Maven and the code organization structure of the network service development framework, a network service skeleton project is designed. Based on the examples and instructions in the network service skeleton project, automatically generated code is organized, and the dependent programs required for compiling and running the network service are compiled. Specifically, the entity class code of the automatically generated algorithm command-line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code are copied to the corresponding skeleton project according to the network service type for compilation, generating a Java archive file (JAR format), i.e., the network service file, to be deployed.
[0048] S60: Deploy the network service file to the server to obtain the corresponding network service.
[0049] In this embodiment, according to the requirements of the remote sensing and geographic information algorithm and network service development framework, the runtime environment for the remote sensing and geographic information algorithms and network services is installed and configured. This includes installing a Java Virtual Machine or Python interpreter, installing the executable programs for the remote sensing and geographic information algorithms and their dependencies, installing a network service runtime container (such as Apache Tomcat), registering the network services to be published in the network service development framework, and configuring system environment variables. Then, the generated network service files are deployed to the network service runtime container to obtain the corresponding network services, and the network service runtime container is started to publish the network services.
[0050] Applying the embodiments of this application, the descriptive information of remote sensing and geographic information algorithms is obtained and converted into a JSON format file; the JSON format file is deserialized to obtain an algorithm description POJO object; based on a preset algorithm command line parameter entity class template file, an algorithm command line execution method template file, the algorithm description POJO object, and a template engine, entity class code for the algorithm command line parameters and Java execution code for the algorithm command line are generated; based on a preset network service encapsulation interface template file, a network service encapsulation implementation class template file, the algorithm description POJO object, and a template engine, network service encapsulation code is generated; the entity class code for the algorithm command line parameters, the Java execution code for the algorithm command line, and the network service encapsulation code are copied to a preset network service skeleton project for compilation to generate a network service file; the network service file is deployed to a server to obtain the corresponding network service. Based on the formatted algorithm description information, template engine, and network service skeleton project, this application embodiment constructs algorithm command line parameter entity class template files, algorithm command line execution method template files, network service encapsulation interface template files, and network service encapsulation implementation class template files. This allows remote sensing and geographic information algorithms to be quickly published as network services that can be called over the network, eliminating the need for manual writing of encapsulation code and improving the efficiency of algorithm network service encapsulation.
[0051] In an optional embodiment, please refer to Figure 2 Step S10 includes steps S101 to S102, as follows:
[0052] S101: Obtain descriptions of relevant remote sensing and geographic information algorithms from online documentation of remote sensing and geographic information analysis software, toolkits, and algorithm scripts using web crawlers;
[0053] S102: Convert the description information into a JSON format file according to the preset standardized algorithm description format.
[0054] A web crawler is a program or script that automatically retrieves information from the World Wide Web according to certain rules. In this embodiment, a web crawler automatically obtains the descriptive information of relevant remote sensing and geographic information algorithms from online documentation of remote sensing and geographic information analysis software, toolkits, and algorithm scripts, improving the efficiency of descriptive information retrieval. Simultaneously, the descriptive information is converted into a JSON format file according to a preset algorithm description standard format, making the descriptive information more standardized and structured, and easier for machines to read and recognize.
[0055] In an optional embodiment, please refer to Figure 3 Step S20 includes steps S201 to S204, as follows:
[0056] S201: Instantiate the JSON format file as a JSON object in Java;
[0057] S202: Obtain the property names of the JSON object, and the property values corresponding to each property name in the JSON object;
[0058] S203: Get the attribute name of the preset algorithm description POJO class;
[0059] S204: If the attribute name of the preset algorithm description POJO class is the same as the attribute name of the JSON object, the preset algorithm description POJO class is instantiated into an algorithm description POJO object, and the attribute value corresponding to the attribute name in the JSON object that is the same as the preset algorithm description POJO class is assigned to the algorithm description POJO object.
[0060] In this embodiment, since the JSON format file has a large amount of data, the JSON format file is instantiated into a JSON object in Java, and then the JSON object is matched with the algorithm description POJO object, thereby converting the JSON format file into an algorithm description POJO object, saving memory resources and overhead, and improving response speed.
[0061] In an optional embodiment, please refer to Figure 4 Step S30 includes steps S301 to S304, as follows:
[0062] S301: The preset algorithm command line parameter entity class template file is parsed by the template engine, and the first template parameter in the preset algorithm command line parameter entity class template file is traversed.
[0063] S302: Obtain a first attribute name that matches the name of the first template parameter from the POJO object describing the algorithm, replace the first template parameter with the attribute value corresponding to the first attribute name, and generate the entity class code of the algorithm command line parameter;
[0064] S303: The preset algorithm command line execution method template file is parsed by the template engine, and the second template parameter in the preset algorithm command line execution method template file is traversed.
[0065] S304: Obtain the second attribute name that matches the name of the second template parameter from the POJO object described by the algorithm, replace the second template parameter with the attribute value corresponding to the second attribute name, and generate the Java execution code of the algorithm command line.
[0066] In this embodiment, the algorithm command-line parameter entity class template file includes several first template parameters, each with a name identical to one of the several attribute names representing the algorithm command-line parameter name in the algorithm description POJO object. The first template parameters serve as placeholders in the algorithm command-line parameter entity class template file. The algorithm command-line execution method template file includes several second template parameters, each with a name identical to several attribute names representing the algorithm command-line parameter name and one attribute name representing the algorithm name in the algorithm description POJO object. The second template parameters serve as placeholders in the algorithm command-line execution method template file.
[0067] The algorithm description POJO object obtains a first attribute name that matches the name of the first template parameter, replaces the first template parameter with the attribute value corresponding to the first attribute name, and obtains a second attribute name that matches the name of the second template parameter, replaces the second template parameter with the attribute value corresponding to the second attribute name, thereby automatically and quickly generating entity class code for algorithm command line parameters and Java execution code for algorithm command lines.
[0068] In an optional embodiment, please refer to Figure 5 Step S40 includes steps S401 to S402, as follows:
[0069] S401: The template engine parses the preset network service encapsulation interface template file and the preset network service encapsulation implementation class template file, and iterates through the third template parameter in the preset network service encapsulation interface template file and the fourth template parameter in the preset network service encapsulation implementation class template file.
[0070] S402: Obtain a third attribute name that matches the name of the third template parameter and a fourth attribute name that matches the name of the fourth template parameter from the POJO object described by the algorithm. Replace the third template parameter with the attribute value corresponding to the third attribute name and replace the fourth template parameter with the attribute value corresponding to the fourth attribute name to generate network service encapsulation code.
[0071] In this embodiment, the network service encapsulation interface template file includes several third template parameters, each with a name identical to one of the several attribute names representing the algorithm name in the algorithm description POJO object. These third template parameters serve as placeholders in the network service encapsulation interface template file. The network service encapsulation implementation class template file includes several fourth template parameters, each with a name identical to one of the several attribute names representing the algorithm name and command-line parameter names in the algorithm description POJO object. These fourth template parameters serve as placeholders in the network service encapsulation implementation class template file.
[0072] The algorithm describes a POJO object to obtain a third attribute name that matches the name of the third template parameter and a fourth attribute name that matches the name of the fourth template parameter. The attribute value corresponding to the third attribute name replaces the third template parameter, and the attribute value corresponding to the fourth attribute name replaces the fourth template parameter, thereby automatically and quickly generating network service encapsulation code.
[0073] For the corresponding method embodiments described above, please refer to Figure 6 This invention provides a network service encapsulation device 6 for remote sensing and geographic information algorithms, comprising:
[0074] The description information acquisition module 61 is used to acquire description information of remote sensing and geographic information algorithms and convert the description information into a JSON format file;
[0075] POJO object acquisition module 62 is used to deserialize the JSON format file to obtain the algorithm description POJO object;
[0076] The entity class code generation module 63 is used to generate entity class code for algorithm command line parameters and Java execution code for algorithm command line based on preset algorithm command line parameter entity class template file, algorithm command line execution method template file, algorithm description POJO object and template engine;
[0077] The encapsulation code generation module 64 is used to generate network service encapsulation code based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine.
[0078] The service file generation module 65 is used to copy the entity class code of the algorithm command line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code to a preset network service skeleton project for compilation, thereby generating a network service file.
[0079] The network service acquisition module 66 is used to deploy the network service file to the server to obtain the corresponding network service.
[0080] Optionally, the description information acquisition module 61 includes:
[0081] The description information acquisition unit is used to obtain the description information of the corresponding remote sensing and geographic information algorithms from online documentation of remote sensing and geographic information analysis software, toolkits, and algorithm scripts through web crawlers.
[0082] The description information conversion unit is used to convert the description information into a JSON format file according to a standard algorithm description format.
[0083] Optionally, the POJO object acquisition module 62 includes:
[0084] The file instantiation unit is used to instantiate the JSON format file into a JSON object in Java;
[0085] The object property name retrieval unit is used to retrieve the property names of the JSON object and the property values corresponding to each property name in the JSON object;
[0086] The class attribute name retrieval unit is used to retrieve the attribute names of the preset algorithm description POJO class;
[0087] The POJO class instantiation unit is used to instantiate the preset algorithm description POJO class into an algorithm description POJO object if the attribute name of the preset algorithm description POJO class is consistent with the attribute name of the JSON object, and to assign the attribute value corresponding to the attribute name with the same attribute name as the preset algorithm description POJO class in the JSON object to the algorithm description POJO object.
[0088] Optionally, the entity class code generation module 63 includes:
[0089] The first template file parsing unit is used to parse the preset algorithm command line parameter entity class template file through the template engine and traverse the first template parameter in the preset algorithm command line parameter entity class template file.
[0090] The entity class code generation unit is used to obtain a first attribute name that matches the name of the first template parameter from the algorithm description POJO object, replace the first template parameter with the attribute value corresponding to the first attribute name, and generate the entity class code of the algorithm command line parameter.
[0091] The second template file parsing unit is used to parse the preset algorithm command line execution method template file through the template engine and traverse the second template parameters in the preset algorithm command line execution method template file;
[0092] The execution code generation unit is used to obtain a second attribute name that matches the name of the second template parameter from the algorithm description POJO object, replace the second template parameter with the attribute value corresponding to the second attribute name, and generate Java execution code for the algorithm command line.
[0093] Optionally, the encapsulation code generation module 64 includes:
[0094] The third template file parsing unit is used to parse the preset network service encapsulation interface template file and the preset network service encapsulation implementation class template file through the template engine, and traverse the third template parameter in the preset network service encapsulation interface template file and the fourth template parameter in the preset network service encapsulation implementation class template file.
[0095] The encapsulation code generation unit is used to obtain a third attribute name that matches the name of the third template parameter and a fourth attribute name that matches the name of the fourth template parameter from the POJO object described by the algorithm, replace the third template parameter with the attribute value corresponding to the third attribute name, and replace the fourth template parameter with the attribute value corresponding to the fourth attribute name to generate network service encapsulation code.
[0096] Applying the embodiments of this application, the descriptive information of remote sensing and geographic information algorithms is obtained and converted into a JSON format file; the JSON format file is deserialized to obtain an algorithm description POJO object; based on a preset algorithm command line parameter entity class template file, an algorithm command line execution method template file, the algorithm description POJO object, and a template engine, entity class code for the algorithm command line parameters and Java execution code for the algorithm command line are generated; based on a preset network service encapsulation interface template file, a network service encapsulation implementation class template file, the algorithm description POJO object, and a template engine, network service encapsulation code is generated; the entity class code for the algorithm command line parameters, the Java execution code for the algorithm command line, and the network service encapsulation code are copied to a preset network service skeleton project for compilation to generate a network service file; the network service file is deployed to a server to obtain the corresponding network service. Based on the formatted algorithm description information, template engine, and network service skeleton project, this application embodiment constructs algorithm command line parameter entity class template files, algorithm command line execution method template files, network service encapsulation interface template files, and network service encapsulation implementation class template files. This allows remote sensing and geographic information algorithms to be quickly published as network services that can be called over the network, eliminating the need for manual writing of encapsulation code and improving the efficiency of algorithm network service encapsulation.
[0097] This application also provides an electronic device, including: a processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and to execute the method steps of the above embodiments.
[0098] This application also provides a computer-readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the method steps of the above embodiments.
[0099] The embodiments described above are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and the present invention also intends to include these modifications and variations.
Claims
1. A method for encapsulating network services of remote sensing and geographic information algorithms, characterized in that, Includes the following steps: Obtain description information of remote sensing and geographic information algorithms, and convert the description information into a JSON format file; The JSON file is deserialized to obtain the algorithm description POJO object; Based on the preset algorithm command line parameter entity class template file, algorithm command line execution method template file, algorithm description POJO object, and template engine, generate the entity class code of the algorithm command line parameter and the Java execution code of the algorithm command line; Based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine, generate network service encapsulation code; The entity class code of the algorithm command line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code are copied to the preset network service skeleton project and compiled to generate network service files; The network service file is deployed to the server to obtain the corresponding network service.
2. The network service encapsulation method for remote sensing and geographic information algorithms according to claim 1, characterized in that: The step of acquiring the description information of the remote sensing and geographic information algorithm and converting the description information into a JSON format file includes: Descriptive information of remote sensing and geographic information algorithms is obtained from online documentation of remote sensing and geographic information analysis software, toolkits, and algorithm scripts using web crawlers. The description information is converted into a JSON format file according to a preset standardized algorithm description format.
3. The network service encapsulation method for remote sensing and geographic information algorithms according to claim 1, characterized in that: The step of deserializing the JSON format file to obtain the algorithm description POJO object includes: Instantiate the JSON format file as a JSON object in Java; Obtain the property names of the JSON object, and the property values corresponding to each property name in the JSON object; Retrieves the attribute names of the preset algorithm description POJO class; If the attribute name of the preset algorithm description POJO class is the same as the attribute name of the JSON object, the preset algorithm description POJO class is instantiated into an algorithm description POJO object, and the attribute value corresponding to the attribute name with the same attribute name as the preset algorithm description POJO class in the JSON object is assigned to the algorithm description POJO object.
4. The network service encapsulation method for remote sensing and geographic information algorithms according to claim 1, characterized in that: The steps of generating entity class code for algorithm command line parameters and Java execution code for algorithm command line based on preset algorithm command line parameter entity class template files, algorithm command line execution method template files, algorithm description POJO objects, and template engines include: The template engine parses the preset algorithm command line parameter entity class template file and iterates through the first template parameter in the preset algorithm command line parameter entity class template file. Obtain the first attribute name that matches the name of the first template parameter from the POJO object described by the algorithm, replace the first template parameter with the attribute value corresponding to the first attribute name, and generate the entity class code of the algorithm command line parameter; The template engine parses the preset algorithm command line execution method template file and iterates through the second template parameters in the preset algorithm command line execution method template file. Obtain the second attribute name that matches the name of the second template parameter from the POJO object described by the algorithm, replace the second template parameter with the attribute value corresponding to the second attribute name, and generate the Java execution code of the algorithm command line.
5. The network service encapsulation method for remote sensing and geographic information algorithms according to claim 1, characterized in that: The step of generating network service encapsulation code based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine includes: The template engine parses the preset network service encapsulation interface template file and the preset network service encapsulation implementation class template file, and iterates through the third template parameter in the preset network service encapsulation interface template file and the fourth template parameter in the preset network service encapsulation implementation class template file. The algorithm describes a POJO object to obtain a third attribute name that matches the name of the third template parameter and a fourth attribute name that matches the name of the fourth template parameter. The attribute value corresponding to the third attribute name replaces the third template parameter, and the attribute value corresponding to the fourth attribute name replaces the fourth template parameter, thereby generating network service encapsulation code.
6. A network service encapsulation device for remote sensing and geographic information algorithms, characterized in that, include: The description information acquisition module is used to acquire description information of remote sensing and geographic information algorithms and convert the description information into a JSON format file; The POJO object acquisition module is used to deserialize the JSON format file to obtain the algorithm description POJO object; The entity class code generation module is used to generate entity class code for algorithm command line parameters and Java execution code for algorithm command line based on preset algorithm command line parameter entity class template files, algorithm command line execution method template files, algorithm description POJO objects, and template engine. The encapsulation code generation module is used to generate network service encapsulation code based on the preset network service encapsulation interface template file, network service encapsulation implementation class template file, the algorithm description POJO object, and the template engine. The service file generation module is used to copy the entity class code of the algorithm command line parameters, the Java execution code of the algorithm command line, and the network service encapsulation code to a preset network service skeleton project for compilation, thereby generating a network service file. The network service acquisition module is used to deploy the network service file to the server to obtain the corresponding network service.
7. The network service encapsulation device for remote sensing and geographic information algorithms according to claim 6, characterized in that, The entity class code generation module includes: The first template parameter traversal unit is used to parse the preset algorithm command line parameter entity class template file through the template engine and traverse the first template parameters in the preset algorithm command line parameter entity class template file. The entity class code generation unit is used to obtain a first attribute name that matches the name of the first template parameter from the algorithm description POJO object, replace the first template parameter with the attribute value corresponding to the first attribute name, and generate the entity class code of the algorithm command line parameter. The second template parameter traversal unit is used to parse the preset algorithm command line execution method template file through the template engine and traverse the second template parameters in the preset algorithm command line execution method template file. The execution code generation unit is used to obtain a second attribute name that matches the name of the second template parameter from the algorithm description POJO object, replace the second template parameter with the attribute value corresponding to the second attribute name, and generate Java execution code for the algorithm command line.
8. The network service encapsulation device for remote sensing and geographic information algorithms according to claim 6, characterized in that, The encapsulation code generation module includes: The third template parameter traversal unit is used to parse the preset network service encapsulation interface template file and the preset network service encapsulation implementation class template file through the template engine, and traverse the third template parameter in the preset network service encapsulation interface template file and the fourth template parameter in the preset network service encapsulation implementation class template file. The encapsulation code generation unit is used to obtain a third attribute name that matches the name of the third template parameter and a fourth attribute name that matches the name of the fourth template parameter from the POJO object described by the algorithm, replace the third template parameter with the attribute value corresponding to the third attribute name, and replace the fourth template parameter with the attribute value corresponding to the fourth attribute name to generate network service encapsulation code.
9. A computer device, comprising: A processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the computer program, implements the steps of the method as claimed in any one of claims 1 to 5.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Dynamic creation method of processing Web service with remote sensing image
CN101807204A
Internet-based remote sensing data analysis tool packaging service method
CN103246516A