## 3 Proposed Methodology
### Indexing Strategy Based on Quadtree
#### 3.2.2 Indexing Algorithm  
Algorithm 1 provides the construction algorithm for the quadtree. In the quadtree construction algorithm, a new node is first created, and its coordinate information is determined, along with the effective compression of spatiotemporal data within the corresponding range. Subsequently, as a result of the calculation of the PSNR and MAE of the spatiotemporal data within that range, the node is assigned quality assessment information, reflecting the effectiveness and accuracy of data compression. If the current node's layer reaches the preset maximum layer, the algorithm returns the node; otherwise, the algorithm calculates the midpoint coordinates based on the current node's coordinate information and recursively constructs four child nodes, corresponding to the four subdivided subregions. This process achieves hierarchical management of spatiotemporal data while constructing the quadtree, providing an efficient spatial structure for subsequent data queries and retrieval. ```
Input: spatial data \(D\), x-coordinate of the top left corner \(lx\), y-coordinate of the top left corner \(ly\), x-coordinate of the bottom right corner \(rx\), y-coordinate of the bottom right corner \(ry\), the number of the layers \(n\) Output: the root node of the quadtree
1. \(node\leftarrow\) create a new node of quadtree
2. \(node.lx\gets lx\)
3. \(node.ly\gets ly\)
4. \(node.rx\gets rx\)
5. \(node.ry\gets ry\)
6. //compress the data in rectangular range (\(lx\), \(ly\))-(\(rx\), \(ry\))
7. \(node.data\leftarrow\) compress\(\_\)data\(\_\)with\(\_\)range(\(D\), \(lx\), \(ly\), \(rx\), \(ry\))
8. // calculate the PSNR of the data in rectangular range (\(lx\), \(ly\))-(\(rx\), \(ry\))
9. \(node.PSNR\leftarrow\) calculate\(\_\)PSNR\(\_\)with\(\_\)range(\(D\), \(lx\), \(ly\), \(rx\), \(ry\))
10. // calculate the MAE of the data in rectangular range (\(lx\), \(ly\))-(\(rx\), \(ry\))
11. \(node.MAE\leftarrow\) calculate\(\_\)MAE\(\_\)with\(\_\)range(\(D\), \(lx\), \(ly\), \(rx\), \(ry\))
12. \(node.bottom\_left\_child\leftarrow\)null
13. \(node.bottom\_right\_child\leftarrow\)null
14. \(node.top\_left\_child\leftarrow\)null
15. \(node.top\_right\_child\leftarrow\)null
16. \(i\)\(n==1\)then
17. return\(node\)
18. endif
19. \(midx\leftarrow\left\lfloor\frac{lx+rx}{2}\right\rfloor\)
20. \(midy\leftarrow\left\lfloor\frac{ly+ry}{2}\right\rfloor\)
21. \(node.top\_left\_child\leftarrow\) build\(\_\)quadtree(\(D\), \(lx\), \(midx\), \(ly\), \(midy\), \(midmidy\))
22. \(node.top\_right\_child\leftarrow\) build\(\_\)quadtree(\(D\), \(lx\), \(midmidx\), \(midmidy\)+1, \(ry\))
23. \(node.bottom\_left\_child\leftarrow\) build\(\_\)quadtree(\(D\), \(midmidx\)+1, \(rx\), \(ly\), \(midmidy\))
24. \(node.bottom\_right\_child\leftarrow\) build\(\_\)quadtree(\(D\), \(midmidx\)+1, \(rx\), \(midmidy\)+1, \(ry\))
25. return node
```  
**Algorithm 1**build\(\_\)quadtree  
Algorithm 2 provides the range query algorithm. In the range query algorithm, the quadtree structure is traversed, and nodes are checked based on specific conditions and the spatial relationship with the specified query rectangle. During this process, relevant spatiotemporal data within nodes that meet the query conditions are decompressed, and concatenation operations are performed to ensure that the final result is presented in a consistent structure and only contains data within the query space range. To obtain detailed information, the algorithm recursively calls potentially overlapping child nodes to collect the required data. Ultimately, this query algorithm provides comprehensive output tailored to the query parameters, effectively supporting spatial retrieval needs for spatiotemporal data. ```
1. ```
2.