Finally, all that we have done during this chapter had one purpose: to display the strength of the signal. We managed to add the cell phone on the map, find the closest tower, and even highlight that tower, but now we need to do some math to calculate the signal. To calculate the signal in terms of percentage, we should establish some rules. If you are sitting just right by the tower, you should get 100 percent signal, and if you are sitting exactly on the edge of the range of the tower, you should have 0 percent signal. So we can deduce that the formula for calculating the signal is as follows:
S = (R – d)/R * 100
In the preceding formula, S
is the signal strength in percentage, R
is the range of the connected tower, and d
is the distance between the cell phone and the tower. Of course, if we get a minus signal, that means we are out of range of the signal.