1 /*
2 * Copyright (C) 2018 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;
17
18 import com.irurueta.algebra.Matrix;
19 import com.irurueta.geometry.Point;
20
21 import java.util.List;
22
23 /**
24 * Data related to a beacon whose location is known.
25 *
26 * @param <P> a {@link Point} type.
27 */
28 public class BeaconLocated<P extends Point<?>> extends Beacon implements RadioSourceLocated<P> {
29
30 /**
31 * Position where beacon is located.
32 */
33 private P position;
34
35 /**
36 * Covariance of inhomogeneous coordinates of current position (if available).
37 */
38 private Matrix positionCovariance;
39
40 /**
41 * Constructor.
42 *
43 * @param identifiers list of the multipart identifiers of the beacon.
44 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI
45 * (expressed in dBm's).
46 * @param position position where beacon is located.
47 * @throws IllegalArgumentException if either identifiers or position are null.
48 */
49 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower, final P position) {
50 super(identifiers, transmittedPower);
51
52 if (position == null) {
53 throw new IllegalArgumentException();
54 }
55
56 this.position = position;
57 }
58
59 /**
60 * Constructor.
61 *
62 * @param identifiers list of the multipart identifiers of the beacon.
63 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).
64 * @param bluetoothAddress the bluetooth mac address.
65 * @param beaconTypeCode the two byte value indicating the type of beacon.
66 * @param manufacturer a two byte code indicating the beacon manufacturer.
67 * @param serviceUuid a 32 bit service uuid for the beacon.
68 * @param bluetoothName the bluetooth device name.
69 * @param position position where beacon is located.
70 * @throws IllegalArgumentException if either identifiers or position are null.
71 */
72 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower,
73 final String bluetoothAddress, final int beaconTypeCode, final int manufacturer,
74 final int serviceUuid, final String bluetoothName, final P position) {
75 super(identifiers, transmittedPower, bluetoothAddress, beaconTypeCode, manufacturer, serviceUuid,
76 bluetoothName);
77
78 if (position == null) {
79 throw new IllegalArgumentException();
80 }
81
82 this.position = position;
83 }
84
85 /**
86 * Constructor.
87 *
88 * @param identifiers list of the multipart identifiers of the beacon.
89 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI
90 * (expressed in dBm's).
91 * @param position position where beacon is located.
92 * @param positionCovariance covariance of inhomogeneous coordinates of current
93 * position (if available).
94 * @throws IllegalArgumentException if either identifiers or position are null.
95 */
96 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower, final P position,
97 final Matrix positionCovariance) {
98 this(identifiers, transmittedPower, position);
99
100 if (positionCovariance != null) {
101 var dims = position.getDimensions();
102 if (positionCovariance.getRows() != dims || positionCovariance.getColumns() != dims) {
103 throw new IllegalArgumentException();
104 }
105 }
106 this.positionCovariance = positionCovariance;
107 }
108
109 /**
110 * Constructor.
111 *
112 * @param identifiers list of the multipart identifiers of the beacon.
113 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).
114 * @param bluetoothAddress the bluetooth mac address.
115 * @param beaconTypeCode the two byte value indicating the type of beacon.
116 * @param manufacturer a two byte code indicating the beacon manufacturer.
117 * @param serviceUuid a 32 bit service uuid for the beacon.
118 * @param bluetoothName the bluetooth device name.
119 * @param position position where beacon is located.
120 * @param positionCovariance covariance of inhomogeneous coordinates of current
121 * position (if available).
122 * @throws IllegalArgumentException if either identifiers or position are null.
123 */
124 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower,
125 final String bluetoothAddress, final int beaconTypeCode, final int manufacturer,
126 final int serviceUuid, final String bluetoothName, final P position,
127 final Matrix positionCovariance) {
128 this(identifiers, transmittedPower, bluetoothAddress, beaconTypeCode, manufacturer, serviceUuid, bluetoothName,
129 position);
130
131 if (positionCovariance != null) {
132 final var dims = position.getDimensions();
133 if (positionCovariance.getRows() != dims || positionCovariance.getColumns() != dims) {
134 throw new IllegalArgumentException();
135 }
136 }
137 this.positionCovariance = positionCovariance;
138 }
139
140 /**
141 * Constructor.
142 *
143 * @param identifiers list of the multipart identifiers of the beacon.
144 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI
145 * (expressed in dBm's).
146 * @param frequency frequency used by this Beacon.
147 * @param position position where beacon is located.
148 * @throws IllegalArgumentException if either identifiers or position are null or
149 * frequency is negative.
150 */
151 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower,
152 final double frequency, final P position) {
153 super(identifiers, transmittedPower, frequency);
154
155 if (position == null) {
156 throw new IllegalArgumentException();
157 }
158
159 this.position = position;
160 }
161
162 /**
163 * Constructor.
164 *
165 * @param identifiers list of the multipart identifiers of the beacon.
166 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).
167 * @param frequency frequency used by this Beacon.
168 * @param bluetoothAddress the bluetooth mac address.
169 * @param beaconTypeCode the two byte value indicating the type of beacon.
170 * @param manufacturer a two byte code indicating the beacon manufacturer.
171 * @param serviceUuid a 32 bit service uuid for the beacon.
172 * @param bluetoothName the bluetooth device name.
173 * @param position position where beacon is located.
174 * @throws IllegalArgumentException if either identifiers or position are null or
175 * frequency is negative.
176 */
177 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower,
178 final double frequency, final String bluetoothAddress, final int beaconTypeCode,
179 final int manufacturer, final int serviceUuid, final String bluetoothName, final P position) {
180 super(identifiers, transmittedPower, frequency, bluetoothAddress, beaconTypeCode, manufacturer, serviceUuid,
181 bluetoothName);
182
183 if (position == null) {
184 throw new IllegalArgumentException();
185 }
186
187 this.position = position;
188 }
189
190 /**
191 * Constructor.
192 *
193 * @param identifiers list of the multipart identifiers of the beacon.
194 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI
195 * (expressed in dBm's).
196 * @param frequency frequency used by this Beacon.
197 * @param position position where beacon is located.
198 * @param positionCovariance covariance of inhomogeneous coordinates of current
199 * position (if available).
200 * @throws IllegalArgumentException if either identifiers or position are null or
201 * frequency is negative.
202 */
203 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower,
204 final double frequency, final P position, final Matrix positionCovariance) {
205 this(identifiers, transmittedPower, frequency, position);
206
207 if (positionCovariance != null) {
208 final var dims = position.getDimensions();
209 if (positionCovariance.getRows() != dims || positionCovariance.getColumns() != dims) {
210 throw new IllegalArgumentException();
211 }
212 }
213 this.positionCovariance = positionCovariance;
214 }
215
216 /**
217 * Constructor.
218 *
219 * @param identifiers list of the multipart identifiers of the beacon.
220 * @param transmittedPower calibrated measured Tx power of the Beacon in RSSI (expressed in dBm's).
221 * @param frequency frequency used by this Beacon.
222 * @param bluetoothAddress the bluetooth mac address.
223 * @param beaconTypeCode the two byte value indicating the type of beacon.
224 * @param manufacturer a two byte code indicating the beacon manufacturer.
225 * @param serviceUuid a 32 bit service uuid for the beacon.
226 * @param bluetoothName the bluetooth device name.
227 * @param position position where beacon is located.
228 * @param positionCovariance covariance of inhomogeneous coordinates of current
229 * position (if available).
230 * @throws IllegalArgumentException if either identifiers or position are null or
231 * frequency is negative.
232 */
233 public BeaconLocated(final List<BeaconIdentifier> identifiers, final double transmittedPower,
234 final double frequency, final String bluetoothAddress, final int beaconTypeCode,
235 final int manufacturer, final int serviceUuid, final String bluetoothName, final P position,
236 final Matrix positionCovariance) {
237 this(identifiers, transmittedPower, frequency, bluetoothAddress, beaconTypeCode, manufacturer, serviceUuid,
238 bluetoothName, position);
239
240 if (positionCovariance != null) {
241 var dims = position.getDimensions();
242 if (positionCovariance.getRows() != dims || positionCovariance.getColumns() != dims) {
243 throw new IllegalArgumentException();
244 }
245 }
246 this.positionCovariance = positionCovariance;
247 }
248
249 /**
250 * Empty constructor.
251 */
252 protected BeaconLocated() {
253 super();
254 }
255
256 /**
257 * Gets position where beacon is located.
258 *
259 * @return position where beacon is located.
260 */
261 public P getPosition() {
262 return position;
263 }
264
265 /**
266 * Gets covariance of inhomogeneous coordinates of current position (if available).
267 *
268 * @return covariance of position or null.
269 */
270 public Matrix getPositionCovariance() {
271 return positionCovariance;
272 }
273 }