示例#1
0
        public EstimateResult compare(IEnumerable <Vertex> vertices, SnifferWifiMeasurement measurement)
        {
            measurement = getNStrongestAPMeasurement(measurement, 7);

            if (vertices == null || measurement == null)
            {
                return(null);
            }

            bcs = WifiPosEngine.BestCandidateSet; //new BCS(5); //bcs.clear();

            double         curDist;               //distance of current vertice in search space
            EstimateResult result = new EstimateResult(null, double.MaxValue);

            foreach (Vertex curVertex in vertices)                                          //sammenlign med hver Vertex
            {
                foreach (SnifferWifiMeasurement curFP in curVertex.SnifferWifiMeasurements) //sammenlign med hvert fingerprint (usually only one - otherwise use more intelligent approach)
                {
                    curDist = 0;
                    foreach (String mac in measurement.getMACs())             //all APs in sample
                    {
                        if (curFP.containsMac(mac))
                        {
                            curDist += Math.Pow((measurement.getAvgDbM(mac) - curFP.getAvgDbM(mac)), 2);
                        }
                        else
                        {
                            curDist += Math.Pow((measurement.getAvgDbM(mac) - MISSING_MAC_PENALTY), 2);
                        }
                    }

                    curDist = Math.Sqrt(curDist);
                    if (curDist < result.getDistance())
                    {
                        result.setDistance(curDist);
                        result.setVertex(curVertex);
                    }
                    bcs.add(curVertex, curDist);             //add to best candidate set - which will take care of only using the best estimates.
                }
            }
            //The following only yields a local error estimate within the primary- or secondary
            //vertices and may thus not be appropriate
            result.setErrorEstimate(Math.Ceiling(bcs.getMaxDistance()));
            return(result);
        }
	public EstimateResult compare(IEnumerable<Vertex> vertices, SnifferWifiMeasurement measurement)
	{
		measurement = getNStrongestAPMeasurement(measurement, 7);
		
		if (vertices == null || measurement == null)
			return null;
		
		bcs = WifiPosEngine.BestCandidateSet; //new BCS(5); //bcs.clear();
		
		double curDist; //distance of current vertice in search space
		EstimateResult result = new EstimateResult(null, double.MaxValue);
		
		foreach (Vertex curVertex in vertices) //sammenlign med hver Vertex
		{
			foreach (SnifferWifiMeasurement curFP in curVertex.SnifferWifiMeasurements) //sammenlign med hvert fingerprint (usually only one - otherwise use more intelligent approach)
			{
				curDist = 0;
				foreach (String mac in measurement.getMACs()) //all APs in sample
					if (curFP.containsMac(mac))
						curDist += Math.Pow((measurement.getAvgDbM(mac) - curFP.getAvgDbM(mac)), 2);
					else
						curDist += Math.Pow((measurement.getAvgDbM(mac) - MISSING_MAC_PENALTY), 2);
				
				curDist = Math.Sqrt(curDist);
				if (curDist < result.getDistance())
				{
					result.setDistance(curDist);
					result.setVertex(curVertex);
				}
				bcs.add(curVertex, curDist); //add to best candidate set - which will take care of only using the best estimates. 
			}                
		}
		//The following only yields a local error estimate within the primary- or secondary 
		//vertices and may thus not be appropriate
		result.setErrorEstimate(Math.Ceiling(bcs.getMaxDistance()));
		return result;
	}