Lightweight data retrieval method based on spatial retrieval
By using a toolkit to perform spatial relationship calculations and fuzzy matching on datasets, the problem of low efficiency and insufficient accuracy in spatial data retrieval in existing technologies has been solved, enabling efficient and flexible spatial range queries.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TAIHUA WISDOM IND GRP CO LTD
- Filing Date
- 2025-07-01
- Publication Date
- 2026-06-16
AI Technical Summary
Existing spatial data retrieval methods suffer from low retrieval comprehensiveness and high time and labor costs, especially in terms of low efficiency and difficulty in guaranteeing accuracy when retrieving data within a spatial range.
The dataset is loaded from the data management platform using a tool library, spatial elements are parsed into feature source objects, and spatial relationship operations are performed using the intersects() and contains() functions to filter out feature source objects that intersect or contain the spatial range. Combined with fuzzy matching algorithms and data format processing, the returned data that meets the user's requirements is generated.
It significantly improves the speed and accuracy of data retrieval within a spatial range, reduces reliance on database spatial query plugins, enhances query autonomy and flexibility, and ensures lightweight deployment and low resource utilization.
Smart Images

Figure CN120804076B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer data management technology, and more specifically, to a lightweight data retrieval method based on spatial retrieval. Background Technology
[0002] With the continuous advancement of urban digitalization, various government departments and units have accumulated a large amount of geospatial data, including basic information and geographic coordinates for various data across the city. Simultaneously, there are also rich spatial data resources such as city-wide spatial data, district / county spatial datasets, and street-level spatial datasets. Efficient retrieval and analysis of this spatial data is of vital importance for numerous fields, including urban planning, resource management, and emergency response.
[0003] In spatial data applications, it is often necessary to perform retrieval operations on elements within a spatial range, such as querying all points of interest or the distribution of specific facilities within a certain area on a map. This relies on effective spatial query techniques to obtain the required data information.
[0004] In the prior art, a Chinese patent application (application number: 202210672392.0, application date: June 15, 2022) discloses a method for gridded storage management of vector spatial information for large-scale satellite data, including the following steps: Step 1, dividing the geographic coordinate spatial range used by the vector spatial information into grids and numbering the grids; Step 2, converting the vector spatial information into the GeoJSON unified format, and saving each independent vector spatial object as a text file with the hash value of the geographic coordinate sequence as the filename; Step 3, establishing a logical connection index between the multi-dimensional vector spatial information and the corresponding numbered grids based on the spatial intersection relationship between the geographic coordinates and the numbered grids; Step 4, establishing a corresponding data management system based on the numbered grid storage model to realize the functions of adding, deleting, rewriting, and searching multi-dimensional vector spatial information. In other words, the prior art for spatial information data management is based on building an index for data retrieval, but this retrieval method can only perform one-to-one searches based on the index, resulting in low comprehensiveness of spatial range retrieval. Furthermore, this retrieval method requires prior index building, which incurs significant time and manpower costs.
[0005] Therefore, the present invention provides a lightweight data retrieval method based on spatial retrieval. Summary of the Invention
[0006] In view of this, the present invention provides a lightweight data retrieval method based on spatial retrieval, comprising:
[0007] Obtain a dataset, which includes spatial elements, and store the dataset in a data management platform;
[0008] Obtain the spatial range to be filtered, request parameters, and visualization scheme;
[0009] The dataset is loaded from the data management platform using a tool library, and the spatial elements in the dataset are parsed into feature source objects.
[0010] The aforementioned tool library is used to convert the spatial range into geometric objects to be filtered;
[0011] The `intersects()` function from the tool library is used to perform spatial relationship operations between the geometric object to be filtered and each of the feature source objects, filtering out the feature source objects that intersect the boundary of the geometric object to be filtered. The `contains()` function from the tool library is used to perform spatial relationship operations between the geometric object to be filtered and each of the feature source objects, filtering out the feature source objects located within the range of the geometric object to be filtered. The spatial elements corresponding to the feature source objects that intersect the boundary of the geometric object to be filtered and the feature source objects located within the range of the geometric object to be filtered are used to form a result set.
[0012] The request parameters are parsed to extract the query fields, query data types, and data formats. A fuzzy matching algorithm is used to match each query field with each spatial element in the result set, and the spatial elements that match the query fields are selected as matching spatial elements. Data is extracted from the matching spatial elements according to the query data types to obtain extracted data. The matching spatial elements and their corresponding extracted data are combined to form assembled data. The assembled data is formatted according to the data formats to obtain the returned data.
[0013] The returned data is rendered and displayed according to the visualization scheme.
[0014] Optionally, obtaining the dataset includes:
[0015] Online geographic data is obtained via a data interface;
[0016] Manually acquiring offline geographic data;
[0017] Convert the offline geographic data into electronic data;
[0018] The online geographic data and the electronic data are aggregated into electronic geographic data;
[0019] The dataset is obtained by cleaning, correcting, and standardizing the format of the electronic geographic data.
[0020] Optionally, the electronic geographic data is cleaned, including:
[0021] The electronic geographic data is processed using regular expressions and outlier detection algorithms to filter out duplicate, erroneous, and invalid data; the duplicate, erroneous, and invalid data are then removed.
[0022] Optionally, the electronic geographic data is corrected, including:
[0023] By using map positioning services and geographic information system technology, the location information of the electronic geographic data is cross-compared and the coordinates are calibrated.
[0024] Optionally, the tool library is used to convert the spatial extent into the geometric objects to be filtered, including:
[0025] The tool library determines whether the spatial range is circular or rectangular;
[0026] If the spatial range is circular, the tool library extracts the center and radius of the spatial range, and constructs a geometric object based on the center and radius of the spatial range as the geometric object to be filtered.
[0027] If the spatial range is rectangular, the tool library extracts the four vertices of the spatial range and constructs the geometric object based on the four vertices of the spatial range as the geometric object to be filtered.
[0028] Optionally, a fuzzy matching algorithm is used to perform matching operations between the query field and each spatial element in the result set, and the spatial elements that match the query field are selected as the matching spatial elements, including:
[0029] The query field is the name field;
[0030] A fuzzy matching algorithm is used to perform string matching between the name field and the information carried by each spatial element in the result set, and the spatial elements that match the query field are selected as the matching spatial elements.
[0031] Optionally, the extracted data is obtained by extracting data from the matching space elements according to the query data type, including:
[0032] According to the query data type, the information carried by the matching space element is subjected to at least one of the following processes: data type conversion, nested structure construction, data extraction according to the query data type, and data assembly, to obtain the extracted data.
[0033] Optionally, the extracted data is obtained by extracting data from the matching space elements according to the query data type, including:
[0034] The data type of the query is coordinate information;
[0035] The corresponding point coordinates are extracted from the information carried by the matching spatial elements as the extracted data.
[0036] Optionally, after constructing the assembled data from the matching spatial elements and their corresponding extracted data, the method further includes:
[0037] The integrity and accuracy of the assembled data are verified.
[0038] Optionally, the tool library is the GeoTools tool library, and the dataset is in GeoJSON format.
[0039] Compared with existing technologies, the lightweight data retrieval method based on spatial retrieval provided by this invention achieves at least the following beneficial effects:
[0040] 1. The lightweight data retrieval method based on spatial retrieval provided by this invention includes: loading a dataset from a data management platform using a tool library and parsing the spatial elements in the dataset into feature source objects; converting the spatial range into geometric objects to be filtered using the tool library; performing spatial relationship operations between the geometric objects to be filtered and each feature source object using the intersects() function in the tool library to filter feature source objects that intersect with the boundary of the geometric objects to be filtered; performing spatial relationship operations between the geometric objects to be filtered and each feature source object using the contains() function in the tool library to filter feature source objects that are within the range of the geometric objects to be filtered; and constructing a result set by combining the spatial elements corresponding to the feature source objects that intersect with the boundary of the geometric objects to be filtered and the feature source objects that are within the range of the geometric objects to be filtered. By utilizing the powerful spatial computing capabilities of the tool library combined with an optimized spatial filtering algorithm, spatial elements that intersect with or are contained within the spatial range can be quickly filtered, significantly improving query speed and accuracy, and effectively meeting the high-efficiency needs for spatial delineation and range query in various scenarios.
[0041] 2. The lightweight data retrieval method based on spatial retrieval provided by this invention does not rely on database spatial query plugins. It directly obtains datasets from the data management platform, improving the autonomy and flexibility of queries. The dataset is parsed and processed by a tool library to obtain the returned data. The level of detail and format of the returned data are determined according to the specific requirements given by the user, including request parameters and visualization schemes, ensuring lightweight deployment and low resource utilization.
[0042] Of course, any product implementing this invention does not necessarily need to achieve all of the technical effects described above at the same time.
[0043] Other features and advantages of the invention will become clear from the following detailed description of exemplary embodiments of the invention with reference to the accompanying drawings. Attached Figure Description
[0044] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments of the invention and, together with their description, serve to explain the principles of the invention.
[0045] Figure 1 This is a flowchart illustrating a lightweight data retrieval method based on spatial retrieval provided by the present invention.
[0046] Figure 2 This is another flowchart illustrating the lightweight data retrieval method based on spatial retrieval provided by the present invention.
[0047] Figure 3 This is a flowchart illustrating a process for obtaining a dataset.
[0048] Figure 4 This is another flowchart illustrating the lightweight data retrieval method based on spatial retrieval provided by the present invention. Detailed Implementation
[0049] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps set forth in these embodiments do not limit the scope of the invention.
[0050] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.
[0051] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.
[0052] In all the examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values.
[0053] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0054] Example 1
[0055] Reference Figure 1 , Figure 1 This is a flowchart illustrating a lightweight data retrieval method based on spatial retrieval provided by the present invention, to illustrate a specific embodiment of the lightweight data retrieval method based on spatial retrieval provided by the present invention, including:
[0056] S101: Obtain the dataset, which includes spatial elements, and store the dataset in the data management platform;
[0057] S102: Obtain the spatial range to be filtered, request parameters, and visualization scheme;
[0058] S103: Use the tool library to load the dataset from the data management platform and parse the spatial elements in the dataset into feature source objects;
[0059] S104: Use the tool library to convert the spatial extent into geometric objects to be filtered;
[0060] S105: Use the intersects() function in the tool library to perform spatial relationship operations between the geometric object to be filtered and each feature source object, and filter out the feature source objects that intersect with the boundary of the geometric object to be filtered. Use the contains() function in the tool library to perform spatial relationship operations between the geometric object to be filtered and each feature source object, and filter out the feature source objects that are within the range of the geometric object to be filtered. Combine the spatial elements corresponding to the feature source objects that intersect with the boundary of the geometric object to be filtered and the feature source objects that are within the range of the geometric object to be filtered to form a result set.
[0061] S106: Parse the request parameters, extract the query fields, query data types, and data formats, and use a fuzzy matching algorithm to match each query field with each spatial element in the result set, selecting spatial elements that match the query fields as matching spatial elements; extract data from the matching spatial elements according to the query data type to obtain extracted data, and combine the matching spatial elements and their corresponding extracted data to form assembled data; format the assembled data according to the data format to obtain the returned data;
[0062] S107: Render and display the returned data according to the visualization scheme.
[0063] It should be noted that in step S101, acquiring the dataset can be a periodic action, i.e., acquiring the dataset at preset time intervals and periodically updating the dataset stored on the data management platform to facilitate lightweight processing of spatial range retrieval in conjunction with the retrieval process. The dataset stored on the data management platform can be in a simple GeoJSON data format. Existing technologies primarily rely on database spatial query plugins and map service spatial query interfaces when performing element retrieval within a spatial range. While database spatial query plugins can utilize the database's own spatial indexing mechanism for data filtering, they have many limitations. For example, the interfaces of spatial query plugins for different databases are not standardized, which significantly increases the development and maintenance costs in multi-database environments; moreover, plugins are often deeply bound to specific databases, lacking versatility and flexibility. The method in this embodiment directly retrieves the dataset stored on the data management platform, which, compared to existing technologies, eliminates the dependence on database spatial query plugins and improves flexibility.
[0064] Understandably, traditional methods are inefficient in spatial delineation and range querying. Taking database spatial query plugins as an example, because they need to adapt to the complex indexing mechanisms of databases, and the index structures of different databases vary greatly, frequent and complex adaptation operations are required during queries, consuming significant computing resources and time, resulting in slow query speeds and difficulty in guaranteeing accuracy due to the limitations of the index. Map service spatial query interfaces are also prone to lag and difficulty in accurately delineating spatial ranges when transmitting massive amounts of data, constrained by factors such as network bandwidth and data format conversion. In steps S103 to S105, a tool library is used to load a dataset from the data management platform and parse the spatial elements in the dataset into feature source objects. The tool library is then used to convert the spatial range into geometric objects to be filtered. The `intersects()` function in the tool library is used to perform spatial relationship operations between each geometric object to be filtered and each feature source object, filtering out feature source objects that intersect the boundary of the geometric object to be filtered. The `contains()` function in the tool library is used to perform spatial relationship operations between each geometric object to be filtered and each feature source object, filtering out feature source objects located within the range of the geometric object to be filtered. The spatial elements corresponding to the feature source objects that intersect the boundary of the geometric object to be filtered and the feature source objects located within the range of the geometric object to be filtered constitute a result set. Specifically, this embodiment provides a calculation method for the `intersects()` and `contains()` functions:
[0065] The intersects() function determines whether geometric objects intersect. For two geometric objects A and B, intersects(A,B) returns a boolean value, which returns True if and only if the geometric shapes of A and B have at least one common point.
[0066] The specific formula is as follows:
[0067] Point P(x0,y0) lies on line segment AB(x1,y1)-(x2,y2) and must satisfy:
[0068] (y2-y1)x0-(x2-x1)y0+x2y1-y2x1=0 and x0 is in the range [min(x1,x2),max(x1,x2)], y0 is in the range [min(y1,y2),max(y1,y2)].
[0069] Substitute data and perform calculations:
[0070] point = Point(2,2);
[0071] line = LineString([(1,1),(3,3)]) print("Point and line intersect:",point.intersects(line)), outputs true.
[0072] The contains(A,B) statement means that A completely contains B, that is, all points of B are inside or on the boundary of A.
[0073] The calculation method is as follows:
[0074] Draw rays from point P in any direction and count the number of intersections with the boundary of polygon A. If the number of intersections is odd, the intersections are inside the polygon.
[0075] Substitute the data:
[0076] polygon = Polygon([(0,0),(0,4),(4,4),(4,0)]) # Square
[0077] point_inside = Point(2,2)
[0078] point_outside = Point(5,5) print("The face contains internal points:", polygon.contains(point_inside)) # Output True print("The face does not contain external points:", polygon.contains(point_outside)) # Output False
[0079] Leveraging the powerful spatial computing capabilities of the tool library combined with optimized spatial filtering algorithms, spatial elements that intersect with or are contained within a spatial range can be quickly filtered out, significantly improving query speed and accuracy. This effectively meets the high-efficiency needs for spatial delineation and range queries in various scenarios. Furthermore, the tool library parses and processes the dataset to obtain the returned data. Based on the user's specific requirements, including request parameters and visualization schemes, the level of detail and format of the returned data are determined, ensuring lightweight deployment and low resource consumption.
[0080] Example 2
[0081] Reference Figure 2 , Figure 3 and Figure 4 , Figure 2 This is another flowchart illustrating the lightweight data retrieval method based on spatial retrieval provided by the present invention. Figure 3 This is a flowchart illustrating a process for obtaining a dataset. Figure 4 This is another flowchart illustrating a lightweight data retrieval method based on spatial retrieval provided by the present invention, demonstrating another specific embodiment of the lightweight data retrieval method based on spatial retrieval provided by the present invention, including:
[0082] S201: Obtain the dataset, which includes spatial elements, and store the dataset in the data management platform.
[0083] Obtaining the dataset includes:
[0084] S2011: Obtain online geographic data via data interface;
[0085] S2012: Manual acquisition of offline geographic data;
[0086] S2013: Convert offline geographic data into electronic data;
[0087] S2014: Combine online geographic data and electronic data into electronic geographic data;
[0088] S2015: The dataset is obtained after cleaning, correcting and standardizing the format of electronic geographic data.
[0089] Cleaning electronic geographic data includes:
[0090] Regular expressions and outlier detection algorithms are used to process electronic geographic data to filter out duplicate, erroneous, and invalid data; these duplicate, erroneous, and invalid data are then removed.
[0091] Correcting electronic geographic data includes:
[0092] By leveraging map positioning services and Geographic Information System (GIS) technology, the location information of electronic geographic data is cross-compared and coordinates are calibrated.
[0093] Standardized format processing of electronic geographic data includes:
[0094] Standardized data templates are adopted, and data mapping and transformation tools are used to perform structured processing on data with different structures and encoding formats to ensure that all electronic geographic data conforms to unified standards.
[0095] S202: Obtain the spatial range to be filtered, request parameters, and visualization scheme;
[0096] S203: Use a tool library to load a dataset from the data management platform and parse the spatial elements in the dataset into feature source objects;
[0097] S204: Use the tool library to convert the spatial range into geometric objects to be filtered, including: the tool library determines whether the spatial range is a circle or a rectangle;
[0098] S2041: If the spatial range is circular, the tool library extracts the center and radius of the spatial range, and constructs a geometric object based on the center and radius of the spatial range as the geometric object to be filtered.
[0099] S2042: If the spatial range is rectangular, the tool library extracts the four vertices of the spatial range and constructs a geometric object based on the four vertices of the spatial range as the geometric object to be filtered.
[0100] S205: Use the intersects() function in the tool library to perform spatial relationship operations between the geometric object to be filtered and each feature source object, and filter out the feature source objects that intersect with the boundary of the geometric object to be filtered. Use the contains() function in the tool library to perform spatial relationship operations between the geometric object to be filtered and each feature source object, and filter out the feature source objects that are within the range of the geometric object to be filtered. Combine the spatial elements corresponding to the feature source objects that intersect with the boundary of the geometric object to be filtered and the feature source objects that are within the range of the geometric object to be filtered to form a result set.
[0101] S206: Parse the request parameters, extract the query fields, query data type, and data format, and use a fuzzy matching algorithm to match each query field with each spatial element in the result set, filtering out spatial elements that match the query fields as matching spatial elements, including:
[0102] The query field is the name field;
[0103] A fuzzy matching algorithm is used to perform string matching between the name field and the information carried by each spatial element in the result set, and the spatial elements that match the query field are selected as the matching spatial elements.
[0104] S207: Extract data from the matching spatial elements based on the query data type to obtain the extracted data, including:
[0105] Based on the query data type, the information carried by the matching spatial elements is processed by at least one of the following methods: data type conversion, nested structure construction, data extraction according to the query data type, and data assembly, to obtain the extracted data.
[0106] S208: Combine the matching spatial elements and their corresponding extracted data to form the assembled data.
[0107] S209: Verify the integrity and accuracy of the assembly data.
[0108] S2091: If the integrity and accuracy checks pass, the assembled data is formatted according to the data format to obtain the returned data.
[0109] S2091: If the integrity and accuracy verification fails, the search can be terminated or data correction can be performed. This can be set according to the actual situation, and this embodiment does not impose specific restrictions on it.
[0110] S210: Render and display the returned data according to the visualization scheme.
[0111] It should be noted that in step S201, online geographic data is acquired via a data interface. To ensure the comprehensiveness and accuracy of the acquired online geographic data, efficient network communication technology and customized data transmission protocols are required. It is also necessary to find accurate information sources. For example, basic information such as the registration and operating status of market entities within a specific scope can be obtained from a big data bureau via a professional data interface, along with the geographic coordinates of their registered addresses. In collaboration with the planning bureau, detailed data on resources and assets such as land and real estate can be collected, their geographic distribution coordinates clarified, and online geographic data aggregated. Online geographic data can cover detailed geospatial information such as urban topography, transportation artery layout, and distribution of large public facilities at the macro level, but it is not limited to these. By employing a professional data interface and utilizing high-concurrency data capture technology, tens of thousands of data requests can be processed per second. Combined with an intelligent caching mechanism and a distributed acquisition architecture, target data can be collected quickly and accurately. This ensures comprehensive and accurate acquisition of online geographic data and its secure and stable aggregation.
[0112] Online geographic data may be incomplete, requiring manual refinement. This can be achieved by manually collecting spatial data specific to each district and county, including current land use, industrial park planning, and the distribution of educational and medical resources. This detailed data meticulously depicts the spatial characteristics and development layout of each district and county, providing rich regional information for spatial retrieval. Alternatively, grassroots management agencies can focus on collecting micro-level spatial data such as building distribution, commercial network layout, and population density at the street level. This data accurately reflects the actual situation at the street level, providing strong support for refined urban management and spatial retrieval. Manually acquired data may be in paper form, which is inconvenient to manage. It can be converted into electronic data through interfaces or document scanning and then aggregated with online geographic data to form electronic geographic data.
[0113] Through a rigorous aggregation process, spatial data from different levels and fields are integrated into a unified data management platform, making it a solid foundational data source for subsequent spatial retrieval.
[0114] After obtaining the electronic geographic data, it is cleaned to remove duplicates, errors, and invalid data, completing the initial processing. Next, the cleaned electronic geographic data undergoes correction to effectively rectify location deviations caused by signal drift and data errors. Then, the corrected electronic geographic data is processed to unify its format. Data mapping and conversion tools are used to structure data with different structures and encoding formats, ensuring that all data conforms to unified standards. In this embodiment, the electronic geographic data after cleaning, correction, and format unification is in a concise and standardized GeoJSON format, facilitating subsequent parsing and processing. Through a secure and stable data transmission channel, the processed electronic geographic data is promptly aggregated to the data management platform in real-time streaming or batch transmission. A data transmission monitoring mechanism can also be established to track the progress and integrity of data transmission in real time, ensuring efficient and accurate data collection and laying a solid foundation for subsequent data analysis and application.
[0115] In steps S203 to S205, the GeoTools tool library is used to parse and process GeoJson data. The GeoTools data reading module loads the dataset and parses it into operable FeatureSource objects, providing a data foundation for subsequent filtering. The GeoTools spatial computation engine is used to construct and manipulate geometric objects. By parsing a given spatial range, it generates Geometry instances corresponding to that range, i.e., the geometric objects to be filtered, which serve as the reference standard for filtering. The GeoTools iteratively processes the loaded dataset. The FeatureSource obtains a FeatureIterator, traversing each spatial element in the dataset row by row. Using spatial relationship judgment methods provided by the GeoTools tool library, such as the intersects() and contains() functions, spatial relationship calculations are performed between the feature source objects of the spatial elements and the reference geometric objects to be filtered. The intersects() function is used to determine whether there is an intersection between the feature source objects of the spatial elements and the boundaries of the geometric objects to be filtered; the contains() function is used to determine whether the feature source objects of the spatial elements are completely contained within the range of the geometric objects to be filtered. When either of the above two conditions is met, the spatial element is selected and added to the result set, thus completing the selection of spatial elements and providing accurate data support for subsequent spatial analysis and data application.
[0116] In this embodiment, step S206 can specifically involve: parsing the request parameters, extracting query fields such as keywords for spatial element names, structuring the request data using a JSON or XML parsing tool, and traversing the spatial element dataset within the filtered query range based on the parsed query fields. For each spatial element, its corresponding field is extracted and matched against the user input field, for example, using a fuzzy matching algorithm to find spatial elements whose names meet the conditions. This embodiment provides a calculation method in step S206 that uses a fuzzy matching algorithm to match the query fields with each spatial element in the result set, filtering out spatial elements that match the query fields as matching spatial elements, including:
[0117] Calculation formula:
[0118] Substitute the data:
[0119] features = [
[0120] {"name": "A certain park", "geometry": "POLYGON((116.28 39.98, 116.34 0.0, 116.32 39.99, 116.28 39.98))", "location": "H District, B City"},
[0121] {"name": "A certain park", "geometry": "POLYGON((116.43 9.96, 116.42 39.98, 116.44 39.97, 116.43 9.96))", "location": "C District, B City"},
[0122] {"name": "A certain beach", "geometry": "POLYGON((121.49 31.23, 121.51 31.24, 121.53 1.22, 121.49 31.23))", "location": "H District, S City"},
[0123] {"name": "A certain park", "geometry": "POLYGON((116.45 39.9, 116.47 39.92, 116.46 39.89, 116.45 39.9))", "location": "C District, B City"}]
[0124] contains_match = gdf[gdf['name'].str.contains(query)] print("Contains match results:", contains_match['name'].tolist())。
[0125] In step S207, for the spatial elements that match the query fields, the detailed data fields expected by the user (i.e., the query data type) are precisely matched with the fields in the original data carried by the matching spatial elements to determine the detailed information fields that need to be obtained. The query data type can be divided into returning simple data and returning complex data. If simple data is returned, specifically: the query data type is coordinate information; the corresponding point coordinates are extracted from the information carried by the matching spatial elements as extracted data. When the extracted data is combined with the matching spatial elements to form assembled data, the assembled data can be a JSON format array, returned through the API interface. If complex data is returned, not only are the user-specified query fields extracted, but also the detailed data fields expected by the user are obtained. Based on the detailed data field requirements expected by the user, an SQL query statement is constructed or the corresponding data query interface is called to retrieve complete and detailed spatial element information from the data management platform. The obtained data is assembled according to the format required by the user request, which may involve data type conversion, nested structure construction, etc. Of course, refer to... Figure 4 If the data type in the user's request parameters does not require detailed data to be returned, the matching spatial elements can also be returned as the returned data through the API interface.
[0126] In this embodiment, data queries are performed directly within a specified range by reading structured data that has been aggregated into a unified data management platform. Based on the coordinate information of the spatial range, data records that meet the criteria are located within the structured data. For example, for a geographic coordinate data record, it is determined whether its coordinates are within the user-specified spatial range; if they are, the record is included in the result set.
[0127] After constructing the result set, the required data is extracted and then displayed. In step S210, the display module selects an appropriate visualization scheme based on the data type and user preferences. If the user prefers a visually intuitive map display, map frameworks such as Leaflet and OpenLayers are used to mark the coordinate points in the result set on the map in the form of icons, heatmaps, etc., and support clicking on the coordinate points to pop up detailed information windows. If the user needs data reports, chart libraries such as ECharts and Highcharts are used to convert the coordinate data and related attributes into visual charts such as bar charts, line charts, and scatter plots. At the same time, the latitude and longitude coordinates are formatted and appropriate decimal places are retained, making the displayed data both professional and easy to understand, providing users with a high-quality data visualization experience.
[0128] It is understood that this embodiment realizes an innovative way to obtain data directly from the data source without relying on a database space query plugin, which improves the autonomy and flexibility of the query, effectively solves the shortcomings of the existing technology, and provides a more powerful tool for data space query.
[0129] As can be seen from the above embodiments, the lightweight data retrieval method based on spatial retrieval provided by the present invention achieves at least the following beneficial effects:
[0130] 1. The lightweight data retrieval method based on spatial retrieval provided by this invention includes: loading a dataset from a data management platform using a tool library and parsing the spatial elements in the dataset into feature source objects; converting the spatial range into geometric objects to be filtered using the tool library; performing spatial relationship operations between the geometric objects to be filtered and each feature source object using the intersects() function in the tool library to filter feature source objects that intersect with the boundary of the geometric objects to be filtered; performing spatial relationship operations between the geometric objects to be filtered and each feature source object using the contains() function in the tool library to filter feature source objects that are within the range of the geometric objects to be filtered; and constructing a result set by combining the spatial elements corresponding to the feature source objects that intersect with the boundary of the geometric objects to be filtered and the feature source objects that are within the range of the geometric objects to be filtered. By utilizing the powerful spatial computing capabilities of the tool library combined with an optimized spatial filtering algorithm, spatial elements that intersect with or are contained within the spatial range can be quickly filtered, significantly improving query speed and accuracy, and effectively meeting the high-efficiency needs for spatial delineation and range query in various scenarios.
[0131] 2. The lightweight data retrieval method based on spatial retrieval provided by this invention does not rely on database spatial query plugins. It directly obtains datasets from the data management platform, improving the autonomy and flexibility of queries. The dataset is parsed and processed by a tool library to obtain the returned data. The level of detail and format of the returned data are determined according to the specific requirements given by the user, including request parameters and visualization schemes, ensuring lightweight deployment and low resource utilization.
[0132] While specific embodiments of the invention have been described in detail by way of examples, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.
Claims
1. A lightweight data retrieval method based on spatial retrieval, characterized in that, include: Obtain a dataset, which includes spatial elements, and store the dataset in a data management platform; Obtain the spatial range to be filtered, request parameters, and visualization scheme; The dataset is loaded from the data management platform using a tool library, and the spatial elements in the dataset are parsed into feature source objects. The tool library is used to convert the spatial extent into geometric objects to be filtered, including: The tool library determines whether the spatial range is circular or rectangular; If the spatial range is circular, the tool library extracts the center and radius of the spatial range, and constructs a geometric object based on the center and radius of the spatial range as the geometric object to be filtered. If the spatial range is rectangular, the tool library extracts the four vertices of the spatial range and constructs the geometric object based on the four vertices of the spatial range as the geometric object to be filtered. The `intersects()` function from the tool library is used to perform spatial relationship operations between the geometric object to be filtered and each of the feature source objects, filtering out the feature source objects that intersect the boundary of the geometric object to be filtered. The `contains()` function from the tool library is used to perform spatial relationship operations between the geometric object to be filtered and each of the feature source objects, filtering out the feature source objects located within the range of the geometric object to be filtered. The spatial elements corresponding to the feature source objects that intersect the boundary of the geometric object to be filtered and the feature source objects located within the range of the geometric object to be filtered are used to form a result set. The request parameters are parsed to extract the query fields, query data types, and data formats. A fuzzy matching algorithm is used to match each query field with each spatial element in the result set, and the spatial elements that match the query fields are selected as matching spatial elements. Data is extracted from the matching spatial elements according to the query data types to obtain extracted data. The matching spatial elements and their corresponding extracted data are combined to form assembled data. The assembled data is formatted according to the data formats to obtain the returned data. The returned data is rendered and displayed according to the visualization scheme.
2. The lightweight data retrieval method based on spatial retrieval according to claim 1, characterized in that, Obtaining the dataset includes: Online geographic data is obtained via a data interface; Manually acquiring offline geographic data; Convert the offline geographic data into electronic data; The online geographic data and the electronic data are aggregated into electronic geographic data; The dataset is obtained by cleaning, correcting, and standardizing the format of the electronic geographic data.
3. The lightweight data retrieval method based on spatial retrieval according to claim 2, characterized in that, Cleaning the electronic geographic data includes: The electronic geographic data is processed using regular expressions and outlier detection algorithms to filter out duplicate, erroneous, and invalid data; the duplicate, erroneous, and invalid data are then removed.
4. The lightweight data retrieval method based on spatial retrieval according to claim 2, characterized in that, Correcting the electronic geographic data includes: By using map positioning services and geographic information system technology, the location information of the electronic geographic data is cross-compared and the coordinates are calibrated.
5. The lightweight data retrieval method based on spatial retrieval according to claim 1, characterized in that, A fuzzy matching algorithm is used to match the query field with each spatial element in the result set, and the spatial elements that match the query field are selected as the matching spatial elements, including: The query field is the name field; A fuzzy matching algorithm is used to perform string matching between the name field and the information carried by each spatial element in the result set, and the spatial elements that match the query field are selected as the matching spatial elements.
6. The lightweight data retrieval method based on spatial retrieval according to claim 1, characterized in that, The extracted data is obtained by extracting data from the matching space elements according to the query data type, including: According to the query data type, the information carried by the matching space element is subjected to at least one of the following processes: data type conversion, nested structure construction, data extraction according to the query data type, and data assembly, to obtain the extracted data.
7. The lightweight data retrieval method based on spatial retrieval according to claim 1, characterized in that, The extracted data is obtained by extracting data from the matching space elements according to the query data type, including: The data type of the query is coordinate information; The corresponding point coordinates are extracted from the information carried by the matching spatial elements as the extracted data.
8. The lightweight data retrieval method based on spatial retrieval according to claim 1, characterized in that, After constructing the assembled data from the matching spatial elements and their corresponding extracted data, the method further includes: The integrity and accuracy of the assembled data are verified.
9. The lightweight data retrieval method based on spatial retrieval according to claim 1, characterized in that, The tool library used is GeoTools, and the dataset is in GeoJSON format.