private void updateNewLocation(WifiSnifferPositioningService.PositionEstimate location) { double distToPrev = -1; //placed here so I can see its value throughoutu the mehthod (for debugging) if (location != null) { bool showNewLocation = true; if (lastUpdatedLocation != null) { //ekstra tjek - paa threshold double oldLat = lastUpdatedLocation.Latitude; double oldLng = lastUpdatedLocation.Longitude; double newLat = location.Latitude; double newLng = location.Longitude; distToPrev = DistanceMeasurements.CalculateMoveddistanceInMeters(oldLat, oldLng, newLat, newLng); if (distToPrev <= this.updateThresholdInMeters) { showNewLocation = false; } } if (showNewLocation) { UI_UpdateNewLocation(location); lastUpdatedLocation = location; //NOTE: MAYBE important to COPY as done here. } lastKnownLocation = location; } }
private static void OnGetPositionComplete(IAsyncResult result) { // Get the radiomapContext back from the stored state. snifferContext = result.AsyncState as SnifferModel; try { WifiSnifferPositioningService.PositionEstimate newPos = snifferContext.EndExecute <WifiSnifferPositioningService.PositionEstimate>(result).FirstOrDefault(); PreviousPositionEstimate = CurrentPositionEstimate; CurrentPositionEstimate = newPos; if (CurrentPositionEstimate != null) { //We notify about a new building in any of these two scenarios: //1) This is the first estimate after starting positioning. //2) The building id of the current estimate differs from the previous bool arrivedAtNewBuilding = PreviousPositionEstimate != null && CurrentPositionEstimate != null && CurrentPositionEstimate.Building_ID != PreviousPositionEstimate.Building_ID; if (!_hasReceivedWifiPosition || arrivedAtNewBuilding) { _hasReceivedWifiPosition = true; OnBuildingIdentificationStatusChanged(null, new BuildingIdentificationEventArgs(true, CurrentPositionEstimate.Building_ID)); } OnPositionEstimateChanged(null, new PositionEstimateEventArgs(CurrentPositionEstimate)); if (AllowTracking) { AddToTrackedPositions(newPos); } } } catch (DataServiceQueryException) { } }
private void UI_UpdateNewLocation(WifiSnifferPositioningService.PositionEstimate location) { if (uiMode == UiMode.GOOGLE_MAPS) { JSInterface.updateNewLocation(browser, location); } else if (uiMode == UiMode.BING_MAPS) { OnPositionEstimateChanged(this, new PositionEstimateArgs(location)); } }
private void LocationService_OnPositionEstimateChange(object sender, LocationService.PositionEstimateEventArgs e) { WifiSnifferPositioningService.PositionEstimate location = e.PositionEstimate; //TODO: Insert a check for whether we need to shift building //location.Building_ID != lastKnownWifiLocation //The rest is part of an else block mCurrentEstimatedFloor = (int)location.Altitude; //placed here because we check floor before updating location //First check if we are even interested in receiving position updates? if (!IsTrackingPosition) { return; } //Then check whether we need to update floor //We change floor if this is the very first wifi location or the location is estimated //at a new floor bool doChangeFloor = false; //Beware: If the locationService changes semantics to broadcasting null estimates (in case of error) //then this null check will not be a valid indicator of a floor change if (lastKnownWifiLocation == null) //No prior pos: We change floor { doChangeFloor = true; } else //Check for new floor { int prevFloor = (int)lastKnownWifiLocation.Altitude; if (prevFloor != mCurrentEstimatedFloor) { doChangeFloor = true; } } lastKnownWifiLocation = location; if (doChangeFloor) { mCurrentSelectedFloor = mCurrentEstimatedFloor; //Globals.ShowDialog(source, "Changing to new floor...", Globals.DURATION_SHORT); refreshUI(); } //the threshold based check for whether to update the location is conducted in updateNewLocation() //as it applies to gps and wi-fi alike updateNewLocation(location); }
/// <summary> /// Both the sniffer backend and radiomap backend define a PositionEstimate entity. /// Therefore, we convert WifiSniffer position estimates to radiomap position-estimates when /// we save tracking data to the radio map backend (which houses the tracking data as well) /// </summary> /// <param name="?"></param> /// <returns></returns> private static TrackedPosition CreateTrackedPosition(WifiSnifferPositioningService.PositionEstimate org) { TrackedPosition res = new TrackedPosition(); res.Accuracy = org.Accuracy; res.Altitude = org.Altitude; res.Bearing = org.Bearing; res.Building_ID = org.Building_ID; res.HasAccuracy = org.HasAccuracy; res.HasBearing = org.HasBearing; res.HasSpeed = org.HasSpeed; res.Latitude = org.Latitude; res.Longitude = org.Longitude; res.Provider = org.Provider; res.Speed = org.Speed; res.Time = DateTime.Now; //org.Time; res.VertexID = org.VertexID; res.ClientID = ClientId; //A guid return(res); }
public PositionEstimateEventArgs(WifiSnifferPositioningService.PositionEstimate pos) { this.PositionEstimate = pos; }
/// <summary> /// Creates a tracked position from a wifi sniffer position estimate and adds it to the tracked positions /// </summary> /// <param name="pos"></param> private static void AddToTrackedPositions(WifiSnifferPositioningService.PositionEstimate pos) { AddToTrackedPositions(CreateTrackedPosition(pos)); }
public PositionEstimateEventArgs(WifiSnifferPositioningService.PositionEstimate pos) { this.PositionEstimate = pos; }
public PositionEstimateArgs(WifiSnifferPositioningService.PositionEstimate loc) { this.Location = loc; }
public PositionEstimateArgs(WifiSnifferPositioningService.PositionEstimate loc) { this.Location = loc; }
private void updateNewLocation(WifiSnifferPositioningService.PositionEstimate location) { double distToPrev = -1; //placed here so I can see its value throughoutu the mehthod (for debugging) if (location != null) { bool showNewLocation = true; if (lastUpdatedLocation != null) { //ekstra tjek - paa threshold double oldLat = lastUpdatedLocation.Latitude; double oldLng = lastUpdatedLocation.Longitude; double newLat = location.Latitude; double newLng = location.Longitude; distToPrev = DistanceMeasurements.CalculateMoveddistanceInMeters(oldLat, oldLng, newLat, newLng); if (distToPrev <= this.updateThresholdInMeters) { showNewLocation = false; } } if (showNewLocation) { UI_UpdateNewLocation(location); lastUpdatedLocation = location; //NOTE: MAYBE important to COPY as done here. } lastKnownLocation = location; } }
private void LocationService_OnPositionEstimateChange(object sender, LocationService.PositionEstimateEventArgs e) { WifiSnifferPositioningService.PositionEstimate location = e.PositionEstimate; //TODO: Insert a check for whether we need to shift building //location.Building_ID != lastKnownWifiLocation //The rest is part of an else block mCurrentEstimatedFloor = (int)location.Altitude; //placed here because we check floor before updating location //First check if we are even interested in receiving position updates? if (!IsTrackingPosition) return; //Then check whether we need to update floor //We change floor if this is the very first wifi location or the location is estimated //at a new floor bool doChangeFloor = false; //Beware: If the locationService changes semantics to broadcasting null estimates (in case of error) //then this null check will not be a valid indicator of a floor change if (lastKnownWifiLocation == null) //No prior pos: We change floor { doChangeFloor = true; } else //Check for new floor { int prevFloor = (int)lastKnownWifiLocation.Altitude; if (prevFloor != mCurrentEstimatedFloor) doChangeFloor = true; } lastKnownWifiLocation = location; if (doChangeFloor) { mCurrentSelectedFloor = mCurrentEstimatedFloor; //Globals.ShowDialog(source, "Changing to new floor...", Globals.DURATION_SHORT); refreshUI(); } //the threshold based check for whether to update the location is conducted in updateNewLocation() //as it applies to gps and wi-fi alike updateNewLocation(location); }