Improving Room-Level Location for Indoor Trajectory Tracking with Low IPS Accuracy †

: With the development of indoor positioning methods, such as Wi-Fi positioning, geo-magnetic sensor positioning, Ultra-Wideband positioning, and pedestrian dead reckoning, the area of location-based services (LBS) is expanding from outdoor to indoor spaces. LBS refers to the geographic location information of moving objects to provide the desired services. Most Wi-Fi-based indoor positioning methods provide two-dimensional (2D) or three-dimensional (3D) coordinates in 1–5 m of accuracy on average approximately. However, many applications of indoor LBS are targeted to speciﬁc spaces such as rooms, corridors, stairs, etc. Thus, they require determining a service space from a coordinate in indoor spaces. In this paper, we propose a map matching method to assign an indoor position to a unit space a subdivision of an indoor space, called USMM ( Unit Space Map Matching ). Map matching is a commonly used localization improvement method that utilizes spatial constraints. We consider the topological information between unit spaces and moving objects’ probabilistic properties, compared to existing room-level mappings based on sensor signals, especially received signal strength-based ﬁngerprinting. The proposed method has the advantage of calculating the probability even if there is only one input trajectory. Last, we analyze the accuracy and performance of the proposed USMM methods by extensive experiments in real and synthetic environments. The experimental results show that our methods bring a signiﬁcant improvement when the accuracy level of indoor positioning is low. In experiments, the room-level location accuracy improves by almost 30% and 23% with real and synthetic data, respectively. We conclude that USMM methods are helpful to correct valid room-level locations from given positioning locations.


Introduction
The development of indoor position tracking technologies and wireless communication networks has accelerated location-based services (LBS) inside buildings or subways. The LBS applications provide services and information to mobile users by utilizing their geographic location over time, such as navigation, auto check-in, and security surveillance. Like the global positioning systems (GPS) in outdoor localization, there are several indoor positioning systems (IPS) that have been proposed, such as Wi-Fi, Ultra-Wideband (UWB), Bluetooth, Radio-Frequency Identification (RFID), and inertial sensors [1][2][3]. Each of these techniques has its advantages and limitations in terms of accuracy, coverage, computational complexity, cost of deployment, and applicability. For example, UWB-based localization [4,5] can achieve centimeter-level accuracy, but it requires specific expensive hardware; Wi-Fi-based localization [6] is relatively cheap because it can use existing infrastructure. Most of these methods are reported to provide approximately 1-5 m accuracy on average, although the accuracy of these methods is unstable and affected by environmental factors, such as humidity, temperature, and other electronic devices [7][8][9]. Some state-of-the-art Wi-Fi-based localization achieved centimeter-level accuracy, but it used additional data (such as image, video, etc.) or was tested on only prepared experiment environments (such as enough line-of-sight coverage and hardware infrastructure), not real sites [3,[10][11][12]. With the accuracy of IPS, the selection of an appropriate IPS corresponding to the application requirements influences the quality of services. For example, some LBS applications require centimeter-level accuracy. One example is autonomous industrial robots cooperating with each other in a manufacturing facility [13]. In such systems, robots should know each other's position as accurately as centimeter-level. Another example is real-time interactive IoT-based smart environments, such as remotely controlling objects in a home or office using a 3D interface [14]. It needs to be a very tight match between the actual objects and their digital representation. In contrast, many LBS applications can be serviced by room-level or region-level granularity of location even though IPS accuracy is low. For example, in scenarios security control with geofencing, which detects when an object or person enters or leaves a virtual zone, specified regions can directly represent controlled zones in contrast with coordinates of moving objects (i.e., pedestrian) [15,16]. The spatial query for indoor tracking data also used a region-level location for various analyses such as hot area detection, space planning, movement pattern discovery, and so on [17][18][19]. This means room-level or region-level granularity of location is sufficient for most indoor location-aware services, unlike those in the outdoor space [17,[20][21][22][23]]. To represent room-level (or region-level) location information, a symbolic space model that provides qualitative human-readable descriptions as symbolic codes about moving objects based on structural entities (such as rooms, elevators, staircases) and region (or point) of interest is used [24][25][26]. Although the symbolic code can be resolved by mapping the coordinate to the nearest meaningful space, this naive approach is unattractive due to insufficient accuracy. For example, if the positioning error exceeds certain meters, we cannot tell the correct room since it could be the room next door, as shown in Figure 1. We need a map matching method for symbolic code using the moving object's historical trajectory to get higher accuracy. According to these requirements, room-level localization has been studied. However, almost all room-level localization studies are based on sensor signals, especially Received Signal Strength (RSS)-based Wi-Fi fingerprinting [23]. Unfortunately, several IPS working on smartphones (e.g., IndoorAtlas [27], ArcGIS Indoors [28], AnyPlace [29], BuildNGO [30], and so on) provides coordinates of a pedestrian by Software Development Kit (SDK), not signal information. Therefore, we targeted developing a map matching method in the symbolic space model using coordinates information from IPS to improve room-level accuracy.

Sequence of IPS points
Actual traveled path However, assuming GPS data or the like, outdoor map matching techniques in Euclidean spaces or road networks are hard to apply directly to the symbolic space model, because the road network and the indoor topology graph have different characteristics, as shown in Figure 2. Indoor spaces feature distinct entities, such as rooms, walls, doors, and staircases, and form complex indoor topology that enables and constrains movements. Therefore, we must consider the particularities of indoor topology appropriately when map matching in indoor space. Another problem is that IPS offers lower sampling frequency and only report discrete indoor locations, unlike GPS that continuously report longitude and latitude. Therefore, there is considerable uncertainty in indoor positioning data to be used to compute indoor symbolic code. This issue becomes even more challenging to deal with in the context of complex indoor topology. Thus, we must handle indoor positioning data appropriately to find indoor symbolic code effectively and efficiently. We defined a method to find symbolic code from positioning coordinates reported by IPS is called USMM (Unit Space Map Matching). We present a USMM method by the hidden Markov model to overcome the limitations of naive USMM and consequently to improve accuracy. The hidden Markov model used in this paper is configured to reflect two factors; the error range of the indoor positioning method and the connectivity between indoor spaces. The novel contributions of our work are as follows: • We conduct an in-depth analysis of room-level localization to emphasize the importance of room-level (or region-level) map matching. • We formulate the unit space map matching (USMM) problem as the hidden Markov model that utilized indoor map, user trajectory, and IPS' characteristic information. • We design and implement several USMM methods based on the hidden Markov model. Additionally, we design and implement preprocess methods to improve its accuracy. • We evaluate USMM with a huge synthetic dataset and a real dataset collected by commercial IPS with Android-based smartphones in actual buildings to compare and analyze the proposed methods of accuracy and performance. The experiments show that the proposed methods show significant improvements in accuracy, mainly when indoor positioning accuracy is low.
The remainder of the paper is structured as follows. The related works on indoor positioning and indoor map matching are surveyed in Section 2. We define USMM and analyze the requirements of USMM in Section 3. In the next section, we introduce an intuitive USMM and discuss the limitations of this method. We proposed several methods for improving map matching accuracy by the hidden Markov model in Section 5. Sections 6 and 7 show the experiments' results to analyze our methods, and this paper concludes in Section 8.

Related Work
Location information is essential for a wide range of ubiquitous and applications for Location-Based Services (LBS). This is why the topic of determining the position of a device in indoor space has been the subject of many studies. Most of the work on indoor map matching (or indoor localization) methods has improved the accuracy of the positioning but not the symbolic map matching. This section gives an overview of some existing systems and implementations that use various IoT sensor signal values and technologies to improve positioning accuracy and achieve room-level localization. We also introduce the spatial model used in indoor localization to improve localization accuracy.

Symbolic Space Modeling
A system requires an appropriate data model representing the locations of objects situated within the environment to provide location-based services applied to indoor spaces. In this study, we used a symbolic spatial model with a place graph according to as following characteristics, strengths, and weaknesses: • First, symbolic information provides a qualitative, human-readable description of moving objects based on structural things or points of interest (e.g., room or floor identifiers). • Symbolic location models can reveal explicitly topological relationships between entities in the environment, such as containment, connectivity, closeness, and overlapping depending on their nature, in contrast to geometric information. • Last, symbolic representation enables spatial and semantic reasoning at an abstract level, supporting interactions between spatial objects within indoor spaces.
Symbolic approaches have frequently attempted to model indoor environments using topological structures [31,32] (and hierarchy structures [33,34]) of indoor space, graphs derived from the connectivity and reachability between spatial units [35,36]. If we have one of the structure information, other structure information can be derived from it. For instance, a hierarchical structure of the indoor space can be derived using the containment relationship. The accuracy of symbolic location depends on the Level of Details (LoD) of the indoor data model. For instance, grid models of indoor spaces into regular grid cells with the same shape and size can represent accurate locations if it has a small cell size (e.g., 10 cm to 1 m) [37]. On the other hand, graph models that use nodes and edges for representing indoor space, especially place topology-based models, can provide location information at the structural-entity level similar to the room level [38]. It has less location accuracy compared to grid models, but each node directly indicates a space with semantic information, such as rooms, corridors, and doors. Moreover, the edges represent topology relationships between nodes. Therefore, place topology-based models are more suitable to represent symbolic information. A particular graph model can represent accurate locations, such as a graph model for pedometers [39], but it is hard to represent room-level semantic information like grid models. Moreover, a symbolic model depends on the application domain; therefore, it needs to be created and managed accordingly. Thus, managing a massive number of location symbols requires a significant modeling effort. Symbolic models are generally less accurate compare to geometric models, but context-awareness is easier to achieve as symbolic models support human-recognizable descriptions. The major shortcoming of symbolic models is the lack of geometric details on entities and places represented in space. There are several hybrid indoor spatial models proposed to overcome this shortcoming. OGC IndoorGML [40] is one of the indoor spatial models with both geometry and topology information. Therefore, the symbolic spatial model used in this study referred to the conceptual model of IndoorGML.

Room-Level Indoor Localization
The research on improving positioning accuracy is classified into three approaches: using sensor signal values (and indoor layout information), additional context information, and additional multimedia information.

•
The first approach is mainly focused on filtering the sensor values. Various researches have been done so far in [41][42][43][44][45][46]. Most studies have improved positioning accuracy by filtering the values of access point (AP) signal or smartphone sensors (acceleration, gyroscope, etc.) used in the pedestrian dead reckoning (PDR) method. WILL [41] is a system that uses the PDR to determine the indoor location using APs with different Received Signal Strength (RSS) for each room. WILL considered the room's characteristics and the relationship between rooms, but eventually, it is aimed at the coordinate level, and the positioning accuracy is~80%. In [45], the authors proposed a Bluetooth Low Energy (BLE) beacon-based indoor navigation system for visual impairments person. The proposed system utilized the fuzzy logic framework for estimating the user's position. The authors analyzed the performance of various versions of the fingerprinting algorithm, including fuzzy logic type 1, fuzzy KNN, fuzzy logic type 2, and traditional methods such as proximity, trilateration, the centroid for indoor localization. The fuzzy logic type 2 method outperformed all other methods; the average localization error obtained in this approach is just 0.43 m. In [46], Son et al. proposed a magnetic vector calibration algorithm that can compensate for the change of the moving direction or the grip position of a user in the three-dimensional space. As the experiment evaluation, the proposed algorithm achieves higher positioning accuracy (average positioning error is 0.66 m) and faster initial positioning because the vector fingerprint is more identifiable compared to the magnitude fingerprint. • The second approach focuses on improving location accuracy using sensor information and map information as well as additional contextual information (landmarks, points of interest, human activity awareness, etc.). Several studies have been conducted in this regard [47,48]. APFiLoc [47] has conducted research to improve location accuracy by combining existing Wi-Fi-and PDR-based location systems with indoor landmark information (elevators, stairs, etc.). Positioning issues based on PDR with accumulated positioning errors are resolved through landmarks, and positioning accuracy is 80% when people hold their phones. • The final approach is to improve location accuracy, using additional multimedia information (images, video, etc.). Likewise, several studies have been carried out in connection with the works in [49][50][51]. Radaelli's research corrected the position measurement results in coordinate units, but it improved the accuracy at the room level [49]. It used a camera installed in the corridor and processed the image data to track moving objects and entrances. It corrected the location coordinates by combining the location information created using Wi-Fi wireless maps to track moving objects. However, the accuracy has not improved significantly.
In this way, previous studies are limited to indoor positioning accuracy. However, location room-level or region-level granularity is sufficient for most indoor location-aware services, unlike outdoor space. Therefore, there is currently a wealth of relevant literature [23,[52][53][54][55][56][57][58] on indoor localization at room-level. However, almost all current work is based on IoT sensor signal values. Furthermore, some works need extra sensor devices. This structure cannot be easily extended in existing systems for making room-level positioning.
• A large number of indoor positioning approaches use Wi-Fi technology to take advantage of the densely installed wireless Access Points (APs) in urban areas. Biehl et al. [55] presented the LoCo framework that can provide highly accurate roomlevel location using a supervised classification scheme to provide high accuracy indoor room classification based on the relative ordering of pairs of APs by RSSI. A modified AdaBoost [59] algorithm was used for room-level location estimation. They trained a classifier per room in the "one-versus-all" formulation and reported 94% accuracy. However, AdaBoost is a boosting technique that cannot be parallelized for training as well as predicting. The "one-versus-all" required computation for every room. It makes Loco's response time dependent on the building size and the number of rooms per building. Therefore, the response time of LoCo worsens directly in proportion to the number of rooms. • Bluetooth-based positioning is also a usual approach to room-level localization. Naya et al. [52] proposed a Bluetooth-based indoor proximity detection method for nursing context-awareness. It exploits proximity between Bluetooth devices attached to people and objects for estimating room-level proximity of people and objects. The introduction of Bluetooth Low Energy (BLE) provided even more opportunities for indoor localization. Kyritsis et al. [56] presented an easy to set up BLE-based system for room localization while keeping the cost as minimal as possible. This work used RSSI of the BLE beacon and the geometry of the rooms the beacons are placed. It shows an improvement in room estimation accuracy, especially in the boundary locations of the rooms. This work's major disadvantage is that it necessary extra devices such as BLE beacons only for positioning. • Another way of indoor localization is by using ultrasound signals. Inspired by bats that use those signals to navigate at night, several such systems have been developed. Jaen et al. [57] performed room-level indoor positioning using different acoustic impulse responses depending on each room's usage and structure. It can achieve very high accuracy, except for the living room. However, most of these studies require not only smartphones, but also individual devices or applications.
A large body of room-level indoor localization approaches uses RSS directly. However, almost all commercial IPS reports in the form of coordinates to a device that requests their location. Our research has focused on developing a room-level (or region-level) map matching method with the geometry of rooms, using only a sequence of coordinates of a user.

Map Matching in Indoor Space
Map matching denotes a procedure that assigns geographical objects to locations on a digital map [60]. The most typical geographical objects are point positions obtained from a positioning system. Map matching has been studied mainly for the outdoor environment, especially road network [61][62][63]. However, the road network and the indoor graph have different properties, as shown in Figure 2. In the case of the road network, map matching aims to place the GPS positions at their "right" locations on the road segment in the map. On the other hand, in the indoor space, the goal of map matching is to place the IPS positions at their "right" locations on the unit space in the map.
The unit space map matching follows a standard pattern: 1.
Extract the relevant information (e.g., latitude, longitude, speed, and heading) from the record received from the IPS.

2.
Select the candidate unit space from the digital indoor map. Usually, the unit spaces that are within a certain error distance of the IPS position are selected.

3.
Use algorithm-specific heuristics to determine the most suitable unit space among the candidate unit spaces. Common weighting criteria include weight for the proximity of unit space and weight for the topology of unit spaces.

Indoor Space Locations
Indoor space is a complex space in which various spaces are combined. Indoor space has a hierarchy in which a building consists of floors and floors consisting of a set of unit spaces. A user can define unit space with various methods, such as a gird space with a fixed resolution, a Voronoi diagram, and so on. Moreover, indoor space is naturally divided into unit space like rooms, corridors, staircases, or elevators by indoor features like walls and doors. Like an outdoor space, indoor space can be expressed as a graph, such as a unit space as a node and accessibility between spaces as an edge.

Definition 1. Indoor Space I
Indoor space I is defined as a directed graph <U,E> to represent an indoor accessibility graph. U = {u 1 , u 2 , ..., u n } is a set of nodes representing the unit spaces as below.

•
Each unit space u i ∈ U has a unique symbolic code, such as room number.

•
Each unit space u i ∈ U has a two-dimensional polygon g.
• For any pairs of units u i , u j ∈ U, u i .g can touches u j .g but cannot intersects.
E is a set of directed edges representing the connectivity between two unit spaces.
• A directed edge e i,j exists if two unit spaces (u i , u j ) are adjacent, connected, and no other space between u i and u j , where u i , u j ∈ U and i = j. Note that the adjacency between two unit spaces means u i .g touches u j .g. • e i,j has a weight tp(ortp u i ,u j ), which means a pass probability from unit space u i to u j . • e i,i always exist.
Note that "touch" and "intersect" are spatial relationship in the 9-intersects model [64].

Example 1.
Referring to the example in Figure 3b, a floor plan is divided into seven indoor unit spaces: U = {u 1 , ..., u 7 } corridor u 1 , rooms u 2 to u 6 , and staircase u 7 . According to the definition of E, a set of edge E is {e 1,1 , e 1,2 , e 1,3 , e 1,5 , e 1,6 , e 1,7 , e 2,1 , e 2,2 , e 3,1 , e 3,3 , e 3,4 , e 4,3 , e 4,4 , e 5,1 , e 5,5 , e 6,1 , e 6,6 , e 7,1 , e 7,7 }. Note that if a unit space is defined by room-level, accessibility is determined by the existence of a door between two unit spaces. When we carry out map matching for a moving object in indoor space, we have to consider not only its current position collected from IPS but also its past trajectory for a better understanding of its behavior.
An IPS sub-trajectory L s,e = (l s , ..., l e ) is a contiguous subset of a IPS trajectory L, where 1 ≤ s < e ≤ m.

Unit Space Map Matching as the Nearest One
A simple and direct approach for USMM, which we called NSMM (Nearest Space Map Matching), is to find the nearest unit space from point l collected from any indoor positioning method. As each unit space has closed geometry, as mentioned in the definition of indoor space, we can easily find the nearest space from point l. This approach depends on the accuracy of the IPS. If the indoor positioning gives low accuracy, the result of NSMM also becomes incorrect.
Note that Dist(l, u) is a shortest Euclidean distance between a point l.pos and a polygon u.g. If the point is included in the polygon, Dist(l, u) = 0.

Example 2.
Referring to the example in Figure 3a, a unit space u 1 is the result of NSMM as it contains point p(100, 30). Similarly, unit space u 3 is the result of NSMM as it is the nearest unit space from point p(150, 100).
On the other hand, in Figure 3b shows an IPS trajectory and its NSMM results is However, this path is incorrect in terms of the indoor accessibility graph I; u 2 → c 3 sequence is incorrect as there is no edge e 2,3 / ∈ E, described in Section 3.2.
When NSMM gives an incorrect estimation, we may correct it for better accuracy. However, there is no basis to choose one when there are several alternatives. A possible approach to resolve this problem is to select the case with a higher probability.

Definition 3. Vague location v
The IPS point l can convert to a set of vague locations V, which consists of a 3-tuple v = (u, ep, t) which represents a possibility ep that l is located in u ∈ U at a timestamp t. For an arbitrary object and an arbitrary reporting time, ∑ v∈V v.ep = 1 always holds for the corresponding set V. Example 3. Referring to the example in Figure 3b, there is an IPS trajectory L = (l 1 , l 2 , l 3 , l 4 , l 5 ), where an narrowed curve indicates a moving object's visiting sequence (same as timestamp t) and a radius of shade circle is error e. If we assume an area of shade circle is ep, according to Equation (2), a set of vague locations V for

Problem Formulation
Problem 1. Unit Space Map Matching f usmm Given an indoor space I =< U, E > and a previous IPS sub-trajectory L 1,t−1 = (l 1 , l 2 , .., l t−1 ) where t ≥ 2, and an IPS point l t , we consider possible paths Φ in the Cartesian product of all relevant vague location sets for trajectory L 1,t = (l 1 , .., we can calculate its probability as pr(φ k t ) as below.
pr(φ k The goal of our work is to discover proper estimation methods for the function f usmm (l t , I, φ t−1 ). Figure 4 shows an illustration of the USMM for the map matching problem illustrated in Figure 3b. Here, each vertical slice represents a point in time corresponding to an IPS point l t at timestamp t = 1, 2, 3, 4, 5. At t = 1, there is one unit space observed near l 1 as V 1 , shown as one blank dot in the first column. The blank dots are the NSMM results of each IPS point. There is a feasible moving path, from this one unit space to points on the two unit spaces near l 2 at t = 2 as V 2 . We can determine connectivity between unit spaces by edge weight tp u i ,u j . Therefore, there is no connection between u 2 at t = 2 and u 3 at t = 3, shown as a thick dot line. We can quickly filter those valid candidates using the indoor accessibility graph I. As the result of the Cartesian product between V 1 and V 2 , we can get a set of possible path

Connectivity between unit spaces
Selected result by USMM

Requirements
When we develop USMM methods, there are several requirements to consider for online map matching as below.
Accuracy When calculating the map matching accuracy for the input trajectory, USMM aims at improving the accuracy much higher than the NSMM. Even if the accuracy of the indoor positioning method is not good, the USMM method should provide a stable and high accuracy.
Performance USMM should be executed within a sampling interval of IPS in mobile devices to support real-time indoor location-based services. In most cases, the sampling interval is 1 second by default.
Data Size As USMM runs on mobile devices such as smartphones, the size of prepared data needed by USMM should be small enough to suitable for mobile devices.
These aspects served as the starting points of developing proper USMM methods in our work. In the following subsection, we discuss the basic ideas about how to realize these aspects.

Hidden Markov Model-Based Unit Space Map Matching
Map matching using HMM has been studied mainly for outdoor environments, especially road networks [61][62][63]. However, the road network and the indoor graph have different properties, as shown in Figure 2. In the road network, the goal of map matching is to match each positioning point with the proper road segment. In the previous studies, they defined the states of the HMM as individual road segments. On the other hand, HMM is usually used for map matching with fingerprinting maps of IoT sensors such as Wi-Fi in the indoor space [65][66][67]. In [66], HMM is used for position estimation based on the fusion of RSSI and movement vector observations. The goal of unit space map matching (USMM) is to match each positioning point with the proper space. There are two reasons that we apply an HMM (hidden Markov model) for USMM: First, the HMM provides a probabilistic approach. Second, the processing cost of HMM is relatively low, which is suitable for the real-time requirement of USMM, as mentioned in Section 3.6. We discuss how to apply the HMM for USMM in this section.

Hidden Markov Model for USMM
The HMM is a statistical Markov model where the system is assumed to be a Markov process with unobserved hidden states [68][69][70]. Five elements model the HMM, as follows: • the number of (hidden) states in the model N, The state transition probability distribution A: The state transition probability distribution A = {a i,j } from u i to u j is defined as below.
where q t−1 and q t are the state at timestamp t − 1 and t, respectively. And the state transition probabilities a i,j have the properties as below.
These probabilities are directly affected by the topographical connectivity between two unit spaces u i and u j . Therefore, we can define a i,j as a weight of edge e i,j in I.
The observation symbol probability distribution B: The observation symbol probability distribution (also called emission probabilities) B = {b i,j } is a probability when a given observation symbol o j can be observed in a hidden state u i . It is defined as below.
Moreover, b i,j have the properties, same as a i,j as below.
b i,j ≥ 0 and b i,j has the same meaning with ep(l t |u j ), which a likelihood that l t located on unit space u j at timestamp t, even if l t .pos is included in u i . We can calculate ep(l t |u j ) under the assumptions as below.
• An uncertainty region for an IPS point l t can be represented by an indoor positioning method error e and a point position l t .pos. • For a given l k , we denote a geometry of uncertainty region where l k can be located is UR(l k ). • An emission probability ep(l t |u j ) can be calculated by the ratio of overlapping area between a geometry of the uncertainty region UR(l t ) and a geometry of the unit space u j .g.
From the requirements described in Section 3.6, we have to consider the previous IPS trajectory L 1,t−1 , not only the current IPS point l t . We resolve it simply by grouping IPS trajectory L 1,t by unit spaces in which l i is included, then union all geometry of uncertainty region in the same group, use it as the uncertainty region of each unit space. We denote UR t is a union of each uncertainty region of L for l t .
Finally, we can define ep(l t |u j ) as below.
Note that, Area(g) is an area of a polygon g. ep(l t |u j ) is also the same as a vague location v = (u j , ep(l t |u j ), t) ∈ f v (L 1,t , I).
The initial state distribution π: In the case of map matching, the initial state distribution gives the probability of the moving object's first (at timestamp t = 1) unit space over all the spaces at the beginning of the movement.
This is semantically the same as the emission probability at timestamp 1. Assuming no measurements have been taken, we start at the first IPS point and have Example 5. Referring to the example in Figure 5, the number of hidden state N and observation symbols M is seven because the indoor space consists of seven unit spaces U = u 1 , ..., u 7 . For l 1 , An initial state distribution is π 1 = 1.0 and the others = 0.0, because there is no other space is overlapped with the observation area (a shaded area centered at l 1 in Figure 5). Assuming t i,j has equal probability, according to a degree of node u i in the graph I, a state transition probability a i,j can be calculated by Equation (13), e.g., a 1,j = [ 1 7 , ..., 1 7 ], 1 ≤ j ≤ N. An emission probability b i,j can be calculated by Equation (11), a ratio between an area of UR t and u i .g, e.g., For making more feasible and reasonable USMM results, we evaluate the probabilities of the HSMM. There are three algorithms for solving three fundamental problems using an HMM: forward algorithm, Viterbi algorithm, and forward-backward algorithm. This paper uses the forward algorithm to real-time HSMM using an IPS trajectory L 1,t . However, as collected IPS points getting accumulated, an old previous trajectory becomes meaningless. For this reason, it is better to handle only a recent sub-trajectory. This paper proposes a method to determine an affect-high period of trajectory through a sliding window. For the convenience, we denote a sub-trajectory of IPS trajectory L = (l 1 , ..., l t ) covered by sliding window w as L t−w+1,t = (l t−w+1 , l t−w , ..., l t ). As the sliding window moves through, some elements of HSMM should be updated accordingly: • the initial state distribution π should be updated using the first element of L t−w+1,t and • the observation symbol probability distribution B should be updated according to Equation (11).
Example 6. Figure 6 shows an example of a sliding window. Given the size of the sliding window w = 3, we only consider three most recent positions for computing the B matrix, instead of the entire trajectory. For more detail, in Figure 6a shows the case where the sliding window L t−w+1,t contains l 2 , l 3 , l 4 at time t. Next, in Figure 6b, when we get the most recent position l 5 at time t + 1, W have replace l 2 to l 5 . At this time, π and B should be update for getting HSMM result about L t−w,t+1 . The real-time HSMM procedure is given as Algorithm 1. As the processing time is quite short, it can easily implement in mobile devices for real-time services. We will discuss it in the next section. L target ← L t−w+1,t , a sub-trajectory from L 1,t using w i is an index of unit space that l t .pos is included and j is an index of unit space v k .u 12: return φ t = f usmm (L target , I) using φ t−1 End

The Methods of Determining the A Matrix
The implementation of state transition probability distribution A is one of the fundamental requirements of the HSMM. With a proper definition of A, we can significantly improve the accuracy of HSMM. The first idea for the definition is based on the connectivity of the indoor accessibility graph I. Given the i-th node u i ∈ U of the I in the Definition 3.2, the probability at i,j is defined as follows: While the probability of unit space transition from u i to u j is considered as same as transition from u i to u i in Equation (13), it depends on the context of moving object normally. For example, when a moving object stays in a classroom for a while, the probability of staying in the unit space is greater than the probability of transition to another room. For this reason, we increase a i,i bigger than a i,j (i = j) of the state transition matrix when the moving object is staying in the same unit space for a while. On the contrary, we decrease a i,i when moving across different unit spaces. To reflect this property, we dynamically update the state transition matrix instead of the static transition matrix given in Equation (14) as follows: Note that σ means the probability to stay in the same unit space. The parameter σ (0 ≤ σ ≤ 1) is determined in a dynamic way. σ k indicates σ at k-th position of a moving object collected by indoor positioning starting from σ 0 , and it is recursively defined as follows: The initial value of σ 0 is given by user, for example, σ 0 = 0.5. It increases by β every time the displacement is under δ, which means staying in the same unit space as explained in Figure 7  When generating A T = at i,j matrix, a probability of transition to unconnected unit spaces is not considered. These constraints have the effect of correcting the case where it is impossible to move on the indoor layout directly. However, this is one reason that fails to generate a valid result when evaluating the probability of an IPS trajectory with considerable noise. We suggest one way with the A matrix that reduces the impact of this problem. This problem can be solved by generating a transition probability between connected unit spaces and between unconnected unit spaces. If they are unconnected to each other, the probability value should be much smaller than that of the adjacent case. A H = ah i,j is a hidden state transition probability matrix that is generated to reflect these characteristics by using an graph I and graph hop distance hop i,j : Note that hop i,j means a minimum hop counts (same as minimum graph hop distance) from nodes u i to u j in U. If i and j are the same or there is no path from u i to u j , zero is returned. h i,j is a weight that sets (hop i,j + 1) 2 as a denominator. Therefore, the larger the hop i,j value, the smaller the h i,j value. The probability of transition to the same unit space is set to one, which is the largest value of h i,j . In other cases, if hop i,j is zero, the nodes u i and u j are not linked on the indoor graph I and h i,j is zero. ah i,j sets to the normalized value of h i,j where 1 ≤ i, j ≤ N.

The Methods of Determining the B Matrix
Another of the fundamental issues of the HSMM is the determination of emission probability distribution B. As discussed in the previous Section 4.1, B can be estimated by the uncertainty regions generated from an IPS trajectory L. To use Equation (11), we should determine how to calculate UR(l), which represents an uncertainty region for an IPS point l. We propose a primary method of UR(l) by a circle buffer polygon which is centered at l.pos with a size of the radius is r = l.e, as shown in Figure 5. This method highly depends on the IPS error value. Unfortunately, almost all IPS does not provide its (average) error size at timestamp t. In this case, we have to set a specific value as the average IPS error value for the target space. For example, we can determine its error value with vast experiment results on the target space.
UR(l) ← Bu f f er(l.pos, l.e) (19) Note that Bu f f er(pos, r) is a point buffer which centered at pos with a fixed width r. The radius of uncertainty circle region r might be determined as an indoor positioning error e. However, the distribution of IPS error is unstable. Therefore, we have to consider more various condition to cover exceptional cases such as a Euclidean distance between current IPS point l t .pos and previous IPS point l t−1 .pos is greater than l t .e. We assume that a Euclidean distance between an IPS point l i and previous IPS point l i−1 is the maximum positioning error value. Then, an adaptive radius r i for l i is defined as follows: Example 7. Figure 8 shows an example of applying an adaptive radius. In the case of l 2 , we can see that the uncertainty region for unit space u 4 is only intersected unit spaces u 4 and u 5 when calculating with a given radius l 2 .e. On the other hand, as shown in a blue circle, when calculated as the adaptive radius, observation probabilities are generated for the unit spaces u 1 and u 3 , additionally. It helps to consider various paths for a given IPS trajectory. Unlike the A matrix, the B matrix's probability distribution depends on the input IPS trajectory. In other words, the probability distribution is not constructed for all unit spaces in an indoor layout. When evaluating this narrow probability distribution, various results are not taken into account. We have to generate a base probability distribution for the B matrix from considering all unit spaces to resolve it. For this purpose, we propose a base method of using a unit space's geometry-based buffer UR space (u): Note that Bu f f er(geom, d) is a polygon buffer with polygon geom with a fixed width d. According to the concept of base method, the emission probability ep(l t |u j ), defined in Equation (11), should be changed as below.
Note that u i is a unit space where l t located.

Indoor Distance-Based Correction
In the previous section, we introduced the basic HSMM method as one of the USMM methods. However, the indoor trajectory of moving objects can be corrected by the correction method using the spatial characteristics before doing map matching. Indoor spaces are separated by walls, and walls are often considered the most important elements of an indoor map. In this paper, we used an indoor distance constrained by the topology of spaces and the geometry of walls. There are several ways to determine indoor distance based on where the two points are located [71][72][73]. We used minimal indoor walking distance Dist indoor (l f rom , l to ) based on Doors Graph to compute the indoor distance, based on the previous works in [72]. We can easily find irregular coordinates in the given trajectory as per the requirement below. Assumption 1. Given two continuous coordinates l i , l i+1 from the given IPS trajectory L = (l 1 , l 2 , ..., l m ), a minimum indoor walking distance Dist miwd (l i , l i+1 ) should be smaller than a maximum indoor distance d MAX within sampling time.
When an object moves in an indoor space, the moving distance is limited by the maximum speed. According to the literature [74,75], a human's comfortable walking speed is 1-1.5 m/s. Similarly, we can assume the maximum speed of pedestrians in indoor space as 5.0 m/s when they are running. If the moving distance of an object exceeds the maximum speed, we have to adjust the current location within the area of the maximum distance.
The problem is how to correct the irregular location which has exceeds the maximum distance. A pattern where the IPS trajectory is across rooms beside a long corridor is one of the most frequent PDR error cases in our experience. Therefore, we make an indoor distance-based correction method for revising to a more passable space such as a corridor. An algorithm for the indoor distance-based correction is as below.
Note that Length(L = (l 1 , ..., l m )) is length of trajectory L. We used linear interpolation to calculate Euclidean distance between two points l i and l i+1 , 1 ≤ i < m. NearestPoint(g a , g b ) computes the nearest point of two geometries g a and g b , where on g a . Algorithm 2 is consists of two phases: First, we find all candidate unit spaces according to the connectivity of unit spaces. There are two conditions to determine candidate unit space.
• topology condition: The candidate unit space u i should connect to u s (or u e ) which containing starting (or ending) IPS point l s (or l e ) respectively. • degree condition: Furthermore, a degree of node u i in the graph I should be more than a given minimum threshold value δ. This condition is derived from a characteristic of the corridor which has several connections with rooms.
Second, we find the nearest point l e on the segment of the indoor route trajectory L segement from the endpoint l e . Each segment is derived from the intersection between the candidate unit space u ∈ U candidate and the indoor route trajectory L miwd . If the number of candidate unit spaces is more than two, we determine l e , which has the shortest distance that the Euclidean distance between l e and l e .
Example 8. Figure 9 shows an example of correction by indoor distance. As the distance from l 3 to l 4 exceeds the maximum distance as a red solid line, we find candidate unit spaces. We can find u 1 , u 3 , u 4 , u 5 by topology condition, but it filtered as u 1 by degree condition δ = 3. Then, we find a correction point l 4 on the indoor distance route, where nearest to point l 4 . As shown in Section 6, it improves the accuracy as well.

Algorithm 2 Indoor_Distance_Correction
Input: -l s , l e : starting and ending IPS points d MAX : maximum indoor distance value -I: indoor accessibility graph as < U, E > δ: threshold value for minimum degree Output: -l e : modified IPS point Begin 1: l e ← l e 2: u s ∈ U ← the unit space containing l s 3: u e ∈ U ← the unit space containing l e 4: L miwd ← the route of minimal indoor walking distance between l s and l e using I 5: if (u s = u e ) ∧ (L miwd = NULL) ∧ (Length(L miwd ) > d MAX ) then 6: U candidate ← array for storing candidate unit spaces 7: for all u i ∈ U do 8: if e s,i ∈ E ∨ e i,e ∈ E then 9: if deg i ≥ δ then 10 for all u ∈ U candidate do 16: L segment ← L miwd ∩ u 17: l tmp ← NearestPoint(L segment , l e ) 18: if Dist(l tmp , l e ) < d tmp then 19:

Experiments
We have performed an extensive experiment for USMM by the hidden Markov model. In this section, we present the results and analysis of the experiments.

Experiment Environments
In order to carry out our experiments, we prepared two sites: One is the fourth floor of Building 313 in Pusan National University campus in the Republic of Korea, which consists of 30 cells as shown in Figure 10a. The building's layout was similar to hotels and apartments, with a long corridor and rooms of different sizes on either side of the corridor. The other is an office building with several rooms and corridors provided in VITA [76] as shown in Figure 10b. The synthetic site is similar to a real experiment site, but firewalls divide a corridor into several spaces. The test environment was given in a two-dimensional space for simplicity. We assume that they are polygon without overlapping. The indoor positioning data was collected in two different ways: • The real trajectories of moving objects were collected by an indoor positioning application named BuildNGO [30], which is based on a hybrid approach with various sensors (Wi-Fi, BLE, GPS, accelerometer, gyroscope, and digital compass) data with PDR. This IPS has an average positioning accuracy of 1-3 m in the official. After collecting the experiment site's fingerprint with BuildNGO, we developed an android application to collect trajectory information using their SDK. We can get discrete coordinates of a device by setting a sampling interval as one second. Furthermore, to evaluate the positioning accuracy, users need to press a button on the android application when they walk through doors to record the corresponding timestamps. Thus, we can get the ground truth location's symbol at each walking step by interpolating based on these doors' locations and corresponding timestamps of encountering them. • Indoor mobility objects generator (VITA (https://github.com/longaspire/vita (accessed on 1 November 2020))) collected the synthetic trajectories of moving objects, which generates synthetic radio signal data for APs installed in the indoor space and generates positioning data for the moving object using these wireless signal data. VITA has various options to make moving object trajectories, e.g., AP device type, deployment model, number of AP devices, number of moving objects, a maximum speed of moving object, and so on. In this experiment, we generated 180 trajectories pairs (position with a trilateration positioning algorithm [77] and ground truth) with the default setting values.
The detailed information of collected trajectories are as summarized in Table 1.

Comparison of the Accuracy
We need to determine the buffer's size and the sliding window's size to perform the HSMM. If we know the IPS noise size e at timestamp t, we can use it for buffer size. Unfortunately, we cannot get IPS noise information using Sails SDK for BuildNGO. Therefore, we used a fixed size of the buffer instead of IPS noise. We observed the relationship between the accuracy and the buffer size r incrementing by 0.5 m, starting from 0.5 to end 2.5 m for real and synthetic datasets. We also observed the relationship between the accuracy and sliding window size w incrementing by two, starting from 4 and ending at 40. The maximum moving distance per second for pedestrians was set to five meters, as mentioned in Section 5. Last, we distinguish the real and synthetic datasets as two groups to observe the effectiveness of r and w according to IPS accuracy. In this experiment, we divided groups based on the accuracy of the NSMM, i.e., NSMM accuracy is over 80 or not. The ratio of the number of correct matching positions to the total number of positions is used as the accuracy rate to evaluate the effects of each USMM method. Note that the position is represented as a symbolic code of unit space. A correct matching position is that if the USMM result of the input trajectory and the NSMM result of the ground truth trajectory are the same at a particular timestamp.
We evaluated all combination of proposed methods for HSMM: • three A matrix setup methods: -AT: indoor graph connectivity-based, -AH: indoor graph minimum hop distance-based, -AS: staying probability-based. We set a parameter for AS is as below; initial probability σ 0 = 0.5, distance threshold δ = 0.5 m, and increment probability value β = 0.1. Last, we also evaluated the accuracy of whether to apply an Indoor Distance-based Correction (IDC) with a minimum threshold value of the degree as five.
An important observation of the real data experiment results in Figure 11a,b. It shows that all proposed methods give significant improvements in accuracy when the position data collected indoor positioning are inaccurate (Figure 11a). In contrast, they do not show any benefit if the indoor positioning is accurate enough (Figure 11b). We can check the effect of fixed buffer size r according to the IPS accuracy, especially when did not apply IDC. If IPS has low accuracy, a larger buffer size becomes more accurate. In contrast, smaller buffer size is better than a larger one if IPS has high accuracy. However, if IDC is applied, there is no significant improvement according to r, but it improves accuracy compare to what did not apply. These results show that IDC trajectories are similar to natural ones, such as ground truth trajectories. As a result, there are not many corrected points compared to the original trajectory. Moreover, IDC is not effective when IPS has high accuracy because the original trajectory is already similar to the ground truth, and as we expected, the HSMM with AT (or AH), BS and corrected by indoor distance shows the best accuracy for most cases in Figure 11a. The effectiveness of AS is not well compared to AT (or AH), because AS depends on the moving object's status. All trajectories in the real dataset are kept moving, and are not stationary. In Figure 12, we observe similar results with the Figure 11. The proposed methods give significant improvements in accuracy when the position data collected indoor positioning is inaccurate. Almost all proposed methods' accuracy is increasing according to increment window size w except AS. As we mentioned, the real dataset trajectory is kept moving, so it is not suitable to AS. The AS methods' accuracy decreases when the big enough w makes self-transition probability a i,i too small.
The proposed USMM methods act the same as the multi-labeled classifiers. Therefore, we calculated the Mirco-Average F1-Score [79] of each USMM method using a real dataset for performance comparison, as shown in Figure 13. In this case, we used the entire dataset, not distinguished by the accuracy of the NSMM. The results have almost the same trend as the accuracy results-applying IDC is always better performance than not applied. The AT and AH are better than AS, and BS is better than BC. And the window size w is not highly affected on performance, but the performance of AS decreased with incremental window size.  As shown in Figure 14, a simple synthetic dataset shows that almost all proposed methods get better accuracy than NSMM, similar to real dataset results as shown in Figure 11, except AS with BS method. Especially, the accuracy of HSMM with AT (or AH) and BC is almost 13% higher than NSMM accuracy. One peculiar point is BS option's accuracy is relatively low when IDC is applied. In our observation, the BS option works well when spaces are connected to one huge or long corridor. It means the performance of each option in HSMM is affected by a structure of space. Similar to real dataset results, if IDC is applied, there is no significant improvement according to r. Still, it improves accuracy compare to did not apply one when using BC. Special cases that a moving object is staying in one space exist in the synthetic dataset. However, AS does not work well because it depends on a distance threshold that uses Euclidean distance between two IPS points with a certain error. The AS method may consider not only distance information but also other information from internal sensors of a smartphone, such as an accelerometer and gyro sensors, for the well-detecting context of the user, such as stop or move. In this paper, we only consider coordinate information, so AS has limitations. The highest accuracy of each method is when r is 1.5 (and 2.0 with IDC). We analyzed that this result has dependent on the average error of the synthetic dataset, as mentioned in Table 1. In Figure 15, we observed similar pattern with the Figure 12. There is no big difference according to window size w if the window size is big enough (over 20).

Processing Time
The processing time is also one of the important requirements of USMM methods as the objective of the USMM is to provide the located space of moving objects' during sampling time. In particular, the processing time becomes critical, as the mobile device of the pedestrian has limited computing power. As we introduced in Sections 4.2 and 4.3, there are two steps to do map matching; (1) setting up HSMM, (2) evaluate the given path with HSMM. First, almost all setup methods A matrix (AT, AH, AS) and B matrix (BC) can be pre-calculated and initialized. Some methods are updated A and B matrix during the set up phase, but in this case, it only updates one row in the matrix. Therefore, the time complexity of the set up phase is O(N), N is a number of states in HSMM. Last, we used a Forward algorithm in HMM, and its time complexity is O(TN 2 ), where T is the length of the given path. However, there are few transitions (or connections) between states according to the characteristic of indoor space as shown in Figures 5 and 10. T is also limited by window size w. As we mentioned in the previous section, we have implemented a proposed method (HSMM) in the Android application that collects real positioning data, where the hardware specification is as shown in Table 2. In the real experiment site, the average turnaround time was measured as 0.233 s when did not apply the IDC method and 0.271 s with the IDC method. These results are within the requirement given in Section 3.6.

Discussion
The results obtained from the real and synthetic dataset experiments show the effectiveness of the HSMM. Table 3 shows the summary of the best options in experiment results. Almost all methods of HSMM are better than NSMM when the IPS accuracy is low. In contrast, if the IPS has high accuracy, HSMM cannot get any benefit. We summarized each HSMM method and additional options in the aspect of accuracy as below.

•
The effect of fixed buffer size r is inversely proportional to the IPS accuracy. This means the performance of HSMM is affected by the error of IPS. If we know about IPS error size at timestamp t, the HSMM accuracy can significantly improve. • The AT (or AH) usually achieves good USMM accuracy.
• The AS does not work well because almost all trajectory data represent kept moving, and its status (moving or staying) is hard to determine only coordinate information. • The BC usually working well on both synthetic and real sites. However, if a unit space is connected with a large number of unit spaces, such as a long hallway in the real site case, BS can achieve better than BC.

•
The window size w and USMM accuracy are proportional. However, if the w is large enough, it has little effect on accuracy. • The IDC trajectory works well on the simple site with a long hallway. The IDC algorithm is structurally working well with a huge unit space that the huge unit space is connected to multiple unit spaces, especially when it is actually in the huge unit space but is positioned in the adjacent unit space. We can expect it is useful such as hotel, school, university, hospital, etc.
However, there is a limitation in that the conducted experiment was performed on a structurally simple building. We confirmed that the topological structure of the unit space affects the accuracy of the proposed methods due to the experiment. Therefore, additional experiments in large and complex buildings such as department stores and convention centers are needed to verify the robustness of the proposed method.

Conclusions and Future Work
Unlike outdoor space, indoor space is surrounded by architectural components such as walls and doors. It naturally divides indoor space into a set of unit spaces such as rooms, corridors, staircases, or elevators. To properly interpret the context of moving objects and provide indoor spatial information services, we have to discover the unit space where it is located. The symbolic space model is a model for a fundamental understanding of indoor space. It means the unit space is more useful than simple (x, y, z) coordinates.
This paper proposed several methods to discover the unit space from the position in (x, y, z) collected from the IPS based on the hidden Markov model. An indoor distancebased correction method was also proposed to improve the accuracy of USMM. We carried out an extensive experiment to analyze the accuracy and compare the proposed methods with a real data set. The experimental results show that the proposed methods improve accuracy when the accuracy of the indoor positioning method is low. For example, when the NSMM accuracy of indoor positioning is~57%, our HSMM method yields accuracies higher than 75%.
The contributions of our work are summarized as follows: • Formulated the unit space map matching (USMM) problem, which translates IPS trajectory to proper unit space identifier. • Developed several USMM methods based on the hidden Markov model, named HSMM, with three A matrix setup methods and two B matrix setup methods. • Developed minimum indoor walking distance-based correction method as preprocess step. • Analyze the accuracy of the HSMM methods by extensive experiments with a synthetic and real dataset. The results of experiments show that the HSMM methods show significant improvements in accuracy, mainly when the accuracy of indoor positioning (NSMM) is low.
As it is one of the first studies on USMM, several issues are to be discussed and improved to the best of our knowledge. For example, we did not consider the speed and heading of moving objects. We expect that it would be possible to considerably improve the accuracy by including these factors in our model, not only map information. We can also improve the accuracy of USMM by taking into account human activity recognition (e.g., running, climbing stairs, and so on).
We evaluated proposed methods using a simple indoor environment (consisting of a long hallway and several rooms). However, indoor environments can be more complex in the real world, such as airports and shopping malls. These complex indoor environments consist of complex shapes of space, such as polygon with holes or a large open space. The usefulness of the proposed method deteriorates in a large open space. We need to consider how to divide a complex space into meaningful unit spaces and a USMM method to overcome this issue.
Last, we considered 2D coordinates (and 2.5D coordinates) with 2D floorplans in the experiment. Nevertheless, we can extend the proposed methods to 3D space. For example, we can calculate the volume of the uncertainty region instead of the area. The experiment with 3D environments can show the utility of the proposed methods.

Data Availability Statement:
The data presented in this study are available from the author upon reasonable request.

Conflicts of Interest:
The authors declare no conflict of interest.