public void StartLocationUpdates() { _timer = new Timer(_timeupdates); _timer.Elapsed += OnTimerElapsed; _timer.Start(); IsGPSStarted = false; if (CLLocationManager.LocationServicesEnabled) { IsGPSStarted = true; LocMgr.DesiredAccuracy = 1; LocMgr.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { if (_timesuccess) { if (LocationUpdated != null) { LocationUpdated.Invoke(this, new LocationUpdatedEventArgs(e.Locations[e.Locations.Length - 1])); } _timesuccess = false; _timer.Enabled = true; } }; LocMgr.StartUpdatingLocation(); } }
/* * Redirect location updates to the event */ public void OnLocationUpdate(LocationResult result) { if (result == null) { LocationUpdated?.Invoke(this, null); return; } LocationUpdated?.Invoke(this, new LocationEventArgs(result.LastLocation.Longitude, result.LastLocation.Latitude)); }
private void _geoLocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { CurrentLocation = new GeoLocation() { Altitude = args.Position.Coordinate.Point.Position.Altitude, Latitude = args.Position.Coordinate.Point.Position.Latitude, Longitude = args.Position.Coordinate.Point.Position.Longitude, LastUpdated = DateTime.Now.ToJSONString() }; RaisePropertyChanged(nameof(CurrentLocation)); LocationUpdated?.Invoke(this, CurrentLocation); }
void LogLocation(Location location) { if (location != null) { Log.Info(CLIENT_LOG_NAME, $"Latitude: {location.Latitude}"); Log.Info(CLIENT_LOG_NAME, $"Longitude: {location.Longitude}"); Log.Info(CLIENT_LOG_NAME, $"Provider: {location.Provider}"); Latitude = location.Latitude; Longitude = location.Longitude; LocationUpdated?.Invoke(this, null); } }
public void TriggerLocationUpdate(CLLocation[] coreLocations) { foreach (var coreLocation in coreLocations) { var args = new LocationManagerUpdate { NewLocation = coreLocation.ToLocation(), OldLocation = LastLocation }; LocationUpdated?.Invoke(this, args); App.LocationUpdated(this, args); LastLocation = coreLocation.ToLocation(); } }
public void Handle(LocationUpdated @event) { using (var context = new ProjectionContext(ConnectionString.Get())) { var lieu = context.Locations.Find(@event.AggregateId); if (lieu == null) { throw new EntityNotFoundException(@event.AggregateId, "Lieu"); } lieu.Name = @event.Name; lieu.Address = @event.Address; lieu.Seats = @event.Seats; context.SaveChanges(); } }
public void Start() { _locator = CrossGeolocator.Current; _cancelationTokenSource = new CancellationTokenSource(); RecurrentCancellableTask.StartNew(async() => { var location = await _locator.GetPositionAsync(TimeSpan.FromSeconds(10), _cancelationTokenSource.Token).ConfigureAwait(false); LocationUpdated?.Invoke(this, new LocationUpdatedEventArgs(new Location { Longitude = location.Longitude, Altitude = location.Altitude, Latitude = location.Latitude })); }, TimeSpan.FromSeconds(10), _cancelationTokenSource.Token, TaskCreationOptions.LongRunning); }
public void StartUpdatingLocation() { _locationManager.StartUpdatingLocation(); Device.StartTimer(new TimeSpan(0, 0, 1), () => { if (_locationManager.Location != null) { LastLocation = _locationManager.Location.ToLocation(); LocationUpdated?.Invoke(this, new LocationManagerUpdate { NewLocation = LastLocation }); _hasInitialLocation = true; } return(!_hasInitialLocation); }); }
public override void DidUpdateBMKUserLocation(BMKUserLocation userLocation) { mapView.UpdateLocationData(userLocation); if (userLocation.Location == null) { return; } LocationUpdated?.Invoke(this, new LocationUpdatedEventArgs { Coordinate = userLocation.Location.Coordinate.ToUnity(), Direction = userLocation.Heading?.TrueHeading ?? double.NaN, Altitude = userLocation.Location.Altitude, Accuracy = Math.Max(userLocation.Location.HorizontalAccuracy, userLocation.Location.VerticalAccuracy), Satellites = -1 }); }
public TestBkgdLocationUpdates() { _locationManager = new CLLocationManager(); _locationManager.PausesLocationUpdatesAutomatically = false; _locationManager.RequestAlwaysAuthorization(); _locationManager.AllowsBackgroundLocationUpdates = true; _locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { var locationsArray = e.Locations; if ((locationsArray != null) && (locationsArray.Length > 0)) { var lastLocation = locationsArray[locationsArray.Length - 1]; LocationUpdated.Invoke(sender, new LocationUpdatedEventArgs(lastLocation)); } }; }
public void OnReceiveLocation(BDLocation location) { if (stopped) { return; } //Debug.WriteLine("LocType: " + location.LocType); switch (location.LocType) { default: break; case BDLocation.TypeServerError: case BDLocation.TypeNetWorkException: case BDLocation.TypeCriteriaException: break; case BDLocation.TypeGpsLocation: case BDLocation.TypeNetWorkLocation: case BDLocation.TypeOffLineLocation: BMap.MyLocationData loc = new BMap.MyLocationData.Builder() .Accuracy(location.Radius) .Direction(location.Direction) .Latitude(location.Latitude) .Longitude(location.Longitude) .Build(); mapView.Map.SetMyLocationData(loc); LocationUpdated?.Invoke(this, new LocationUpdatedEventArgs { //Coordinate = new Coordinate(loc.Latitude, loc.Longitude), Direction = location.Direction, Accuracy = location.HasRadius ? location.Radius : double.NaN, Altitude = location.HasAltitude ? location.Altitude : double.NaN, Satellites = location.SatelliteNumber, Type = location.LocTypeDescription }); return; } Failed?.Invoke(this, new LocationFailedEventArgs(location.LocType.ToString())); }
private async Task ReadAsync() { await Task.Run(() => { using (var fileStream = new FileStream(_currentJournalFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (StreamReader file = new StreamReader(fileStream)) using (JsonTextReader reader = new JsonTextReader(file)) { reader.SupportMultipleContent = true; var jsonSerializer = new JsonSerializer(); DateTime newestEventTime = _latestEventTime; dynamic logEvent = null; while (reader.Read()) { logEvent = jsonSerializer.Deserialize(reader); if (logEvent != null && (_latestEventTime == null || logEvent.timestamp > _latestEventTime)) { HandleLogEvent(logEvent); } } if (logEvent != null) { _latestEventTime = logEvent.timestamp; } } // Fire events for new information if (_isPlayerInfoChanged) { PlayerInfoUpdated?.Invoke(this, Log); _isPlayerInfoChanged = false; } if (_isLocationChanged) { LocationUpdated?.Invoke(this, Log); _isLocationChanged = false; } }); }
public void Initialize(KinectStatusUpdated kinectStatusUpdated, ProcessStatusUpdated processStatusUpdated, LocationUpdated locationUpdated, BitmapInit bitmapInit) { this.kinectSensor = KinectSensor.GetDefault(); this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.BodyIndex); this.multiFrameSourceReader.MultiSourceFrameArrived += this.Reader_MultiSourceFrameArrived; this.coordinateMapper = this.kinectSensor.CoordinateMapper; FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription; depthWidth = depthFrameDescription.Width; depthHeight = depthFrameDescription.Height; FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription; colorWidth = colorFrameDescription.Width; colorHeight = colorFrameDescription.Height; this.colorMappedToDepthPoints = new DepthSpacePoint[colorWidth * colorHeight]; this.depthMappedToColorPoints = new ColorSpacePoint[depthWidth * depthHeight]; this.bitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null); // Calculate the WriteableBitmap back buffer size this.bitmapBackBufferSize = (uint)((this.bitmap.BackBufferStride * (this.bitmap.PixelHeight - 1)) + (this.bitmap.PixelWidth * this.bytesPerPixel)); bitmapInit(this.bitmap); this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; this.kinectSensor.Open(); this.kinectStatusUpdated = kinectStatusUpdated; this.processStatusUpdated = processStatusUpdated; this.locationUpdated = locationUpdated; kinectStatusUpdated(this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText); this.timestamp = DateTime.Now; }
public override void ProcessIncoming(NMEASentence sentence) { if (sentence is NMEAStandartSentence) { NMEAStandartSentence nSentence = (sentence as NMEAStandartSentence); if (detected) { ResetTimer(); } if (nSentence.SentenceID == SentenceIdentifiers.HDT) { if (!detected) { detected = true; } double hdn = O2D(nSentence.parameters[0]); if (!double.IsNaN(hdn)) { Heading = hdn; HeadingUpdated.Rise(this, new EventArgs()); } } else if (nSentence.SentenceID == SentenceIdentifiers.RMC) { if (!detected) { detected = true; } DateTime tStamp = nSentence.parameters[0] == null ? DateTime.MinValue : (DateTime)nSentence.parameters[0]; var latitude = O2D(nSentence.parameters[2]); var longitude = O2D(nSentence.parameters[4]); var groundSpeed = O2D(nSentence.parameters[6]); var courseOverGround = O2D(nSentence.parameters[7]); DateTime dateTime = nSentence.parameters[8] == null ? DateTime.MinValue : (DateTime)nSentence.parameters[8]; bool isValid = (nSentence.parameters[1].ToString() != "Invalid") && (!double.IsNaN(latitude)) && latitude.IsValidLatDeg() && (!double.IsNaN(longitude)) && longitude.IsValidLonDeg() && (!double.IsNaN(groundSpeed)) && (nSentence.parameters[11].ToString() != "N"); if (isValid) { dateTime = dateTime.AddHours(tStamp.Hour); dateTime = dateTime.AddMinutes(tStamp.Minute); dateTime = dateTime.AddSeconds(tStamp.Second); dateTime = dateTime.AddMilliseconds(tStamp.Millisecond); groundSpeed = 3.6 * NMEAParser.Bend2MpS(groundSpeed); if (nSentence.parameters[3].ToString() == "S") { latitude = -latitude; } if (nSentence.parameters[5].ToString() == "W") { longitude = -longitude; } Latitude = latitude; Longitude = longitude; GroundSpeed = groundSpeed; CourseOverGround = courseOverGround; GNSSTime = dateTime; LocationUpdated.Rise(this, new EventArgs()); } } } }
public void ForceLocationUpdate() { LocationUpdated?.Invoke(CurrentLocation, LastLocation); LocationUpdatedRaw?.Invoke(CurrentLocationRaw, LastLocationRaw); }
/// <summary> /// 实现位置监听,实时缓存我的位置 /// </summary> /// <param name="location"></param> public void OnReceiveLocation(BDLocation location) { if (stopped) { return; } System.Diagnostics.Debug.WriteLine("LocType: " + location.LocType); switch (location.LocType) { default: break; case BDLocation.TypeServerError: { System.Diagnostics.Debug.Print("服务端网络定位失败,可以反馈IMEI号和大体定位时间到[email protected],会有人追查原因"); } break; case BDLocation.TypeNetWorkException: { System.Diagnostics.Debug.Print("网络不同导致定位失败,请检查网络是否通畅"); } break; case BDLocation.TypeCriteriaException: { System.Diagnostics.Debug.Print("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机"); } break; case BDLocation.TypeGpsLocation: case BDLocation.TypeNetWorkLocation: case BDLocation.TypeOffLineLocation: { StringBuilder sb = new StringBuilder(); sb.Append("time : "); sb.Append(location.Time); sb.Append("\nerror code : "); sb.Append(location.LocType); sb.Append("\nlatitude : "); sb.Append(location.Latitude); sb.Append("\nlontitude : "); sb.Append(location.Longitude); sb.Append("\nradius : "); sb.Append(location.Radius); System.Diagnostics.Debug.Print(sb.ToString()); BMap.MyLocationData loc = new BMap.MyLocationData.Builder() .Accuracy(location.Radius) .Direction(location.Direction) .Latitude(location.Latitude) .Longitude(location.Longitude) .Build(); mapView.Map.SetMyLocationData(loc); ///位置更新 LocationUpdated?.Invoke(this, new LocationUpdatedEventArgs { Coordinate = new Coordinate(loc.Latitude, loc.Longitude), Direction = location.Direction, Accuracy = location.HasRadius ? location.Radius : double.NaN, Altitude = location.HasAltitude ? location.Altitude : double.NaN, Satellites = location.SatelliteNumber, Type = location.LocTypeDescription, Province = location.Province, City = location.City, District = location.District, Street = location.Street, Address = location.AddrStr }); return; } } Failed?.Invoke(this, new LocationFailedEventArgs(location.LocType.ToString())); }
public void UpdateFilter() { System.Console.WriteLine($"Location Filter updated to display related locations"); LocationUpdated?.Invoke(this, EventArgs.Empty); }
private void HandleUpdateLocation(string username, double latitude, double longitude, double?altitude) { LocationUpdated?.Invoke(this, new LocationUpdatedEventArgs(username, latitude, longitude, altitude)); }
protected virtual void OnLocationUpdated() => LocationUpdated?.Invoke(this, EventArgs.Empty);
private void OnLocationUpdated(GeoLocationData data) { LocationUpdated?.Invoke(this, new GeoLocationEventArgs(data)); }
private void Handle(LocationUpdated ievent) { NotifyAffected("LocationUpdated", ievent.Location, ievent.Location.Lat, ievent.Location.Lng); }
public void RaiseEvent(UserLocation userLocation) { LocationUpdated?.Invoke(this, userLocation); }
protected void EmitLocationUpdated() { LocationUpdated?.Invoke(CurrentLocation, LastLocation); }