summaryrefslogtreecommitdiffstats
path: root/lookup/ResultScore.java
blob: 2044fda0db7c33566ce33c0e1a3f1a2ab7671b71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//OUTDATED: no longer used: 06.06.2011

package lookup;

import helper.ListBTS;
import helper.ListGPS;

import java.util.ArrayList;
import java.util.List;

import DataStructure.GPScoordinate;
import DataStructure.GSMMap;
import DataStructure.SingleBTS;

public class ResultScore {
	ArrayList<ScoreElement> scores = new ArrayList<ScoreElement>();
	GSMMap map;

	/**
	 * Gets score for every Coordinate
	 * 
	 * @param list
	 */
	public ResultScore(GSMMap map) {
		this.map = map;

	}

	public ArrayList<ScoreElement> find(List<SingleBTS> MR, double thresholdDBm) {
		// looks like threshold_dB has to be as high as 25dBm
		ArrayList<GPScoordinate> places = map.find(MR, thresholdDBm);
		GPScoordinate[] content = ListGPS.content(places);
		for (GPScoordinate curr_content : content) {
			// take every Coordinate once. Build a ScoreElement with it.Traverse
			// all found places
			ScoreElement curr_score = new ScoreElement(curr_content);
			for (GPScoordinate curr_place : places) {
				// count how often this place got marked
				curr_score.inc_occurence(curr_place);
			}
			scores.add(curr_score);

			// traverse every coordinate from gsm.find. check every tile if all
			// mesurements match. if not, score gets low

			// then, check BTS relations!

		}

		// check scores. compare it with map

		// HACK: hardcoded ratio between 877 and 880
		for (int i = 0; i < scores.size(); i++) {
			ScoreElement score_at_i = scores.get(i);
			scores.set(i, ratioboost(score_at_i, MR));

		}

		return scores;
	}

	private ScoreElement ratioboost(ScoreElement place, List<SingleBTS> MR) {
		// MR are the measured values during a call
		// ArrayList<SingleBTS> list = map.getBTSList(place.gps);
		// compare list with MR. Ratio between 877 and 880

		while (ListBTS.contains(MR, 880) && ListBTS.contains(MR, 877)) {
			SingleBTS r880 = ListBTS.removeARFCN(MR, 880);
			SingleBTS r877 = ListBTS.removeARFCN(MR, 877);
			if (r880.getDldB() > -46 || r877.getDldB() > -46) {
				continue;
			}
			double ratio_MR = r880.getDldB() - r877.getDldB();
			// compare ratio with gsmmap. Get a number between 100 and 0 %
			// double ratioscore = 0; // zero means absolutly no match
			ArrayList<SingleBTS> maplist = map.getBTSList(place.gps);
			// check if map has both BTS at this place
			if (ListBTS.contains(maplist, 880)
					&& ListBTS.contains(maplist, 877)) {
				double ratio_map = ListBTS.getARFCN(maplist, 880).getDldB()
						- ListBTS.getARFCN(maplist, 877).getDldB();
				// calculate distance in %
				if (ratio_MR >= ratio_map) {
					place.occurrence += (ratio_map / ratio_MR * 100);
				} else if (ratio_MR < ratio_map) {
					place.occurrence += (ratio_MR / ratio_map * 100);
				}

			}

		}

		return place;
	}

}

class ratio {
	SingleBTS first;
	SingleBTS second;
}