View Javadoc
1   /*
2    * Copyright (C) 2019 Alberto Irurueta Carro (alberto@irurueta.com)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.irurueta.navigation.indoor.fingerprint;
17  
18  import com.irurueta.geometry.Point;
19  import com.irurueta.navigation.LockedException;
20  import com.irurueta.navigation.indoor.RadioSource;
21  import com.irurueta.navigation.indoor.RssiFingerprint;
22  import com.irurueta.navigation.indoor.RssiFingerprintLocated;
23  import com.irurueta.navigation.indoor.RssiReading;
24  
25  import java.util.List;
26  
27  /**
28   * Base class for position and radio source estimators based on located fingerprints
29   * containing only RSSI readings.
30   * All implementations of this class estimate the position of a new fingerprint
31   * and the position of all radio sources associated to fingerprints whose location
32   * is known.
33   *
34   * @param <P> a {@link Point} type.
35   */
36  public abstract class FingerprintPositionAndRadioSourceEstimator<P extends Point<?>> extends
37          BaseFingerprintPositionAndRadioSourceEstimator<P, FingerprintPositionAndRadioSourceEstimatorListener<P>> {
38  
39      /**
40       * True indicates that mean effects are removed to find nearest located fingerprints
41       * based on RSSI readings. False indicates that RSSI readings are directly used, which
42       * might be inaccurate due to bias effects on new fingerprint readings for unknown
43       * locations.
44       * By default, mean effects are removed to remove possible bias effects due to
45       * readings measured by different devices with different hardware.
46       */
47      protected boolean useNoMeanNearestFingerprintFinder = true;
48  
49      /**
50       * Constructor.
51       */
52      protected FingerprintPositionAndRadioSourceEstimator() {
53      }
54  
55      /**
56       * Constructor.
57       *
58       * @param listener listener in charge of handling events.
59       */
60      protected FingerprintPositionAndRadioSourceEstimator(
61              final FingerprintPositionAndRadioSourceEstimatorListener<P> listener) {
62          super(listener);
63      }
64  
65      /**
66       * Constructor.
67       *
68       * @param locatedFingerprints located fingerprints containing RSSI readings.
69       * @param fingerprint         fingerprint containing readings at an unknown location
70       *                            for provided located fingerprints.
71       * @throws IllegalArgumentException if either non located fingerprint or located
72       *                                  fingerprints are null.
73       */
74      protected FingerprintPositionAndRadioSourceEstimator(
75              final List<? extends RssiFingerprintLocated<? extends RadioSource,
76                      ? extends RssiReading<? extends RadioSource>, P>> locatedFingerprints,
77              final RssiFingerprint<? extends RadioSource,
78                      ? extends RssiReading<? extends RadioSource>> fingerprint) {
79          super(locatedFingerprints, fingerprint);
80      }
81  
82      /**
83       * Constructor.
84       *
85       * @param locatedFingerprints located fingerprints containing RSSI readings.
86       * @param fingerprint         fingerprint containing readings at an unknown location
87       *                            for provided located fingerprints.
88       * @param listener            listener in charge of handling events.
89       * @throws IllegalArgumentException if either non located fingerprint or located
90       *                                  fingerprints are null.
91       */
92      protected FingerprintPositionAndRadioSourceEstimator(
93              final List<? extends RssiFingerprintLocated<? extends RadioSource,
94                      ? extends RssiReading<? extends RadioSource>, P>> locatedFingerprints,
95              final RssiFingerprint<? extends RadioSource,
96                      ? extends RssiReading<? extends RadioSource>> fingerprint,
97              final FingerprintPositionAndRadioSourceEstimatorListener<P> listener) {
98          super(locatedFingerprints, fingerprint, listener);
99      }
100 
101     /**
102      * Indicates which fingerprint finder is used.
103      * True indicates that mean effects are removed to find nearest located fingerprints
104      * based on RSSI readings. False indicates that RSSI readings are directly used, which
105      * might be inaccurate due to bias effects on new fingerprint readings for unknown
106      * locations.
107      * By default, mean effects are removed to remove possible bias effects due to
108      * readings measured by different devices with different hardware.
109      *
110      * @return indicates which fingerprint finder is used.
111      */
112     public boolean getUseNoMeanNearestFingerprintFinder() {
113         return useNoMeanNearestFingerprintFinder;
114     }
115 
116     /**
117      * Specifies which fingerprint finder is used.
118      * True indicates that mean effects are removed to find nearest located fingerprints
119      * based on RSSI readings. False indicates that RSSI readings are directly used, which
120      * might be inaccurate due to bias effects on new fingerprint readings for unknown
121      * locations.
122      * By default, mean effects are removed to remove possible bias effects due to
123      * readings measured by different devices with different hardware.
124      *
125      * @param useNoMeanNearestFingerprintFinder indicates which fingerprint finder is used.
126      * @throws LockedException if estimator is locked.
127      */
128     public void setUseNoMeanNearestFingerprintFinder(final boolean useNoMeanNearestFingerprintFinder)
129             throws LockedException {
130         if (isLocked()) {
131             throw new LockedException();
132         }
133         this.useNoMeanNearestFingerprintFinder = useNoMeanNearestFingerprintFinder;
134     }
135 
136 }