MongoDB-based geospatial index generation and retrieval method, device, and storage medium

By generating indexes of separation, intersection and inclusion between regions in MongoDB, the problem of MongoDB's single geospatial search method is solved, and more accurate retrieval and functional expansion is achieved.

CN113076384BActive Publication Date: 2025-08-22GEOVIS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010010855.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-06
Publication Date
2025-08-22
Estimated Expiration
2040-01-06

AI Technical Summary

Technical Problem

MongoDB's geospatial retrieval method is single, and it is impossible to accurately judge the intersection, inclusion and disjunction relationship between regions, and cannot meet the needs of multiple business scenarios.

Method used

By obtaining MongoDB's intersects and within functions, and using logical operations to generate indexes of separation, intersection and/or inclusion relationships between regions, the generation method of MongoDB's geospatial index is extended.

Benefits of technology

It improves the accuracy of geospatial retrieval, expands the functions of MongoDB database, and can meet the needs of a variety of business scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113076384B_ABST
    Figure CN113076384B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a MongoDB-based geospatial index generation and retrieval method, device, and storage medium. The method includes obtaining MongoDB's intersects and / or within functions, wherein the intersects function is used to generate the geospatial index intersects, and the within function is used to generate the geospatial index within; and generating an index based on the intersects and / or within functions through logical operations to identify the separation, intersection, and / or inclusion relationships between regions. In this way, an index based on the separation, intersection, and / or inclusion relationships between regions can be generated, improving retrieval accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present disclosure generally relate to the field of big data retrieval technology, and more specifically, to a MongoDB-based geospatial index generation and retrieval method, device, and computer-readable storage medium. Background Art

[0002] MongoDB lies somewhere between relational and non-relational databases, offering the richest functionality and closest resemblance to relational databases. It supports very loose data structures, allowing it to store relatively complex data types. MongoDB's most significant feature is its powerful query language, whose syntax is somewhat similar to object-oriented query languages. It can perform almost all of the same single-table queries as relational databases and even supports indexing of data.

[0003] However, MongoDB's own geospatial search method is too simple, supporting only intersects and within relationship search, and its functions are not comprehensive and cannot meet the needs of business scenarios. For example, in MongoDB's existing geospatial search function, the definition of the intersection of two areas (intersects) is not precise, such as Figure 4 The relationship between regions AB in MongoDB is defined as intersection, but in practice, the relationship between regions AB is coverage (inclusion). Therefore, when calculating the intersecting area of ​​two regions, if a belongs to or covers relationship exists, the search results will obviously be incorrect. Furthermore, the current MongoDB search function cannot meet the requirements of business scenarios such as inclusion and non-intersection. Summary of the Invention

[0004] According to an embodiment of the present disclosure, a MongoDB-based geospatial index generation and retrieval method, device, and computer-readable storage medium are provided.

[0005] In a first aspect of the present disclosure, a method for generating a geospatial index based on MongoDB is provided. The method for generating a geospatial index based on MongoDB comprises:

[0006] Obtain the intersects and / or within functions of MongoDB, wherein the intersects function is used to generate a geospatial index intersects, and the within function is used to generate a geospatial index within;

[0007] An index of the separation, intersection and / or inclusion relationship between regions is generated through logical operations according to the intersects and / or within functions.

[0008] Furthermore, generating an index of separation, intersection and / or inclusion relationships between regions through logical operations according to the intersects and / or within functions includes:

[0009] Generate an index of the inter-region separation relationship according to the intersects function; and / or

[0010] Generates indices of intersection and / or containment relationships between regions based on the intersects and within functions.

[0011] Furthermore, generating an index of the inter-region separation relationship according to the intersects function includes:

[0012] The index of the inter-region separation relationship is generated by the following formula:

[0013]

[0014] Where A is the given area;

[0015] X is the region containing A;

[0016] Represents logical NOT;

[0017] “∩” represents the intersects function in MongoDB, which is the logical “intersection” in MongoDB.

[0018] Furthermore, generating an index of the intersection relationship between regions according to the intersects and within functions includes:

[0019] The index of the intersection relationship between the regions is generated by the following formula:

[0020]

[0021] Where A is the given area;

[0022] X is the region containing A;

[0023] Represents logical NOT;

[0024] “∩” represents the intersects function in MongoDB, which is the logical “intersection” in MongoDB;

[0025] Represents the within function in MongoDB, which is the logical "inclusion" in MongoDB;

[0026] “&&” represents logical “and”.

[0027] Furthermore, generating an index of the inclusion relationship between regions according to the intersects and within functions includes:

[0028] The index of the inclusion relationship between the regions is generated by the following formula:

[0029]

[0030] Where A is the given area;

[0031] X is the region containing A;

[0032] “∩” represents the intersects function in MongoDB, which is the logical “intersection” in MongoDB;

[0033] Represents the within function in MongoDB, which is the logical "inclusion" in MongoDB;

[0034] “&&” represents logical “and”.

[0035] In a second aspect of the present disclosure, a geospatial retrieval method based on MongoDB is provided, comprising:

[0036] Receive information about a given area;

[0037] The geospatial data stored in MongoDB is retrieved using the index of the separation, intersection and / or inclusion relationship between regions generated in the first aspect to obtain regions that are separated from the given region, regions that intersect with the given region and / or regions that include the given region.

[0038] In a third aspect of the present disclosure, a device is provided, comprising:

[0039] one or more processors;

[0040] a storage device for storing one or more programs;

[0041] When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to the first aspect and / or the second aspect of the present disclosure.

[0042] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method according to the first aspect and / or the second aspect of the present disclosure is implemented.

[0043] The embodiments of the present application provide a method for generating a geographic spatial index based on MongoDB. This method obtains the intersects and / or within functions of MongoDB and generates indexes of the separation, intersection, and / or inclusion relationships between regions through logical operations based on the intersects and / or within functions. This method greatly simplifies the search method, improves the accuracy of the search, expands the functionality of the MongoDB database, and can meet the needs of various business scenarios.

[0044] It should be understood that the contents described in the Summary of the Invention section are not intended to limit the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:

[0046] Figure 1 is a flowchart of an embodiment of a method for generating a geospatial index based on MongoDB according to the present application;

[0047] Figure 2 is a flowchart of an embodiment of a MongoDB-based geospatial retrieval method according to the present application;

[0048] Figure 3 This is a schematic diagram of the structure of a computer system of a terminal device or server used to implement an embodiment of the present application;

[0049] Figure 4 It is the existing MongoDB geospatial region data relationship definition diagram;

[0050] Figure 5 is a diagram defining the relationship between data in geographic space regions according to an embodiment of the present application;

[0051] Figure 6 is a flowchart of generating an inter-region intersection relationship index according to an embodiment of the present application;

[0052] Figure 7 is a flowchart of generating an inter-region inclusion relationship index according to an embodiment of the present application;

[0053] Figure 8 This is a flowchart of generating an inter-region inclusion relationship index according to an embodiment of the present application. DETAILED DESCRIPTION

[0054] To make the purpose, technical solutions, and advantages of the embodiments of the present disclosure more clear, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making any creative efforts are within the scope of protection of the present disclosure.

[0055] In this document, the term "and / or" simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " in this document generally indicates that the related objects are in an "or" relationship.

[0056] Figure 4 The data relationship between geographic spatial regions in the existing MongoDB is shown, which shows the existing intersects index and within index and their corresponding inter-region relationships. The intersects index is implemented by the intersects function, and the within index is implemented by the within function. It should be noted that in Figure 4 The relationship description of AF is separate, but there is no separate relationship judgment in the existing MongoDB. Figure 4 The separate relationship added is only for a better understanding of this solution.

[0057] To better understand this solution, first define the various operation symbols and letters that may be used below:

[0058] A is the given area;

[0059] X is the region containing A;

[0060] Represents mathematical logic "not";

[0061] “∩” represents the intersects function in MongoDB, which is the logical “intersection” in MongoDB;

[0062] Represents the within function in MongoDB, which is the logical "inclusion" in MongoDB;

[0063] “&&” represents the mathematical logic “AND”.

[0064] like Figure 11 is a flowchart 100 of a method for generating a geographic spatial index based on MongoDB according to an embodiment of the present application.

[0065] The MongoDB-based geospatial index generation method of this embodiment includes the following steps:

[0066] S110 , obtaining the intersects and / or within functions of MongoDB, wherein the intersects function is used to generate a geospatial index intersects, and the within function is used to generate a geospatial index within.

[0067] S120 : Generate indexes of separation, intersection, and / or inclusion relationships between regions through logical operations according to the intersects and / or within functions.

[0068] In this application, the geospatial relationships within MongoDB are redefined, such as Figure 5 As shown:

[0069] AB: defined as the containment relationship between regions;

[0070] AC: defined as the intersects relationship between regions;

[0071] AD: defined as the within relationship between regions;

[0072] AF: defined as the separate relationship between regions.

[0073] The specific method is as follows:

[0074] Generate an index of the inter-region separation relationship according to the intersects function; and / or

[0075] Generates indices of intersection and / or containment relationships between regions based on the intersects and within functions.

[0076] The intersects function generates the index of the inter-region separation relationship (separate). Specifically, the following formula is used to generate the index of the inter-region separation relationship (reference Figure 5 AF in ):

[0077]

[0078] Furthermore, the index of the intersecting relationship between regions is generated according to the intersects and within functions. Specifically, the index of the intersecting relationship between regions is generated by the following formula:

[0079]

[0080] refer to Figure 6 , which shows a flowchart of generating an inter-region intersection relationship index in this embodiment.

[0081] Specifically, first, use the intersects function in MongoDB to query areas B, C, and D that intersect with A, filter out area F that does not intersect with A, and then use the within function in MongoDB to query area B that is included in A, performing the inversion operation. Get the areas C and D that are not included in A, filter out the area B that covers (includes) A, and finally, use MongoDB's within function again to perform a negation operation in the area included in A Filter out area D included in A and obtain area C not included in A. The results between each step are "&&", and finally the intersection relationship retrieval function (AC) between regions is realized.

[0082] Furthermore, an index of the inter-region inclusion relationship is generated based on the intersects and within functions. Specifically, the index of the inter-region inclusion relationship is generated by the following formula:

[0083]

[0084] refer to Figure 7 , which shows a flowchart of generating an inter-region inclusion relationship index in this embodiment.

[0085] Specifically, first, use MongoDB's intersects function to query areas B, C, and D that intersect with A, filter out area F that does not intersect with A, and then use MongoDB's within function to query area B that is contained in A. The results between each step are separated by "&&" to implement the containment relationship retrieval function (AB) between areas.

[0086] Optionally, according to another embodiment of the present application, a method for generating an index of an inter-region inclusion relationship is provided.

[0087] Specifically, an index of the inclusion relationship between regions is generated by modifying the within function in MongoDB.

[0088] Will Figure 7 and Figure 8By comparison, it can be found that the within index in MongoDB is very similar to the contains index definition in this application. The implementation of the first step is exactly the same. In the second step, the within index function (AD) can be implemented by simply swapping the given area A and the query area X in the formula. That is, Change to MongoDB is an open source project, and its internal function expressions can be modified and configured. Therefore, we can add a contains function within the MongoDB source code, modeled after the within function. Specifically, we first obtain the key judgment expression of the within function in MongoDB, then replace the "<=" operator in the function expression with ">=", and then generate an index for the containment relationship between regions based on the modified function expression.

[0089] The MongoDB-based geospatial index generation method of this embodiment can generate indexes of separation, intersection and / or inclusion relationships between regions by merging and reusing the intersects and / or within functions in MongoDB, greatly simplifying the retrieval method and improving the accuracy of the retrieval. At the same time, it expands the functionality of the MongoDB database and can meet the needs of various business scenarios.

[0090] like Figure 2 As shown, another embodiment of the present application provides a flowchart 200 of a geospatial retrieval method based on MongoDB.

[0091] The MongoDB-based geospatial search method of this embodiment includes the following steps:

[0092] S210, receiving information of a given area;

[0093] The given area may be selected by the user by inputting an area number or selecting a box.

[0094] S220, using the index of the separation, intersection and / or inclusion relationship between regions generated by the embodiment of the MongoDB-based geospatial index generation method of the present application, the geospatial data stored in MongoDB is retrieved to obtain regions that are separated from the given region, regions that intersect with the given region, and / or regions that include the given region.

[0095] By using the index of the inter-region separation, intersection and / or inclusion relationship generated in the MongoDB-based geospatial index generation method in the embodiment, the inter-region separation, intersection and / or inclusion relationship is retrieved for the given area obtained in step S210 to obtain areas that are separated from the given area, areas that intersect with the given area and / or areas that include the given area.

[0096] The present application also provides a device, including:

[0097] one or more processors;

[0098] a storage device for storing one or more programs;

[0099] When the one or more programs are executed by the one or more processors, the one or more processors implement the above method.

[0100] In addition, an embodiment of the present application further proposes a computer-readable storage medium on which a computer program is stored, and the program implements the above method when executed by a processor.

[0101] Reference below Figure 3 , which shows a structural diagram of a computer system of a terminal device or server suitable for implementing an embodiment of the present application. Figure 3 The terminal device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.

[0102] like Figure 3 As shown, the computer system includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes based on programs stored in a read-only memory (ROM) 302 or programs loaded from a storage unit 308 into a random access memory (RAM) 303. Various programs and data required for system operation are also stored in the RAM 303. The CPU 301, ROM 302, and RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0103] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, and the like; an output section 307 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 308 including a hard disk and the like; and a communication section 309 including a network interface card such as a LAN card or a modem. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. Removable media 311, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 310 as needed, so that computer programs read therefrom can be installed in the storage section 308 as needed.

[0104] In particular, based on an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product comprising a computer program carried on a computer-readable medium, wherein the computer program includes program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 309, and / or installed from a removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, the above-mentioned functions defined in the method of the present application are executed.

[0105] It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.

[0106] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a unit, program segment or a part of code, and the unit, program segment or a part of code includes one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.

[0107] The units involved in the embodiments described in this application can be implemented by software or hardware. The units described can also be set in a processor. For example, it can be described as: a processor includes an information measurement unit, a driving trajectory determination unit, a mapping relationship determination unit, and a driving strategy generation unit. Among them, the names of these units do not constitute a limitation of the units themselves in some cases. For example, the information measurement unit can also be described as "a unit for measuring the status information of the vehicle and the surrounding scene information."

[0108] As another aspect, the present application also provides a non-volatile computer storage medium, which may be the non-volatile computer storage medium included in the apparatus described in the above embodiment; or a non-volatile computer storage medium that exists independently and is not installed in a terminal. The above non-volatile computer storage medium stores one or more programs, and when the one or more programs are executed by a device, the device: obtains MongoDB's intersects and / or within functions, the intersects function is used to generate a geographic spatial index intersects, and the within function is used to generate a geographic spatial index within; and generates an index of the separation, intersection, and / or inclusion relationship between regions through logical operations based on the intersects and / or within functions.

[0109] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this application.

Claims

1. A method for generating a geospatial index based on MongoDB, characterized in that: include: Obtain the intersects and / or within functions of MongoDB, wherein the intersects function is used to generate a geospatial index intersects, and the within function is used to generate a geospatial index within; Generate indexes of separation, intersection and / or inclusion relationships between regions through logical operations according to the intersects and / or within functions; Generating an index of the separation, intersection and / or inclusion relationship between regions through logical operations according to the intersects and / or within functions includes: generating an index of the separation relationship between regions according to the intersects function; and / or generating an index of the intersection and / or inclusion relationship between regions according to the intersects and within functions; Generating the index of the intersecting relationship between regions according to the intersects and within functions includes: generating the index of the intersecting relationship between regions by the following formula: The step of generating an index of inter-region separation relationships according to the intersects function includes: The index of the inter-region separation relationship is generated by the following formula: The indexes for generating the inclusion relationship between regions based on the intersects and within functions include: The index of the inclusion relationship between the regions is generated by the following formula: Where A is the given area; X is the region containing A; Represents logical "not"; "∩" represents the intersects function in MongoDB, which means the logical "intersection" in MongoDB; Represents the within function in MongoDB, that is, the logical "inclusion" in MongoDB; "&&" represents logical "and".

2. A geospatial retrieval method based on MongoDB, characterized in that: include: Receive information about a given area; The index of the separation, intersection and / or inclusion relationship between regions generated by claim 1 is used to search the geographic spatial data stored in MongoDB to obtain regions that are separated from the given region, regions that intersect with the given region and / or regions that include the given region.

3. A device, characterized in that include: one or more processors; a storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method according to claim 1 .

4. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to claim 1 is implemented.

Citation Information

Patent Citations

  • Geographical video data organization management method supporting storage and calculation linkage

    CN105354247A

  • Context-dependent display of contents on vehicle surfaces

    WO2019034262A1