# An Optimization Technique of the 3D Indoor Map Data Based on an Improved Octree Structure

Authors: Xiaomin Yu; Huiqiang Wang; Hongwu Lv; Junqiang Fu
Journal: Mathematical Problems in Engineering
 (2020)

---

## Abstract

The construction and retrieval of indoor maps are important for indoor positioning and navigation. It is necessary to ensure a good user experience while meeting real-time requirements. Unlike outdoor maps, indoor space is limited, and the relationship between indoor objects is complex which would result in an uneven indoor data distribution and close relationship between the data. A data storage model based on the octree scene segmentation structure was proposed in this paper initially. The traditional octree structure data storage model has been improved so that the data could be backtracked. The proposed method will solve the problem of partition lines within the range of the object data and improve the overall storage efficiency. Moreover, a data retrieval algorithm based on octree storage structure was proposed. The algorithm adopts the idea of “searching for a point, points around the searched point are within the searching range.” Combined with the octree neighbor retrieval methods, the closure constraints are added. Experimental results show that using the improved octree storage structure, the retrieval cost is 1/8 of R-tree. However, by using the neighbor retrieval, it improved the search efficiency by about 27% on average. After adding the closure constraint, the retrieval efficiency increases by 25% on average.


---

## Body

## 1. Introduction

Nowadays, people have higher requirements for using the electronic map due to the popularization of electronic map application and the rapid development of related technologies. The traditional two-dimensional map cannot meet the latest requirements in terms of visual effects. Surveys showed that people are spending more time in indoor environment nowadays, including shopping malls, exhibition halls, libraries, cruise ships, and many other large-scale indoor environments [1]. The existence of three-dimensional indoor map is of practical significance [2]. Data storage efficiency, retrieval consumption, time delay, and other parameters will directly affect the application level of the maps [3]. Consequently, the efficient management of the indoor map data has become a major challenge.At present, all walks of life, including the fields of map, are faced with the problem that huge data is difficult to store and complex to query [4]. Since the data sets of a map scene are very large, they are not able to be stored directly by the indexes. Therefore, a scene segmentation method is needed as a secondary index to reduce the data storage unit and achieve the lightweight storage. Generally speaking, due to the different environment, maps can be divided into outdoor maps and indoor maps. The regional segmentation technology is preferable as the outdoor scene is large and uneven, and the map data is stored as sheet. Compared with the outdoor map, the indoor map includes numerous objects, and the volume of the objects is small. The situation of uneven distribution often exists. If the sheet framing is used, a large number of objects may be distributed in a sheet. This extreme situation will reduce the regional segmental effect. In order to solve this problem, it is necessary to continue the segmentation, which will increase the cost of scene segmentation. The sheet framing cannot meet the vertical requirement between different floors and cannot preserve the three-dimensional nature of the data.The technology of the storage of outdoor map data has developed rapidly, while the indoor map data storage is still in the initial stage [5] of development. For the indoor data storage, the scene can be divided by tree structure, and the octree is one of the high-efficiency scene segmentation methods, which can realize the rapid segmentation of 3D map scene and retain the characteristics of map data [6]. However, at present, this method is mainly applied in the field of game scene and 3D image processing, and there are few applications for indoor map. Moreover, indoor map data is updated more frequently, and there are room partitions between the data. Therefore, the traditional scene segmentation methods are not applicable for the indoor map data [7]. One of the key problems is to design a set of storage structure suitable for indoor map features based on fast scene segmentation method.The efficiency of the octree structure in the scene segmentation is very high. However, its performance in data retrieval is not ideal. After scene segmentation using octree structure, map data will be stored in corresponding nodes. We need to traverse every required data tree, so the efficiency of querying and updating indoor map data is not high. This leads to another key problem, which is improving the efficiency of data retrieval and ensuring high storage efficiency.In this paper, a set of indoor map data storage model based on the scene segmentation is designed, which can fulfill the scene segmentation, code design, data expression, and storage structure design. And a fast data retrieval method based on the data storing models is also proposed. These results provide an efficient data storage and retrieval scheme.


## 2. Related Works

At present, map data processing software (such as ArcGIS) or domestic emerging software (including SuperMap) mostly adopt the scene segmentation for data unit division and form a map data index structure. The ArcGIS SDE of Esri supports fixed grid scene segmentation structure, while MapGIS and SuperMap support quad-tree scene segmentation structure. Furthermore, ArcView and MapInfo support R-tree scene segmentation structure, while Oracle Spatial supports both R-tree and quad-tree scene segmentation structure [8].Fixed grid is a kind of scene segmentation structure which is widely used in two-dimensional space environment. Its specific principle is to use a preset size mesh to segment the scene and form a rectangular pixel of equal size. Each rectangular cell is uniquely annotated and recorded according to the row number and the column number. The contents stored in the rectangle cell area are related to the information and properties of the data. The data in the whole scene find their respective storage locations through uniquely marked rectangular area [9].And when it is necessary to retrieve the data from the scene, the location of the cell can be located by querying the row number and the column number. Since there may be multiple data in each cell, it is also necessary to compare the data attribute values to determine the retrieved data. According to the research conducted by Qiao [10], data retrieval with fixed grid method can be divided into accurate retrieval and range retrieval. Accurate retrieval can complete the search of row number and column number to uniquely determine the cell location, but it still needs range retrieval to continue to retrieve all units that intersect the range retrieved in the first step. One of the studies conducted by Yang [11] pointed out that due to the variety of map data, when the data attributes were particularly complex, it would lead to the redundancy of the index records and reduce the efficiency of data retrieval. This method is similar to the rectangle framing and longitude latitude framing in the map, and it is more suitable for two-dimensional space.Originally as an index method, R-tree structure was proposed by Guttman in 1984. This structure is applicable to both two-dimensional environment and three-dimensional environment, and it is an extension of B-tree [12]. Many researches have been carried out on the deformation of R-tree, and specific needs have been met [13]. These studies often expand R-tree node and store some properties similar to topological relationship. However, this method will double the stored information which increases the burden to the storage and cause the problem of data redundancy.The study carried out by Wang et al. [14] proposed a method combining R-tree and the octree to manage large-scale three-dimensional scene. Its advantage is to implement dynamic, efficient, and real-time management of the change data during the interaction. It makes the rendering picture smoother, resulting in a significant reduction in rendering time. However, due to fusing two types of complex structures, it will consume more time to construct the data structure. The study carried out by Namdari et al. [15] proposed an efficient parallelization task execution method based on R-tree. By designing the storage structure, the problem of limited parallelization effect of R-tree on GPU was solved, and a fast search method of R-tree was proposed. R-tree is one of the commonly used storage methods at present, but the objects in the indoor scene are placed with a large density and uneven distribution, so this method is not much applicable [16].As a scene segmentation method of tree structure, the quad-tree is mainly applied to two-dimensional scene. It uses the fixed grid structure to divide each space into four rectangular areas. It can achieve more efficient space segmentation compared with the grid structure. Compared with R tree, quad-tree structure is relatively simple, so its construction time is shorter. Due to the regularity of each recursion, each quad-tree node can be encoded. The data retrieval can be completed by encoding. This structure is more suitable for two-dimensional space scenes similar to the fixed grid structure [17].The octree structure was first proposed by Meagher in 1982 [18]. It is an extension of the quad-tree in three-dimensional environment [19], and it has the characteristic of flexibility and extensibility [20]. It is a popular method in the field of 3D image processing and spatial data index [21] and has a better effect than R-tree [22]. The octree has been applied in the storage of 3D objects data such as iron and steel industry, etc. [23]. Riegler et al. [24] and Tatarchenko et al. [25] proposed a fast scene reconstruction method by taking advantage of the regularity of the octree segmentation. Deng et al. [26] proposed a method to add an update memo in the octree, which improves the update efficiency and significantly reduces the update cost of 3D objects.These methods can initially realize the basic storage of 3D spatial data, but due to the large density and uneven distribution of indoor map data, these storage processes have many disadvantages in some aspects.When the map scene is segmented by the octree, the objects’ data is stored in the nodes. In this way, when retrieving objects, it needs to go through the tree. So, it is very tedious for the data with large retrieval requirements. Many scholars have studied the retrieval method, and the current aspect is the retrieval of neighbor nodes. The neighbor query is divided into four classes [27]: (i) all objects are also the query points. This is known as an all-kNN query (akNN); (ii) only selected objects are the query points. This is known as a Group Nearest Neighbor (GNN); (iii) there is a variant of GNN, which is called Group Nearest Group (GNG); and (iv) only object locations within a given rectangle are the query points. This is known as a Range-kNN query. Optimization techniques used include machine learning [28–30], deep learning [31, 32], and optimization technologies for transportation [33–35]. The study carried out by Pan et al. [31] proposed a fine-grained classification model named RMA (ResNet-Multiscale-Attention) based on deep learning to analyze the subtle and local differences among navigation mark types for the recognition of navigation marks. The study carried out by Pan et al. [32] proposed a CNN-GRU model combined with the network structures of gated recurrent unit (GRU) and convolutional neural network (CNN). The GRU part learned the changing trend of water level, and the CNN part learned the spatial correlation among water level data observed from adjacent water stations.The study carried out by Cho et al. [36] proposed a neighbor retrieval method, which took advantage of the regularity of the octree segmentation and could find out the 26 neighboring nodes by calculating the offset in three directions of x, y, and z. However, the neighbors search was done after the tree is built again. This approach is simple and does not add any time complexity. Furthermore, Namdari et al. improved on this basis [15] and proposed an improved neighbor retrieval method, which stored the neighbors of all leaf nodes in the process of building the tree. It has the advantage of conventional octree partitioning. Storing neighbors when building a tree will not cause damage to the complexity of building tree. They proved that the sum of time for retrieval, storing neighbors, and building tree is not much different from the time it takes to create the tree alone.Although the neighbor node search method is feasible, it does not need all 26 neighbor nodes for the indoor scene of closed room. There is still some unnecessary consumption, and the efficiency needs to be further improved. In this study, we proposed an octree-based data storage model with backtracking and an octree neighbor retrieval algorithm with closed constraints.


## 3. Materials and Methods

### 3.1. Map Scene Segmentation

The octree storage model usually consists of three parts: scene segmentation, node coding, and data representation. The basic principle to fulfill the function is using the octree to segment 3D scene regularly, using octree code to encode the route of each node [37]. The cube boxes are further used to express the objects approximately, and the codes are stored in the corresponding nodes according to the size and location of the boxes [38–40].


#### 3.1.1. Octree Scene Segmentation Technology

The octree is a regular segmentation data structure. It approximately takes the overall scene of a three-dimensional indoor map as a cube and takes it as the root node of the tree. Moreover, it divides the scene into 8 or 0 pieces at a time during scene segmentation. Its schematic diagram is shown in Figure1, and its definition is as follows:(1)octree=vi=18vi−1,di=12di−1,hi=hi−1+1,n>2,end of separation,n≤2ordi=dmin,where vi,di,andhi are the volume, side length, and depth of the cube obtained by the ith division, respectively, n is the number of objects contained in the cube, and dmin is the minimum side length that the cube can be separated into.Figure 1
The octree scene segmentation schematic diagram.There are three types of nodes in an octree. In order to distinguish them, three colors are used in this paper. The white nodes indicate that no data has been stored, whereas gray nodes indicate that more than two objects’ data have been stored and black nodes indicate that one- or two-object data have been stored. White and black nodes can be regarded as leaf nodes, and gray nodes need to be further segmented. This segmentation is a recursive process, whose termination condition is that all nodes are leaf nodes or segmentation reaches the specified minimum segmentation area. Figure1 shows a twice-segmented tree structure, in which (a) is a schematic diagram of three-dimensional cube, whereas white circles represent the objects, and (b) is a schematic diagram of two-dimensional tree structure.After a three-dimensional map is recursively segmented by octree algorithm, many subregions will be formed, which are distributed in all the corners of the three-dimensional space.


#### 3.1.2. Octree Node Addressing Encoding

In order to make the data management organized in the octree data storage models, it is necessary to make clear position of each data corresponding to the tree. In this paper, the position of each subregion is marked by encoding. The node addressing code uses digits to mark the 8 child-nodes which were extracted from each node, so that the 3D data can be represented by one-dimensional digits. Among which the number of encoded bits is the same as the number of layers, and each encodes unique marks of the node region while recording the path of this node to the root node. The method of “push back” is used in encoding. The first segmented code is taken as the first digit, and the result of each recursive segmenting is added to the last several digits in turn. The segmented 8 subregions can be distinguished by the deviation degree from the three direction axes, and this method can mark the spatial information in the 8 directions with only 3 binary bits. The following formula can be used to calculate the node addressing encoding, wherep is the current number of layers and n is the number of layers to be segmented:(2)coding=xpypzp,xp+1yp+1zp+1,…,xp+nyp+nzp+n.The first bit of the three-bit binary code indicates the deviation degree from thex-axis, 0 indicates the subregion has no deviation in the x-axis direction, and 1 indicates the subregion has deviation in the x-axis direction. Similarly, the second bit and the third bit represent the deviation degree of the subregion in the y-axis and z-axis direction, respectively, which is exhibited in Figure 2.Figure 2
The octree nodes addressing encoding.The maximum number of layers for node segmentation is determined by the system word length.m is used to indicate the maximum number of layers that the current system can be divided into, and Bits represents the number of bits in the system word length:(3)m=bits3.A 64-bit system can be divided up into 21 layers. Assuming that the required minimum partition area is 1 m2, the maximum coverage area is 421 m2.According to the addressing encoding method, the storage structure of the octree can be encoded. In order to easily record, the code can be converted to decimal representation as shown in Figure3, which is a twice-segmented 3D scene. The specific steps of segmentation and encoding are as follows:(1)
The 3D map scene is represented in the form of cube approximately.(2)
By treating this cube as the root node of the tree, according to its deviation from the three axes, it is marked with three binary numbers, and then the binary numbers are converted into corresponding decimal numbers. The first segmentation and coding are completed.(3)
After the first segmentation, the regions numbered 0, 2, 3, 5, and 7 do not contain data, so they are white nodes and can be used as leaf nodes without further segmentation. The regions numbered 1 and 6 contain one data, respectively, so they are black nodes and can be regarded as leaf nodes without further segmentation. The region numbered 4 contains 4 data, so it is a gray node. It cannot be regarded as a leaf node, and the segmentation should continue; repeat step (2) to divide and encode.(4)
After the second segmentation, the region originally numbered 4 is divided into 8 subregions, among which the nodes numbered 40, 41, 42, 43, 44, and 47 do not contain data, so they are white. The nodes numbered 45 contain two data, and the node numbered 46 contains two data, so the two nodes are black. At this time, all nodes can be regarded as leaf nodes, so there is no need to segment, and the recursive operation of scene segmentation is finished.Figure 3
The decimal coded representation of the octree nodes.


#### 3.1.3. Data Expression

In three-dimensional indoor maps, most of the shapes of objects are very irregular, and the objects with cube shape occupy a much larger proportion than that with spherical shape. Therefore, after statistical analysis, Axially Aligned Bounding Box (AABB) method was considered to be more appropriate. The enclosing shape is a cuboid, and each side of the cuboid needs to be consistent with the corresponding coordinate axis direction. The benefit of normalizing the cube is that the AABB can be easily calculated based on the maximum and minimum coordinates of each vertex. The size and coordinates are as follows:(4)pos=x,y,zxmin≤x≤xmax,ymin≤y≤ymax,zmin≤z≤zmax.The minimum coordinate of point A in the lower-left corner and the maximum coordinate of point B in the upper-right corner can be selected and wrapped into a range. Two points A and B can be used to represent the bounding box as shown in Figure4.Figure 4
The sample of AABB object.By combining the above octree scene segmentation, node addressing encoding, and data approximate expression AABB, a storage model based on traditional octree can be formed. However, due to its approximate expression, some error rates still exist and are acceptable.


### 3.2. Design of Map Data Storage Method

In the process of saving the approximate representation data into the octree, few practical problems appeared such as map data conflict, partition line and object conflict, etc. Therefore, an improved octree structure with backtracking characteristics is proposed in this paper.


#### 3.2.1. Resolution to Map Data Conflict

In the three-dimensional indoor map scene, the distribution of objects is irregular. Many objects are too close to each other and even overlap. Therefore, when using bounding boxes to represent the objects approximately, the bounding boxes may intersect or overlap. As AABB is cube and cube box sides, respectively, on the axis, when a minimum coordinate and a maximum coordinate are used to represent the cube, we should check whether the coordinates of the two objects overlap or not. Suppose the coordinates of A arexAmin,yAmin,zAmin, xAmax,yAmax,zAmax, and the coordinates of B are xBmin,yBmin,zBmin, xBmax,yBmax,zBmax; then, the judgment conditions are as follows:(1)
IfxAmax<xBmin or xBmax<xAmin, the bounding box cubes of two objects do not conflict(2)
IfyAmax<yBminor yBmax<yAmin, the bounding box cubes of two objects do not conflict(3)
IfzAmax<zBminor zBmax<zAmin, the bounding box cubes of two objects do not conflictIf none of the above three conditions is satisfied, the AABB surrounded cubes of two objects are to be in conflict. In the three-dimensional map of indoor scenarios, due to the relatively small volume of a single object, for the conflicted data, we should use a bigger bounding box for approximate expression, that is, obtaining the maximum and minimum coordinates of the four coordinates used by two objects to represent the coordinates of the new bounding box. Because this kind of conflict is not a lot in the actual indoor environment and the new bounding box volume is not large, the cost is acceptable. Another advantage of taking the method is to help solve the difficulty caused by the unexpected situation of the dividing line at the intersection of two objects of the AABB bounding boxes.


#### 3.2.2. Resolution to Conflict between Dividing Line and Object

The linear way can replace the storage of pointers by addressing codes, which only need to record the addressing codes of leaf nodes, which can greatly reduce the storage pressure. In addition, the linear octree can be transformed into the corresponding linear list for representation. The elements in the linear list correspond to the nodes, which can increase the convenience of calculation.Linear mode is one of the most widely used storage methods. All data of this method are only stored in the leaf nodes, and the middle nodes do not store any data. However, in the three-dimensional indoor map scene, the location of indoor data is very close. It often exists in the situation that the dividing line is on the indoor object. If the object data is segmented at this time, it will terminate the object data and need to be reconstructed again. This is a complex process and requires a large amount of calculation. Therefore, this method is not applicable to the data storage of 3D indoor map.According to the characteristics of the close distribution of indoor map data, a new data storage model is proposed in this paper. It improves the linear octree and makes it to have backtracking ability. Originally, the map data is still stored at the leaf nodes, when the dividing line occurs in the object, the object data is not divided and instead it gets stored in the nearest parent node that can fully contain the object data. Since the object data storage has been completed at this time, the scene segmentation can be continued.


#### 3.2.3. Algorithm Implementation

(1) Definition of relevant data structure(I) Leaf Tree Node structureStruct LeafTreeNode{Coordinate [4]//Coordinates of the cubeNodeCoding//Location codeNodeDepth//The level of nodeObjectNum//The number of objects contained in nodesObjectID[objectNum]//Object code}(II) Non-Leaf Tree Node structureStruct Non-LeafTreeNode{Coordinate [4]//Coordinates of the cubeNodeCoding//Location codeNodeDepth//The level of nodeChildren [8]//the pointers point to the node’s childrenObjectNum//The number of objects contained in nodesObjectID[objectNum]//Object code}(III) Object structureStruct Object{ObjectID//Object codeObjectSize//Object size (AABB)RoomID//Room code that the object is in}(IV) Room structureStruct Room{ObjectID//Object codeObjectSize//Object size (AABB)RoomID//Room code the object in}The three structures defined above have different functions, but they are also related to each other. The algorithm of creating an octree is as follows Algorithm1.Algorithm 1: Octree Map Data Storage.
Input: TreeNode//Map scene is as root nodeOutput: TreeNode//The root node of the segmented data storage modelBegin:Fori = 0: MAX//Scene segmentationnewNodeDepth = nodeDepth + 1newNodeParents = nodenewNodeAABB = nodeAABB/8If nodeAABB.value > 2 and node.AABB > nodeMin thenIf Line on nodeAABB thenSearch for the smallest ancestorData is stored in the ancestor nodeDelete original dataEnd IfDivide nodeNode codingEnd IfEnd ForStore leaf node dataReturn TreeNodeEnd


### 3.3. Closed-Orientation 3D Indoor Map Data Retrieval Method

Based on the data storage model which is proposed in this paper, a data retrieval method with closed constraints was proposed according to the characteristics of more indoor partition to improve the efficiency of data retrieval.


#### 3.3.1. Analysis of Neighbor Retrieval Algorithm Based on the Octree

In octree structure, there are at most 26 neighbor nodes of a node. According to the type of critical location between the target node and neighbor node, three cases exist: surface-neighbor, edge-neighbor, and point-neighbor, as shown in Figure5. There are 6 surface-neighbors, 12 edge-neighbors, and 8 point-neighbors for one node.Figure 5
The neighbor nodes of a node. (a) The surface-neighbor. (b) The edge-neighbor. (c) The point-neighbor.
(a)(b)(c)In the octree, the calculation of neighbor nodes can be realized by finding the nearest common ancestor of target node and neighbor nodes. According to the direction and area information of the nodes, this method completes the calculation of address coding of neighbor nodes. This calculation is based on the modifying of the target node addressing code. The process is from the rightmost coding in turn to the left, updating the value of the target node at that position with the numerical results obtained by each bit of computation.In the octree environment, if we want to find the 26 direction’s information, we can only record the surface-neighbor data in orthogonal direction {D, U, R, L, B, F}. The 12 edge-neighbors and 8 point-neighbors’ data can achieve through orthogonal direction data twice or thrice operation. This can reduce the amount of data table.When the target node and the neighbor node in the given direction are brothers, the calculation method executes the “stop” command and directly modifies the rightmost digit value. Otherwise, the nearest common ancestor of the two nodes should be located, and then relevant calculation can be performed. When the layer of neighbor nodes is deeper than the target nodes, which is due to the neighbor node calculation method can only calculate the same size nodes with the target nodes, and the nodes calculated are not leaf nodes. That is, the nodes adjacent to the target nodes can also continue to refine. Although it is difficult to solve this problem, the research background of this paper is 3D indoor maps. Most of the map data volume is small, and therefore we can regard the calculated neighbor nodes as the target node’s neighbor nodes, and it does not need any further detailed analysis. The effects of these errors are negligible.


#### 3.3.2. Neighborhood Retrieval Optimization Algorithm in Indoor Map Scene

In the traditional octree neighbor node retrieval methods, the results of each retrieval are the target node’s 26 neighbor nodes in all directions. As we knew from the analysis mentioned earlier, there is no need of all 26 neighbor nodes in the 3D indoor scenarios. We can take the indoor room partition into consideration. The neighbor nodes in the same room with the target nodes are needed with the data. The optimization of the traditional octree neighbor retrieval method can realize the filtrating of neighbor nodes, reduce the number of neighbor nodes, reduce the workload for the later neighbor data analysis, thus reduce the cost of retrieval, and improve the stability of the algorithm.In the actual retrieval process of indoor map, according to the area where the target data is located, it can be divided into the following situations:(1)
The retrieval of data on the room ground: the retrieval in this environment can improve the efficiency by using the closure neighbor retrieval method.(2)
Corridor data retrieval: unlike the data on the room ground, the objects in corridor are limited, the environment is relatively open, and the enclosed space is few. Therefore, using neighbor search algorithm does not improve the efficiency, and it will lead to unnecessary retrieval costs. So, in this case, we can retrieve directly.(3)
The retrieval of data inside the room of nonground: the data in the area mainly refers to the space among walls and ceiling; it is similar to the data in the corridor. The purpose of retrieving it is not to move it, such as lamps on the ceiling. The purpose of retrieval is to repair, not to change the position. So even though it is closure, it does not meet the usage scenarios of closure neighbor search algorithm; this case also can retrieve directly.These three cases can contain most of the data, and direct retrieval is sufficient for extreme cases.Because different retrieval algorithms are used in different scenarios, the logical relationship of the object position parameters is as follows:x represents object data, Ax represents data on the floor of the room, Bx represents data on the corridor, and Cx represents data in the room that is not on the floor:(5)¬Ax⟶∃xBx∧Cx.N represents neighbor search:(6)¬∃xBx∧Cx∧Ax⟶N.Object data on the floor of the room requires neighbor retrieval.Nx,y is the data that x and y are neighbor. Rx,y is the data that x and y are in the same room:(7)∃yNx,y∧Rx,y∧¬∀yNx,y⟶Rx,y.Although there are cases in which neighbor data is in the same room, not all the neighbor nodes are in the same room.


#### 3.3.3. Algorithm Design

Considering the closure of data, the data retrieval method is the combination of the traditional octree neighbor nodes retrieval method and the closure of indoor rooms. The calculated neighbor data is filtered again by adding the constraint condition of room closure:(1)
Compare the ID of the target data with the node data to find the node where the target data is located and record the addressing code of the node, which is called the target node.(2)
According to the addressing code of the target node, retrieve the location of the target node in the octree and compare the data in the node with the target data ID to obtain the target data.(3)
If the target data do not conform to the application scope of neighbor retrieval, the retrieval shall be stopped; otherwise, the next step shall be carried out.(4)
Calculate the neighbor nodes of the target node and consider the room constraints, no more than 26. Parse the data in the qualified neighbor node. The two algorithms of octree retrieval and octree neighbor retrieval are shown in Algorithms2 and 3, respectively.Algorithm 2: Octree Map Target Data Retrieval.
Input: objectID, nodeCodingOutput: target dataBegin: target = rootWhile (objectID in CurNode and nodeCoding<>targetNode. nodeCoding) dotargetNode = CurNode.children[thei-th bit of the nodeCoding]While length of node objectNum > 0 do/∗ objectNum is array, does not reach the segmentation threshold ∗/collect objectData from targetNodeif collect objectData = targetObjectData thencall function OctreeMapNeighborDataRetrieval methodend whileEndAlgorithm 3: Octree Map Neighbor Data Retrieval.
Input: objectID, nodeCoding, objectPositionOutput: Neighbor dataBegin:If objectPosition ≠ roomNoGround and objectPosition ≠ corrido then/∗ Retrieval scenario judgment ∗/call NeighborRetrieval methodEnd IfEndFunction NeighborRetrievalFori = 1 : 26If targetObject.roomID = neighborObject.roomID then/∗ Room ID judgment ∗/Return TrueEnd IfEnd ForEnd


## 3.1. Map Scene Segmentation

The octree storage model usually consists of three parts: scene segmentation, node coding, and data representation. The basic principle to fulfill the function is using the octree to segment 3D scene regularly, using octree code to encode the route of each node [37]. The cube boxes are further used to express the objects approximately, and the codes are stored in the corresponding nodes according to the size and location of the boxes [38–40].


### 3.1.1. Octree Scene Segmentation Technology

The octree is a regular segmentation data structure. It approximately takes the overall scene of a three-dimensional indoor map as a cube and takes it as the root node of the tree. Moreover, it divides the scene into 8 or 0 pieces at a time during scene segmentation. Its schematic diagram is shown in Figure1, and its definition is as follows:(1)octree=vi=18vi−1,di=12di−1,hi=hi−1+1,n>2,end of separation,n≤2ordi=dmin,where vi,di,andhi are the volume, side length, and depth of the cube obtained by the ith division, respectively, n is the number of objects contained in the cube, and dmin is the minimum side length that the cube can be separated into.Figure 1
The octree scene segmentation schematic diagram.There are three types of nodes in an octree. In order to distinguish them, three colors are used in this paper. The white nodes indicate that no data has been stored, whereas gray nodes indicate that more than two objects’ data have been stored and black nodes indicate that one- or two-object data have been stored. White and black nodes can be regarded as leaf nodes, and gray nodes need to be further segmented. This segmentation is a recursive process, whose termination condition is that all nodes are leaf nodes or segmentation reaches the specified minimum segmentation area. Figure1 shows a twice-segmented tree structure, in which (a) is a schematic diagram of three-dimensional cube, whereas white circles represent the objects, and (b) is a schematic diagram of two-dimensional tree structure.After a three-dimensional map is recursively segmented by octree algorithm, many subregions will be formed, which are distributed in all the corners of the three-dimensional space.


### 3.1.2. Octree Node Addressing Encoding

In order to make the data management organized in the octree data storage models, it is necessary to make clear position of each data corresponding to the tree. In this paper, the position of each subregion is marked by encoding. The node addressing code uses digits to mark the 8 child-nodes which were extracted from each node, so that the 3D data can be represented by one-dimensional digits. Among which the number of encoded bits is the same as the number of layers, and each encodes unique marks of the node region while recording the path of this node to the root node. The method of “push back” is used in encoding. The first segmented code is taken as the first digit, and the result of each recursive segmenting is added to the last several digits in turn. The segmented 8 subregions can be distinguished by the deviation degree from the three direction axes, and this method can mark the spatial information in the 8 directions with only 3 binary bits. The following formula can be used to calculate the node addressing encoding, wherep is the current number of layers and n is the number of layers to be segmented:(2)coding=xpypzp,xp+1yp+1zp+1,…,xp+nyp+nzp+n.The first bit of the three-bit binary code indicates the deviation degree from thex-axis, 0 indicates the subregion has no deviation in the x-axis direction, and 1 indicates the subregion has deviation in the x-axis direction. Similarly, the second bit and the third bit represent the deviation degree of the subregion in the y-axis and z-axis direction, respectively, which is exhibited in Figure 2.Figure 2
The octree nodes addressing encoding.The maximum number of layers for node segmentation is determined by the system word length.m is used to indicate the maximum number of layers that the current system can be divided into, and Bits represents the number of bits in the system word length:(3)m=bits3.A 64-bit system can be divided up into 21 layers. Assuming that the required minimum partition area is 1 m2, the maximum coverage area is 421 m2.According to the addressing encoding method, the storage structure of the octree can be encoded. In order to easily record, the code can be converted to decimal representation as shown in Figure3, which is a twice-segmented 3D scene. The specific steps of segmentation and encoding are as follows:(1)
The 3D map scene is represented in the form of cube approximately.(2)
By treating this cube as the root node of the tree, according to its deviation from the three axes, it is marked with three binary numbers, and then the binary numbers are converted into corresponding decimal numbers. The first segmentation and coding are completed.(3)
After the first segmentation, the regions numbered 0, 2, 3, 5, and 7 do not contain data, so they are white nodes and can be used as leaf nodes without further segmentation. The regions numbered 1 and 6 contain one data, respectively, so they are black nodes and can be regarded as leaf nodes without further segmentation. The region numbered 4 contains 4 data, so it is a gray node. It cannot be regarded as a leaf node, and the segmentation should continue; repeat step (2) to divide and encode.(4)
After the second segmentation, the region originally numbered 4 is divided into 8 subregions, among which the nodes numbered 40, 41, 42, 43, 44, and 47 do not contain data, so they are white. The nodes numbered 45 contain two data, and the node numbered 46 contains two data, so the two nodes are black. At this time, all nodes can be regarded as leaf nodes, so there is no need to segment, and the recursive operation of scene segmentation is finished.Figure 3
The decimal coded representation of the octree nodes.


### 3.1.3. Data Expression

In three-dimensional indoor maps, most of the shapes of objects are very irregular, and the objects with cube shape occupy a much larger proportion than that with spherical shape. Therefore, after statistical analysis, Axially Aligned Bounding Box (AABB) method was considered to be more appropriate. The enclosing shape is a cuboid, and each side of the cuboid needs to be consistent with the corresponding coordinate axis direction. The benefit of normalizing the cube is that the AABB can be easily calculated based on the maximum and minimum coordinates of each vertex. The size and coordinates are as follows:(4)pos=x,y,zxmin≤x≤xmax,ymin≤y≤ymax,zmin≤z≤zmax.The minimum coordinate of point A in the lower-left corner and the maximum coordinate of point B in the upper-right corner can be selected and wrapped into a range. Two points A and B can be used to represent the bounding box as shown in Figure4.Figure 4
The sample of AABB object.By combining the above octree scene segmentation, node addressing encoding, and data approximate expression AABB, a storage model based on traditional octree can be formed. However, due to its approximate expression, some error rates still exist and are acceptable.


## 3.1.1. Octree Scene Segmentation Technology

The octree is a regular segmentation data structure. It approximately takes the overall scene of a three-dimensional indoor map as a cube and takes it as the root node of the tree. Moreover, it divides the scene into 8 or 0 pieces at a time during scene segmentation. Its schematic diagram is shown in Figure1, and its definition is as follows:(1)octree=vi=18vi−1,di=12di−1,hi=hi−1+1,n>2,end of separation,n≤2ordi=dmin,where vi,di,andhi are the volume, side length, and depth of the cube obtained by the ith division, respectively, n is the number of objects contained in the cube, and dmin is the minimum side length that the cube can be separated into.Figure 1
The octree scene segmentation schematic diagram.There are three types of nodes in an octree. In order to distinguish them, three colors are used in this paper. The white nodes indicate that no data has been stored, whereas gray nodes indicate that more than two objects’ data have been stored and black nodes indicate that one- or two-object data have been stored. White and black nodes can be regarded as leaf nodes, and gray nodes need to be further segmented. This segmentation is a recursive process, whose termination condition is that all nodes are leaf nodes or segmentation reaches the specified minimum segmentation area. Figure1 shows a twice-segmented tree structure, in which (a) is a schematic diagram of three-dimensional cube, whereas white circles represent the objects, and (b) is a schematic diagram of two-dimensional tree structure.After a three-dimensional map is recursively segmented by octree algorithm, many subregions will be formed, which are distributed in all the corners of the three-dimensional space.


## 3.1.2. Octree Node Addressing Encoding

In order to make the data management organized in the octree data storage models, it is necessary to make clear position of each data corresponding to the tree. In this paper, the position of each subregion is marked by encoding. The node addressing code uses digits to mark the 8 child-nodes which were extracted from each node, so that the 3D data can be represented by one-dimensional digits. Among which the number of encoded bits is the same as the number of layers, and each encodes unique marks of the node region while recording the path of this node to the root node. The method of “push back” is used in encoding. The first segmented code is taken as the first digit, and the result of each recursive segmenting is added to the last several digits in turn. The segmented 8 subregions can be distinguished by the deviation degree from the three direction axes, and this method can mark the spatial information in the 8 directions with only 3 binary bits. The following formula can be used to calculate the node addressing encoding, wherep is the current number of layers and n is the number of layers to be segmented:(2)coding=xpypzp,xp+1yp+1zp+1,…,xp+nyp+nzp+n.The first bit of the three-bit binary code indicates the deviation degree from thex-axis, 0 indicates the subregion has no deviation in the x-axis direction, and 1 indicates the subregion has deviation in the x-axis direction. Similarly, the second bit and the third bit represent the deviation degree of the subregion in the y-axis and z-axis direction, respectively, which is exhibited in Figure 2.Figure 2
The octree nodes addressing encoding.The maximum number of layers for node segmentation is determined by the system word length.m is used to indicate the maximum number of layers that the current system can be divided into, and Bits represents the number of bits in the system word length:(3)m=bits3.A 64-bit system can be divided up into 21 layers. Assuming that the required minimum partition area is 1 m2, the maximum coverage area is 421 m2.According to the addressing encoding method, the storage structure of the octree can be encoded. In order to easily record, the code can be converted to decimal representation as shown in Figure3, which is a twice-segmented 3D scene. The specific steps of segmentation and encoding are as follows:(1)
The 3D map scene is represented in the form of cube approximately.(2)
By treating this cube as the root node of the tree, according to its deviation from the three axes, it is marked with three binary numbers, and then the binary numbers are converted into corresponding decimal numbers. The first segmentation and coding are completed.(3)
After the first segmentation, the regions numbered 0, 2, 3, 5, and 7 do not contain data, so they are white nodes and can be used as leaf nodes without further segmentation. The regions numbered 1 and 6 contain one data, respectively, so they are black nodes and can be regarded as leaf nodes without further segmentation. The region numbered 4 contains 4 data, so it is a gray node. It cannot be regarded as a leaf node, and the segmentation should continue; repeat step (2) to divide and encode.(4)
After the second segmentation, the region originally numbered 4 is divided into 8 subregions, among which the nodes numbered 40, 41, 42, 43, 44, and 47 do not contain data, so they are white. The nodes numbered 45 contain two data, and the node numbered 46 contains two data, so the two nodes are black. At this time, all nodes can be regarded as leaf nodes, so there is no need to segment, and the recursive operation of scene segmentation is finished.Figure 3
The decimal coded representation of the octree nodes.


## 3.1.3. Data Expression

In three-dimensional indoor maps, most of the shapes of objects are very irregular, and the objects with cube shape occupy a much larger proportion than that with spherical shape. Therefore, after statistical analysis, Axially Aligned Bounding Box (AABB) method was considered to be more appropriate. The enclosing shape is a cuboid, and each side of the cuboid needs to be consistent with the corresponding coordinate axis direction. The benefit of normalizing the cube is that the AABB can be easily calculated based on the maximum and minimum coordinates of each vertex. The size and coordinates are as follows:(4)pos=x,y,zxmin≤x≤xmax,ymin≤y≤ymax,zmin≤z≤zmax.The minimum coordinate of point A in the lower-left corner and the maximum coordinate of point B in the upper-right corner can be selected and wrapped into a range. Two points A and B can be used to represent the bounding box as shown in Figure4.Figure 4
The sample of AABB object.By combining the above octree scene segmentation, node addressing encoding, and data approximate expression AABB, a storage model based on traditional octree can be formed. However, due to its approximate expression, some error rates still exist and are acceptable.


## 3.2. Design of Map Data Storage Method

In the process of saving the approximate representation data into the octree, few practical problems appeared such as map data conflict, partition line and object conflict, etc. Therefore, an improved octree structure with backtracking characteristics is proposed in this paper.


### 3.2.1. Resolution to Map Data Conflict

In the three-dimensional indoor map scene, the distribution of objects is irregular. Many objects are too close to each other and even overlap. Therefore, when using bounding boxes to represent the objects approximately, the bounding boxes may intersect or overlap. As AABB is cube and cube box sides, respectively, on the axis, when a minimum coordinate and a maximum coordinate are used to represent the cube, we should check whether the coordinates of the two objects overlap or not. Suppose the coordinates of A arexAmin,yAmin,zAmin, xAmax,yAmax,zAmax, and the coordinates of B are xBmin,yBmin,zBmin, xBmax,yBmax,zBmax; then, the judgment conditions are as follows:(1)
IfxAmax<xBmin or xBmax<xAmin, the bounding box cubes of two objects do not conflict(2)
IfyAmax<yBminor yBmax<yAmin, the bounding box cubes of two objects do not conflict(3)
IfzAmax<zBminor zBmax<zAmin, the bounding box cubes of two objects do not conflictIf none of the above three conditions is satisfied, the AABB surrounded cubes of two objects are to be in conflict. In the three-dimensional map of indoor scenarios, due to the relatively small volume of a single object, for the conflicted data, we should use a bigger bounding box for approximate expression, that is, obtaining the maximum and minimum coordinates of the four coordinates used by two objects to represent the coordinates of the new bounding box. Because this kind of conflict is not a lot in the actual indoor environment and the new bounding box volume is not large, the cost is acceptable. Another advantage of taking the method is to help solve the difficulty caused by the unexpected situation of the dividing line at the intersection of two objects of the AABB bounding boxes.


### 3.2.2. Resolution to Conflict between Dividing Line and Object

The linear way can replace the storage of pointers by addressing codes, which only need to record the addressing codes of leaf nodes, which can greatly reduce the storage pressure. In addition, the linear octree can be transformed into the corresponding linear list for representation. The elements in the linear list correspond to the nodes, which can increase the convenience of calculation.Linear mode is one of the most widely used storage methods. All data of this method are only stored in the leaf nodes, and the middle nodes do not store any data. However, in the three-dimensional indoor map scene, the location of indoor data is very close. It often exists in the situation that the dividing line is on the indoor object. If the object data is segmented at this time, it will terminate the object data and need to be reconstructed again. This is a complex process and requires a large amount of calculation. Therefore, this method is not applicable to the data storage of 3D indoor map.According to the characteristics of the close distribution of indoor map data, a new data storage model is proposed in this paper. It improves the linear octree and makes it to have backtracking ability. Originally, the map data is still stored at the leaf nodes, when the dividing line occurs in the object, the object data is not divided and instead it gets stored in the nearest parent node that can fully contain the object data. Since the object data storage has been completed at this time, the scene segmentation can be continued.


### 3.2.3. Algorithm Implementation

(1) Definition of relevant data structure(I) Leaf Tree Node structureStruct LeafTreeNode{Coordinate [4]//Coordinates of the cubeNodeCoding//Location codeNodeDepth//The level of nodeObjectNum//The number of objects contained in nodesObjectID[objectNum]//Object code}(II) Non-Leaf Tree Node structureStruct Non-LeafTreeNode{Coordinate [4]//Coordinates of the cubeNodeCoding//Location codeNodeDepth//The level of nodeChildren [8]//the pointers point to the node’s childrenObjectNum//The number of objects contained in nodesObjectID[objectNum]//Object code}(III) Object structureStruct Object{ObjectID//Object codeObjectSize//Object size (AABB)RoomID//Room code that the object is in}(IV) Room structureStruct Room{ObjectID//Object codeObjectSize//Object size (AABB)RoomID//Room code the object in}The three structures defined above have different functions, but they are also related to each other. The algorithm of creating an octree is as follows Algorithm1.Algorithm 1: Octree Map Data Storage.
Input: TreeNode//Map scene is as root nodeOutput: TreeNode//The root node of the segmented data storage modelBegin:Fori = 0: MAX//Scene segmentationnewNodeDepth = nodeDepth + 1newNodeParents = nodenewNodeAABB = nodeAABB/8If nodeAABB.value > 2 and node.AABB > nodeMin thenIf Line on nodeAABB thenSearch for the smallest ancestorData is stored in the ancestor nodeDelete original dataEnd IfDivide nodeNode codingEnd IfEnd ForStore leaf node dataReturn TreeNodeEnd


## 3.2.1. Resolution to Map Data Conflict

In the three-dimensional indoor map scene, the distribution of objects is irregular. Many objects are too close to each other and even overlap. Therefore, when using bounding boxes to represent the objects approximately, the bounding boxes may intersect or overlap. As AABB is cube and cube box sides, respectively, on the axis, when a minimum coordinate and a maximum coordinate are used to represent the cube, we should check whether the coordinates of the two objects overlap or not. Suppose the coordinates of A arexAmin,yAmin,zAmin, xAmax,yAmax,zAmax, and the coordinates of B are xBmin,yBmin,zBmin, xBmax,yBmax,zBmax; then, the judgment conditions are as follows:(1)
IfxAmax<xBmin or xBmax<xAmin, the bounding box cubes of two objects do not conflict(2)
IfyAmax<yBminor yBmax<yAmin, the bounding box cubes of two objects do not conflict(3)
IfzAmax<zBminor zBmax<zAmin, the bounding box cubes of two objects do not conflictIf none of the above three conditions is satisfied, the AABB surrounded cubes of two objects are to be in conflict. In the three-dimensional map of indoor scenarios, due to the relatively small volume of a single object, for the conflicted data, we should use a bigger bounding box for approximate expression, that is, obtaining the maximum and minimum coordinates of the four coordinates used by two objects to represent the coordinates of the new bounding box. Because this kind of conflict is not a lot in the actual indoor environment and the new bounding box volume is not large, the cost is acceptable. Another advantage of taking the method is to help solve the difficulty caused by the unexpected situation of the dividing line at the intersection of two objects of the AABB bounding boxes.


## 3.2.2. Resolution to Conflict between Dividing Line and Object

The linear way can replace the storage of pointers by addressing codes, which only need to record the addressing codes of leaf nodes, which can greatly reduce the storage pressure. In addition, the linear octree can be transformed into the corresponding linear list for representation. The elements in the linear list correspond to the nodes, which can increase the convenience of calculation.Linear mode is one of the most widely used storage methods. All data of this method are only stored in the leaf nodes, and the middle nodes do not store any data. However, in the three-dimensional indoor map scene, the location of indoor data is very close. It often exists in the situation that the dividing line is on the indoor object. If the object data is segmented at this time, it will terminate the object data and need to be reconstructed again. This is a complex process and requires a large amount of calculation. Therefore, this method is not applicable to the data storage of 3D indoor map.According to the characteristics of the close distribution of indoor map data, a new data storage model is proposed in this paper. It improves the linear octree and makes it to have backtracking ability. Originally, the map data is still stored at the leaf nodes, when the dividing line occurs in the object, the object data is not divided and instead it gets stored in the nearest parent node that can fully contain the object data. Since the object data storage has been completed at this time, the scene segmentation can be continued.


## 3.2.3. Algorithm Implementation

(1) Definition of relevant data structure(I) Leaf Tree Node structureStruct LeafTreeNode{Coordinate [4]//Coordinates of the cubeNodeCoding//Location codeNodeDepth//The level of nodeObjectNum//The number of objects contained in nodesObjectID[objectNum]//Object code}(II) Non-Leaf Tree Node structureStruct Non-LeafTreeNode{Coordinate [4]//Coordinates of the cubeNodeCoding//Location codeNodeDepth//The level of nodeChildren [8]//the pointers point to the node’s childrenObjectNum//The number of objects contained in nodesObjectID[objectNum]//Object code}(III) Object structureStruct Object{ObjectID//Object codeObjectSize//Object size (AABB)RoomID//Room code that the object is in}(IV) Room structureStruct Room{ObjectID//Object codeObjectSize//Object size (AABB)RoomID//Room code the object in}The three structures defined above have different functions, but they are also related to each other. The algorithm of creating an octree is as follows Algorithm1.Algorithm 1: Octree Map Data Storage.
Input: TreeNode//Map scene is as root nodeOutput: TreeNode//The root node of the segmented data storage modelBegin:Fori = 0: MAX//Scene segmentationnewNodeDepth = nodeDepth + 1newNodeParents = nodenewNodeAABB = nodeAABB/8If nodeAABB.value > 2 and node.AABB > nodeMin thenIf Line on nodeAABB thenSearch for the smallest ancestorData is stored in the ancestor nodeDelete original dataEnd IfDivide nodeNode codingEnd IfEnd ForStore leaf node dataReturn TreeNodeEnd


## 3.3. Closed-Orientation 3D Indoor Map Data Retrieval Method

Based on the data storage model which is proposed in this paper, a data retrieval method with closed constraints was proposed according to the characteristics of more indoor partition to improve the efficiency of data retrieval.


### 3.3.1. Analysis of Neighbor Retrieval Algorithm Based on the Octree

In octree structure, there are at most 26 neighbor nodes of a node. According to the type of critical location between the target node and neighbor node, three cases exist: surface-neighbor, edge-neighbor, and point-neighbor, as shown in Figure5. There are 6 surface-neighbors, 12 edge-neighbors, and 8 point-neighbors for one node.Figure 5
The neighbor nodes of a node. (a) The surface-neighbor. (b) The edge-neighbor. (c) The point-neighbor.
(a)(b)(c)In the octree, the calculation of neighbor nodes can be realized by finding the nearest common ancestor of target node and neighbor nodes. According to the direction and area information of the nodes, this method completes the calculation of address coding of neighbor nodes. This calculation is based on the modifying of the target node addressing code. The process is from the rightmost coding in turn to the left, updating the value of the target node at that position with the numerical results obtained by each bit of computation.In the octree environment, if we want to find the 26 direction’s information, we can only record the surface-neighbor data in orthogonal direction {D, U, R, L, B, F}. The 12 edge-neighbors and 8 point-neighbors’ data can achieve through orthogonal direction data twice or thrice operation. This can reduce the amount of data table.When the target node and the neighbor node in the given direction are brothers, the calculation method executes the “stop” command and directly modifies the rightmost digit value. Otherwise, the nearest common ancestor of the two nodes should be located, and then relevant calculation can be performed. When the layer of neighbor nodes is deeper than the target nodes, which is due to the neighbor node calculation method can only calculate the same size nodes with the target nodes, and the nodes calculated are not leaf nodes. That is, the nodes adjacent to the target nodes can also continue to refine. Although it is difficult to solve this problem, the research background of this paper is 3D indoor maps. Most of the map data volume is small, and therefore we can regard the calculated neighbor nodes as the target node’s neighbor nodes, and it does not need any further detailed analysis. The effects of these errors are negligible.


### 3.3.2. Neighborhood Retrieval Optimization Algorithm in Indoor Map Scene

In the traditional octree neighbor node retrieval methods, the results of each retrieval are the target node’s 26 neighbor nodes in all directions. As we knew from the analysis mentioned earlier, there is no need of all 26 neighbor nodes in the 3D indoor scenarios. We can take the indoor room partition into consideration. The neighbor nodes in the same room with the target nodes are needed with the data. The optimization of the traditional octree neighbor retrieval method can realize the filtrating of neighbor nodes, reduce the number of neighbor nodes, reduce the workload for the later neighbor data analysis, thus reduce the cost of retrieval, and improve the stability of the algorithm.In the actual retrieval process of indoor map, according to the area where the target data is located, it can be divided into the following situations:(1)
The retrieval of data on the room ground: the retrieval in this environment can improve the efficiency by using the closure neighbor retrieval method.(2)
Corridor data retrieval: unlike the data on the room ground, the objects in corridor are limited, the environment is relatively open, and the enclosed space is few. Therefore, using neighbor search algorithm does not improve the efficiency, and it will lead to unnecessary retrieval costs. So, in this case, we can retrieve directly.(3)
The retrieval of data inside the room of nonground: the data in the area mainly refers to the space among walls and ceiling; it is similar to the data in the corridor. The purpose of retrieving it is not to move it, such as lamps on the ceiling. The purpose of retrieval is to repair, not to change the position. So even though it is closure, it does not meet the usage scenarios of closure neighbor search algorithm; this case also can retrieve directly.These three cases can contain most of the data, and direct retrieval is sufficient for extreme cases.Because different retrieval algorithms are used in different scenarios, the logical relationship of the object position parameters is as follows:x represents object data, Ax represents data on the floor of the room, Bx represents data on the corridor, and Cx represents data in the room that is not on the floor:(5)¬Ax⟶∃xBx∧Cx.N represents neighbor search:(6)¬∃xBx∧Cx∧Ax⟶N.Object data on the floor of the room requires neighbor retrieval.Nx,y is the data that x and y are neighbor. Rx,y is the data that x and y are in the same room:(7)∃yNx,y∧Rx,y∧¬∀yNx,y⟶Rx,y.Although there are cases in which neighbor data is in the same room, not all the neighbor nodes are in the same room.


### 3.3.3. Algorithm Design

Considering the closure of data, the data retrieval method is the combination of the traditional octree neighbor nodes retrieval method and the closure of indoor rooms. The calculated neighbor data is filtered again by adding the constraint condition of room closure:(1)
Compare the ID of the target data with the node data to find the node where the target data is located and record the addressing code of the node, which is called the target node.(2)
According to the addressing code of the target node, retrieve the location of the target node in the octree and compare the data in the node with the target data ID to obtain the target data.(3)
If the target data do not conform to the application scope of neighbor retrieval, the retrieval shall be stopped; otherwise, the next step shall be carried out.(4)
Calculate the neighbor nodes of the target node and consider the room constraints, no more than 26. Parse the data in the qualified neighbor node. The two algorithms of octree retrieval and octree neighbor retrieval are shown in Algorithms2 and 3, respectively.Algorithm 2: Octree Map Target Data Retrieval.
Input: objectID, nodeCodingOutput: target dataBegin: target = rootWhile (objectID in CurNode and nodeCoding<>targetNode. nodeCoding) dotargetNode = CurNode.children[thei-th bit of the nodeCoding]While length of node objectNum > 0 do/∗ objectNum is array, does not reach the segmentation threshold ∗/collect objectData from targetNodeif collect objectData = targetObjectData thencall function OctreeMapNeighborDataRetrieval methodend whileEndAlgorithm 3: Octree Map Neighbor Data Retrieval.
Input: objectID, nodeCoding, objectPositionOutput: Neighbor dataBegin:If objectPosition ≠ roomNoGround and objectPosition ≠ corrido then/∗ Retrieval scenario judgment ∗/call NeighborRetrieval methodEnd IfEndFunction NeighborRetrievalFori = 1 : 26If targetObject.roomID = neighborObject.roomID then/∗ Room ID judgment ∗/Return TrueEnd IfEnd ForEnd


## 3.3.1. Analysis of Neighbor Retrieval Algorithm Based on the Octree

In octree structure, there are at most 26 neighbor nodes of a node. According to the type of critical location between the target node and neighbor node, three cases exist: surface-neighbor, edge-neighbor, and point-neighbor, as shown in Figure5. There are 6 surface-neighbors, 12 edge-neighbors, and 8 point-neighbors for one node.Figure 5
The neighbor nodes of a node. (a) The surface-neighbor. (b) The edge-neighbor. (c) The point-neighbor.
(a)(b)(c)In the octree, the calculation of neighbor nodes can be realized by finding the nearest common ancestor of target node and neighbor nodes. According to the direction and area information of the nodes, this method completes the calculation of address coding of neighbor nodes. This calculation is based on the modifying of the target node addressing code. The process is from the rightmost coding in turn to the left, updating the value of the target node at that position with the numerical results obtained by each bit of computation.In the octree environment, if we want to find the 26 direction’s information, we can only record the surface-neighbor data in orthogonal direction {D, U, R, L, B, F}. The 12 edge-neighbors and 8 point-neighbors’ data can achieve through orthogonal direction data twice or thrice operation. This can reduce the amount of data table.When the target node and the neighbor node in the given direction are brothers, the calculation method executes the “stop” command and directly modifies the rightmost digit value. Otherwise, the nearest common ancestor of the two nodes should be located, and then relevant calculation can be performed. When the layer of neighbor nodes is deeper than the target nodes, which is due to the neighbor node calculation method can only calculate the same size nodes with the target nodes, and the nodes calculated are not leaf nodes. That is, the nodes adjacent to the target nodes can also continue to refine. Although it is difficult to solve this problem, the research background of this paper is 3D indoor maps. Most of the map data volume is small, and therefore we can regard the calculated neighbor nodes as the target node’s neighbor nodes, and it does not need any further detailed analysis. The effects of these errors are negligible.


## 3.3.2. Neighborhood Retrieval Optimization Algorithm in Indoor Map Scene

In the traditional octree neighbor node retrieval methods, the results of each retrieval are the target node’s 26 neighbor nodes in all directions. As we knew from the analysis mentioned earlier, there is no need of all 26 neighbor nodes in the 3D indoor scenarios. We can take the indoor room partition into consideration. The neighbor nodes in the same room with the target nodes are needed with the data. The optimization of the traditional octree neighbor retrieval method can realize the filtrating of neighbor nodes, reduce the number of neighbor nodes, reduce the workload for the later neighbor data analysis, thus reduce the cost of retrieval, and improve the stability of the algorithm.In the actual retrieval process of indoor map, according to the area where the target data is located, it can be divided into the following situations:(1)
The retrieval of data on the room ground: the retrieval in this environment can improve the efficiency by using the closure neighbor retrieval method.(2)
Corridor data retrieval: unlike the data on the room ground, the objects in corridor are limited, the environment is relatively open, and the enclosed space is few. Therefore, using neighbor search algorithm does not improve the efficiency, and it will lead to unnecessary retrieval costs. So, in this case, we can retrieve directly.(3)
The retrieval of data inside the room of nonground: the data in the area mainly refers to the space among walls and ceiling; it is similar to the data in the corridor. The purpose of retrieving it is not to move it, such as lamps on the ceiling. The purpose of retrieval is to repair, not to change the position. So even though it is closure, it does not meet the usage scenarios of closure neighbor search algorithm; this case also can retrieve directly.These three cases can contain most of the data, and direct retrieval is sufficient for extreme cases.Because different retrieval algorithms are used in different scenarios, the logical relationship of the object position parameters is as follows:x represents object data, Ax represents data on the floor of the room, Bx represents data on the corridor, and Cx represents data in the room that is not on the floor:(5)¬Ax⟶∃xBx∧Cx.N represents neighbor search:(6)¬∃xBx∧Cx∧Ax⟶N.Object data on the floor of the room requires neighbor retrieval.Nx,y is the data that x and y are neighbor. Rx,y is the data that x and y are in the same room:(7)∃yNx,y∧Rx,y∧¬∀yNx,y⟶Rx,y.Although there are cases in which neighbor data is in the same room, not all the neighbor nodes are in the same room.


## 3.3.3. Algorithm Design

Considering the closure of data, the data retrieval method is the combination of the traditional octree neighbor nodes retrieval method and the closure of indoor rooms. The calculated neighbor data is filtered again by adding the constraint condition of room closure:(1)
Compare the ID of the target data with the node data to find the node where the target data is located and record the addressing code of the node, which is called the target node.(2)
According to the addressing code of the target node, retrieve the location of the target node in the octree and compare the data in the node with the target data ID to obtain the target data.(3)
If the target data do not conform to the application scope of neighbor retrieval, the retrieval shall be stopped; otherwise, the next step shall be carried out.(4)
Calculate the neighbor nodes of the target node and consider the room constraints, no more than 26. Parse the data in the qualified neighbor node. The two algorithms of octree retrieval and octree neighbor retrieval are shown in Algorithms2 and 3, respectively.Algorithm 2: Octree Map Target Data Retrieval.
Input: objectID, nodeCodingOutput: target dataBegin: target = rootWhile (objectID in CurNode and nodeCoding<>targetNode. nodeCoding) dotargetNode = CurNode.children[thei-th bit of the nodeCoding]While length of node objectNum > 0 do/∗ objectNum is array, does not reach the segmentation threshold ∗/collect objectData from targetNodeif collect objectData = targetObjectData thencall function OctreeMapNeighborDataRetrieval methodend whileEndAlgorithm 3: Octree Map Neighbor Data Retrieval.
Input: objectID, nodeCoding, objectPositionOutput: Neighbor dataBegin:If objectPosition ≠ roomNoGround and objectPosition ≠ corrido then/∗ Retrieval scenario judgment ∗/call NeighborRetrieval methodEnd IfEndFunction NeighborRetrievalFori = 1 : 26If targetObject.roomID = neighborObject.roomID then/∗ Room ID judgment ∗/Return TrueEnd IfEnd ForEnd


## 4. Results and Discussion

### 4.1. Creation of Experimental Scenarios

In order to ensure the standardization and convenience of 3D indoor map scene creation, SketchUp and ArcGIS were used to create the map scene. ArcMap was used to create the two-dimensional scene base map, in which the surface data structure was used as the wall, and the point data structure was used as the marker point of each specific object in the scene. Finally, in the ArcScene platform, we added a height value for each surface type data structure and made it with a 3D data including height value. We changed the symbol expression mode of each point data to the specific object form which it represented, such as computer table, sofa, cabinet, etc. These specific objects needed to be done by SketchUp specific components. For the purpose of beauty, wall, ground, windows, and doors can be decorated with concrete material. The final scene is shown in Figure6.Figure 6
The experimental scenario A.Map scenario consists of two floors; there is a corridor in the middle section of each floor. On both sides, there are some rooms of different sizes. The basic object types include computer chair, table, and bookcase inside the room, a total of 87 indoor objects, and the specific parameters of floor 1 and floor 2 as shown in Tables1 and 2, not considering the dining regions and stairwells.Table 1
Floor 1 parameters.
Room ID134132131122123124Object number58613415Object type115112Room length (m)23302831455Table 2
Floor 2 parameters.
Room ID237235225226227228Object number2863106Object type211112Room length (m)31333052926


### 4.2. Experiments and Analysis of Neighbor Retrieval Algorithm

For the map data retrieval, the time required is an important index to evaluate the efficiency of a retrieval method. Therefore, in the experiment, based on the proposed storage model, the octree data retrieval method, R-tree data retrieval method, and octree neighbor data retrieval method are tested to analyze the time cost by these three methods in retrieving 3D indoor map data. In order to avoid the impact on the experimental results due to the lack of experimental data, the experiment is conducted under two simulation scenarios. The first experiment scene A is the map scene created in Section4.1, and the second experiment scene B is shown in Figure 7. The modeling method of this scenario is adopted in Section 4.1.Figure 7
The experimental scene B.Both experimental scene A and experimental scene B are three-dimensional indoor maps, and the details of them are shown in Table3. Now in the second experimental scenarios, three retrieval methods are completed. It is now the analysis of the time used complexity of data retrieval under different conditions.Table 3
Experimental scene parameters.
NameSize (kB)Data formatObject numberScene length (m)Scene ALab building16691sxd8790Scene BLibrary17347skp10360, 46, 90When 3D indoor map data is directly retrieved without any data structure and retrieval method, the time complexity of retrieval isnp, where n is the number of data and p is the number of data to be searched. When only using the proposed data storage model for the experimental data storage, without using any search method, as the octree, it cannot directly link to the other required node address based on a node address. Therefore, it needs to do tree traversal for each retrieval; time complexity of the search is O23L−1, where L is the depth of the tree. R-tree data retrieval method is like octree data retrieval method, but due to the overlapping area occurring in the R-tree, it takes extra time to detect if there is a collision of object data in the overlapping area. In an indoor environment, objects are packed more frequently, so retrieval takes more time. If the concept of “searching for a point, points around the searched point are within the searching range” is used at this time, the neighbor data information is retrieved by the traditional neighbor retrieval method of octree. Because of the regularity of the octree partitioning, it can calculate up to 26 neighbors map data around the target data through the formula. Therefore, the time complexity of neighbor retrieval method is O1.This experiment simulated five data retrievals and took scene A as an example for analysis. The data retrieved each time were distributed in multiple rooms. The specific retrieval parameters are shown in Table4.Table 4
Simulated retrieval operation parameters.
Times1st2nd3rd4th5thData number101581820Room 1 (ID, objects number)132, 4122, 8225, 3124, 10227, 5Room2131, 4225, 4228, 5123, 4124, 9Room3237, 2132, 3—227, 4228, 6Figures8 and 9 show the comparison of retrieval time among R-tree retrieval, the octree retrieval, and the octree neighbor retrieval under two scenarios, respectively. Figures 10 and 11 show the comparison of the octree retrieval and neighbor retrieval methods in terms of frequency times. From the experimental results, it can be concluded that the octree requires less time consumption in data retrieval operation than R-tree, and its stability is better. It indicates that the octree structure is not only better in construction time than R-tree structure, but also has advantages in data retrieval. For the octree structure, the use of neighbor retrieval method is better than not using it completely, which proves that the idea of “searching for a point, points around the searched point are within the searching range” is feasible. This suggests that neighbor nodes data of the target node is significantly useful. It is verified that the octree neighborhood retrieval can improve the overall efficiency without increasing the time efficiency of single retrieval.Figure 8
The simulated data retrieval in scenario A.Figure 9
The simulated data retrieval in scenario B.Figure 10
The number of data retrievals in scene A.Figure 11
The number of data retrievals in scene B.


### 4.3. Experiments and Analysis of Data Retrieval Methods Oriented to Closure Constraints

The experiments in this section will analyze from the aspect of retrieval cost, which refers to the number of neighbor nodes other than the target node each time the neighbor retrieval method is adopted. As the retrieved data needs to be parsed and represented each time, there will be more neighbors and the cost will be higher. The experiments still adopt the simulated retrieval data in the previous section to conduct in the experimental scene A and the experimental scene B.From Figures12 and 13, we can observe that the calculation method of neighbor nodes after adding the closure constraint condition has obviously reduced most cases in the number of neighbor nodes. Compared with the search method without constraint conditions, the search cost is reduced by 25 percent on average, which proves that the room closure condition can reduce the cost of data retrieval and then improve the efficiency of data retrieval on the premise of guaranteeing the efficiency of neighbor retrieval.Figure 12
The number of neighbors in scene A.Figure 13
The number of neighbors in scene B.


## 4.1. Creation of Experimental Scenarios

In order to ensure the standardization and convenience of 3D indoor map scene creation, SketchUp and ArcGIS were used to create the map scene. ArcMap was used to create the two-dimensional scene base map, in which the surface data structure was used as the wall, and the point data structure was used as the marker point of each specific object in the scene. Finally, in the ArcScene platform, we added a height value for each surface type data structure and made it with a 3D data including height value. We changed the symbol expression mode of each point data to the specific object form which it represented, such as computer table, sofa, cabinet, etc. These specific objects needed to be done by SketchUp specific components. For the purpose of beauty, wall, ground, windows, and doors can be decorated with concrete material. The final scene is shown in Figure6.Figure 6
The experimental scenario A.Map scenario consists of two floors; there is a corridor in the middle section of each floor. On both sides, there are some rooms of different sizes. The basic object types include computer chair, table, and bookcase inside the room, a total of 87 indoor objects, and the specific parameters of floor 1 and floor 2 as shown in Tables1 and 2, not considering the dining regions and stairwells.Table 1
Floor 1 parameters.
Room ID134132131122123124Object number58613415Object type115112Room length (m)23302831455Table 2
Floor 2 parameters.
Room ID237235225226227228Object number2863106Object type211112Room length (m)31333052926


## 4.2. Experiments and Analysis of Neighbor Retrieval Algorithm

For the map data retrieval, the time required is an important index to evaluate the efficiency of a retrieval method. Therefore, in the experiment, based on the proposed storage model, the octree data retrieval method, R-tree data retrieval method, and octree neighbor data retrieval method are tested to analyze the time cost by these three methods in retrieving 3D indoor map data. In order to avoid the impact on the experimental results due to the lack of experimental data, the experiment is conducted under two simulation scenarios. The first experiment scene A is the map scene created in Section4.1, and the second experiment scene B is shown in Figure 7. The modeling method of this scenario is adopted in Section 4.1.Figure 7
The experimental scene B.Both experimental scene A and experimental scene B are three-dimensional indoor maps, and the details of them are shown in Table3. Now in the second experimental scenarios, three retrieval methods are completed. It is now the analysis of the time used complexity of data retrieval under different conditions.Table 3
Experimental scene parameters.
NameSize (kB)Data formatObject numberScene length (m)Scene ALab building16691sxd8790Scene BLibrary17347skp10360, 46, 90When 3D indoor map data is directly retrieved without any data structure and retrieval method, the time complexity of retrieval isnp, where n is the number of data and p is the number of data to be searched. When only using the proposed data storage model for the experimental data storage, without using any search method, as the octree, it cannot directly link to the other required node address based on a node address. Therefore, it needs to do tree traversal for each retrieval; time complexity of the search is O23L−1, where L is the depth of the tree. R-tree data retrieval method is like octree data retrieval method, but due to the overlapping area occurring in the R-tree, it takes extra time to detect if there is a collision of object data in the overlapping area. In an indoor environment, objects are packed more frequently, so retrieval takes more time. If the concept of “searching for a point, points around the searched point are within the searching range” is used at this time, the neighbor data information is retrieved by the traditional neighbor retrieval method of octree. Because of the regularity of the octree partitioning, it can calculate up to 26 neighbors map data around the target data through the formula. Therefore, the time complexity of neighbor retrieval method is O1.This experiment simulated five data retrievals and took scene A as an example for analysis. The data retrieved each time were distributed in multiple rooms. The specific retrieval parameters are shown in Table4.Table 4
Simulated retrieval operation parameters.
Times1st2nd3rd4th5thData number101581820Room 1 (ID, objects number)132, 4122, 8225, 3124, 10227, 5Room2131, 4225, 4228, 5123, 4124, 9Room3237, 2132, 3—227, 4228, 6Figures8 and 9 show the comparison of retrieval time among R-tree retrieval, the octree retrieval, and the octree neighbor retrieval under two scenarios, respectively. Figures 10 and 11 show the comparison of the octree retrieval and neighbor retrieval methods in terms of frequency times. From the experimental results, it can be concluded that the octree requires less time consumption in data retrieval operation than R-tree, and its stability is better. It indicates that the octree structure is not only better in construction time than R-tree structure, but also has advantages in data retrieval. For the octree structure, the use of neighbor retrieval method is better than not using it completely, which proves that the idea of “searching for a point, points around the searched point are within the searching range” is feasible. This suggests that neighbor nodes data of the target node is significantly useful. It is verified that the octree neighborhood retrieval can improve the overall efficiency without increasing the time efficiency of single retrieval.Figure 8
The simulated data retrieval in scenario A.Figure 9
The simulated data retrieval in scenario B.Figure 10
The number of data retrievals in scene A.Figure 11
The number of data retrievals in scene B.


## 4.3. Experiments and Analysis of Data Retrieval Methods Oriented to Closure Constraints

The experiments in this section will analyze from the aspect of retrieval cost, which refers to the number of neighbor nodes other than the target node each time the neighbor retrieval method is adopted. As the retrieved data needs to be parsed and represented each time, there will be more neighbors and the cost will be higher. The experiments still adopt the simulated retrieval data in the previous section to conduct in the experimental scene A and the experimental scene B.From Figures12 and 13, we can observe that the calculation method of neighbor nodes after adding the closure constraint condition has obviously reduced most cases in the number of neighbor nodes. Compared with the search method without constraint conditions, the search cost is reduced by 25 percent on average, which proves that the room closure condition can reduce the cost of data retrieval and then improve the efficiency of data retrieval on the premise of guaranteeing the efficiency of neighbor retrieval.Figure 12
The number of neighbors in scene A.Figure 13
The number of neighbors in scene B.


## 5. Conclusions

In this study, we evaluated the problems related to the storage consumption of 3D indoor maps. In order to reduce storage consumption and improve storage efficiency, a 3D data storage model based on the octree structure was proposed. The octree structure is used to segment the indoor map data. The addressing code was used to uniquely mark the generated nodes without retaining the pointers to the parent and child nodes. Compared with pointer storage, this storage method saved 60% of storage space. Considering the complexity caused by irregular shape of indoor objects, AABB method was used to approximately express the object data in the map scene. The advantage of this storage model based on scene segmentation lied in the fact that it could reduce the amount of storage units and improve the storage efficiency. Moreover, the connection between each storage unit was convenient for future management and use. Then, according to the characteristics of close distribution of indoor map data, the situation of octree scene segmentation line within the object data range was analyzed. The linear octree was improved to have a backtracking ability. When the dividing line occurred in the object, the object data was not divided and instead it got stored in the nearest parent node that could fully contain the object data, not just in leaf nodes. Ultimately, it led to strengthening the stability of data storage and improving the efficiency of storage. After experimental verification, the data storage model of the octree map did not consume much time compared with the traditional octree, which is 1/8 of the time consumed by R-tree structure. Moreover, considering the problem of high cost and low efficiency of data retrieval, a data retrieval method based on the octree storage model was proposed in this paper. The method mainly analyzed from two aspects. Initially, according to the feature of “searching for a point, points around the searched point are within the searching range” of map data retrieval, an octree neighbor nodes retrieval method was proposed to reduce the number of retrieval operations. Then, by adding closure constraint conditions, the neighbor nodes retrieval method was improved to decrease the cost of data retrieval. Then, we could improve the efficiency of data retrieval. Experimental results showed that the cost of retrieval was reduced by about 25%.Due to the huge amount of indoor map data, the consumption of storage is crucial to the promotion and application of the system. The index linear storage based on octree can save a lot of storage space, reduce storage costs by 60%, and save system development costs. Meanwhile, the neighbor retrieval method proposed by adding closed constraints improved the retrieval efficiency by about 25%. The method of map data storage and retrieval proposed in this paper saved storage space and improved retrieval speed in practical applications. The indoor map was used in indoor localization to display the positioning results in indoor scenes, so that users would have a good positioning experience. With the advent of the 5G era, indoor localization has developed rapidly, and the search efficiency of indoor maps will be increasingly demanded. This research can achieve the purpose of real-time display of positioning results in map scene.There are many potential future directions existing for this type of work. First, in terms of map data expression, AABB packaging box approximate expression method was adopted in this paper, which can meet current needs. However, for objects with special shapes, some segmentation methods based on point-cloud data can be adopted to improve the accuracy of data expression. Second, there are vast amounts of data and many concurrent operations such as data retrieval in the indoor map. Therefore, cloud storage method and distributed system architecture can be combined to improve the robustness of data storage and retrieval, which could enhance the application experience of users.



---

*Source: 4315850-2020-07-10.xml*