public SnifferModel()
        {
            PositionEstimate dummyPos = new PositionEstimate();
            dummyPos.ID = 0;
            dummyPos.VertexID = 1;
            dummyPos.Latitude = 10;
            dummyPos.Longitude = 20;
            dummyPos.Altitude = 3;
            dummyPos.Time = DateTime.Now;

            _positionEstimates.Add(dummyPos);           
        }        
示例#2
0
        public SnifferModel()
        {
            PositionEstimate dummyPos = new PositionEstimate();

            dummyPos.ID        = 0;
            dummyPos.VertexID  = 1;
            dummyPos.Latitude  = 10;
            dummyPos.Longitude = 20;
            dummyPos.Altitude  = 3;
            dummyPos.Time      = DateTime.Now;

            _positionEstimates.Add(dummyPos);
        }
        public PositionEstimate GetPosition(string clientMac)
        {
            /**
             * [WebGet] = SnifferReceiver operation (cf: http://msdn.microsoft.com/en-us/library/cc668788.aspx )
             * usage example: http://localhost:38244/SnifferService.svc/GetPosition?mac='Big Mac'
             */

            if (clientMac == null)
            {
                return(null);
            }

            SnifferWifiMeasurement curMeas;

            if (!(currentOnlineMeasurements.TryGetValue(clientMac, out curMeas)))
            {
                return(null); //we do not have a measurement yet to base an estimate on
            }

            //Check whether the client is associated with a building
            //If not, positioning has (JUST) been requested, but the correct building not established yet.
            WifiPosEngine posEngine;

            if (!(currentWifiPosEngines.TryGetValue(clientMac, out posEngine)))
            {
                return(null); //we do not have a wifi pos engine. Reason: User has probably not called StartWifiPositioning.
            }

            if (posEngine.getCurrentBuilding() == null) //It is the very first estimate
            {
                posEngine.setCurrentBuilding(getCorrectBuilding(curMeas));
            }

            EstimateResult currentEstimate = posEngine.getEstimate(curMeas);

            //We have a result
            if (currentEstimate != null && currentEstimate.getVertex() != null)
            {
                //convert estimated location to PositionEstimate
                PositionEstimate result = new PositionEstimate();
                Vertex           v      = currentEstimate.getVertex();
                AbsoluteLocation a      = v.AbsoluteLocations.First();

                result.VertexID    = v.ID;
                result.Building_ID = v.Building_ID;
                result.Latitude    = (double)a.latitude;
                result.Longitude   = (double)a.longitude;
                result.Altitude    = (double)a.longitude;
                result.Accuracy    = currentEstimate.getErrorEstimate();
                result.HasAccuracy = true;
                result.HasBearing  = false;
                result.HasSpeed    = false;
                result.Provider    = WIFI_PROVIDER;
                result.Time        = DateTime.Now;

                return(result);
            }
            else //We do not have a result
            {
                return(null);
            }
        }