2.1. Wi-Fi-Based Indoor Localization
Wi-Fi-based indoor localization has emerged as a widely used framework for enabling LBSs. This popularity stems from the existing Wi-Fi infrastructure, where WAPs deployed for wireless local area networks (WLANs) can be leveraged for localization without requiring additional hardware installation. Wi-Fi-based indoor positioning systems utilize these pre-existing networks, reducing deployment costs and simplifying implementation. Approaches to Wi-Fi-based indoor localization are generally categorized into two types: geometric mapping and fingerprinting.
Geometric mapping methods rely on measurements such as time of arrival (ToA) [
24,
25,
26] and angle of arrival (AoA) [
24,
27,
28,
29] to estimate a device’s position. Time of arrival (ToA) represents the time at which a signal reaches the receiver and is used to calculate the distance between the device and the receiver based on this measurement. This estimated distance is then applied to estimate the device’s location through trilateration. However, due to the limited bandwidth of Wi-Fi signals (typically between 20 and 160 MHz), ToA-based distance estimation has low resolution, leading to decreased accuracy. To mitigate this, some methods [
25,
26] employ virtual bandwidth to improve ToA accuracy. However, these methods require precise time synchronization across all APs or rely on channel hopping, which disrupts regular data communication.
AoA-based methods utilize multiple antennas and array signal processing techniques to analyze the phase differences between antennas to calculate the angle of arrival, and this value is then used for triangulation to estimate the user’s location. As demonstrated by SpotFi [
24], employing parametric algorithms such as MUSIC [
30] can further enhance the precision of angle estimation. These methods are effective under ideal conditions. However, they require specialized hardware, as in some AoA-based methods [
27,
28]. Additionally, they are vulnerable to coherent signals, which can lead to decreased accuracy in complex indoor environments. In contrast, fingerprinting-based approaches are data-driven, predicting the user’s location in an online phase using signal patterns collected during an offline phase. These techniques do not require specialized hardware, instead leveraging pre-existing Wi-Fi signal data to perform localization.
Fingerprinting-based approaches have gained popularity due to their practicality and ease of deployment. They require only standard signal strength measurements, such as RSSIs, which are accessible on most Wi-Fi-enabled devices. This makes fingerprinting adaptable to a wide range of indoor environments without the need for expensive or specialized infrastructure.
Wi-Fi fingerprinting operates in two phases: an offline phase and an online phase. During the offline phase, RSSI measurements are collected from multiple WAPs at predefined RPs, creating a radio map that links signal patterns to known locations. In the online phase, the user’s device collects RSSI measurements from its environment, which are matched against the radio map to estimate the user’s position.
A variety of machine learning algorithms are commonly employed to enhance positioning accuracy. SVM-based positioning methods [
6,
7,
8] utilize Wi-Fi signals or RSSI data to learn distinctive, location-specific signal patterns, constructing hyperplanes to separate and classify these locations. However, SVM-based methods can face limitations with slower training and prediction times in large or high-dimensional datasets. RF-based methods [
9,
10,
11] use multiple decision trees to handle large-scale fingerprint datasets effectively. However, RF-based methods require significant computational resources, especially during the training phase. Recent studies have explored artificial neural networks (ANNs), where MLPs with autoencoders, CNNs, and RNNs model complex and sequential patterns in RSSI data, offering enhanced positioning accuracy and flexibility [
12,
13,
14]. While each approach provides unique advantages, challenges such as high computational costs and parameter tuning remain, particularly in large-scale environments.
KNN and its variants remain particularly attractive for Wi-Fi fingerprinting, not only because of their simplicity and ease of implementation but also due to their low computational cost and ability to handle small datasets effectively [
2,
3,
4,
5]. KNN-based methods estimate a user’s location by identifying the
k-nearest RPs based on the similarity between the query fingerprint (RSSI vector) and the fingerprints stored in the radio map [
2]. In the KNN positioning algorithm, this similarity is measured by calculating the distance between the RSSI vector of the target location and the radio map, and methods based on Euclidean distance [
2,
3] and Manhattan distance [
4,
5] have been studied. The distance metrics between the target location and each stored fingerprint are calculated and ranked in ascending order, with the
k closest RPs being selected. The average coordinates of these
k-nearest RPs, whose RSSI values most closely match the query fingerprint, are then used as the estimated position of the target location. Weighted KNN (WKNN) enhances the positioning process by assigning weights to neighbors based on their distance, giving closer reference points greater influence on the position estimation [
4]. This approach takes into account the varying impact of each reference point on the final location estimate, using a weighted average of the coordinates to improve positioning accuracy.
Advanced KNN-based variants, such as SAWKNN [
15] and APD-WKNN [
16], have been developed to address specific challenges. One issue with traditional WKNN methods, which use a fixed
k value, is that they may experience performance degradation when the optimal
k value varies depending on location. Thus, SAWKNN was proposed as a method for dynamically adjusting the
k value according to the environment. APD-WKNN addresses the limitations of traditional distance metrics, which do not accurately reflect physical distance. Due to the indoor signal propagation path and RSSI attenuation, RSSI and positional information do not follow a simple linear relationship. Therefore, APD-WKNN uses an independently developed approximate position distance (APD), which balances the RSSI and signal propagation distance differences according to the spatial signal attenuation law, enabling a more accurate selection of RPs. While SAWKNN and APD-WKNN provide improvements over traditional KNN in terms of accuracy, they still rely on manually crafted distance metrics. As a result, the configured distance metric fails to accurately reflect physical distance and fingerprint similarity [
31].
Various approaches have been explored to enhance the performance of WKNN-based Wi-Fi fingerprinting, including dataset preprocessing [
17], the integration of user trajectory or historical data [
18,
19], or the measurement of RSSIs over a period using PDR techniques [
20]. Hou et al. [
17] employed robust principal component analysis (RPCA) with an adaptive k-selection using the Jenks natural breaks algorithm (JNBA) to improve noise filtering. However, Hou et al.’s method [
17] requires multiple RSSI samples obtained through repeated scans to perform RPCA. Leng et al. [
18] introduced a fusion of Euclidean and cosine distances to improve robustness to device heterogeneity, with an adaptive k-selection strategy based on trajectory data. However, this approach requires a Kalman filter, which relies on time-series data, necessitating multiple scans over time. Zhang et al. [
19] enhanced accuracy by adapting the number of selected RPs based on historical trajectory information. This approach, however, relies on Wi-Fi fingerprint data from the user’s historical trajectory. Poulose et al. [
20] used a sensor fusion framework combining IMU-based PDR with Wi-Fi RSSI data, requiring user movement for accurate position estimation.
Additionally, Narasimman et al. [
32] focused on data adaptation by normalizing labels across different buildings and using only the strongest AP signals. This study was primarily concerned with data adaptation rather than accuracy improvement, placing it outside the primary scope of our work.
Our proposed method specifically targets WKNN-based instant positioning, where positioning is achieved using only the RSSI values from APs at a given location through a single Wi-Fi scan for high usability. This approach is designed with two primary conditions in mind: (1) positioning should be achievable with a single scan, without requiring multiple scans over time, which excludes the use of time-series data; (2) instant positioning should not rely on user movement to obtain location estimates, as our goal is to provide a system with high usability and rapid response times. However, the methods in [
17,
18,
19,
20] cannot meet these requirements, as they require either multiple Wi-Fi scans or user movement, making them unsuitable for instant positioning applications.
In contrast to APD-WKNN, which estimates physical distance based on a signal propagation model, our approach leverages distance metric learning to directly learn the physical distance relationships between reference points. This allows the model to better capture the underlying spatial structure of the environment, resulting in improved positioning accuracy.