/// <summary> /// 位置情報が変化したとき /// </summary> public void OnLocationChanged(Location location) { //UNIX時刻 DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); LastLocation = new LocationData() { Provider = location.Provider, Accuracy = location.Accuracy, Altitude = location.Altitude, Latitude = location.Latitude, Longitude = location.Longitude, Speed = location.Speed, Time = UnixEpoch.AddMilliseconds(location.Time).ToLocalTime() }; }
public PicData(byte[] data, DateTime timeStamp, LocationData location) { this.Data = data; this.TimeStamp = timeStamp; this.Location = location; }
void CameraManager_PictureTaken(object sender, DataEventArgs e) { try { //2つの位置情報を取得する LocationData gps = locTrackerGPS.LastLocation; LocationData net = locTrackerNetwork.LastLocation; //どちらの位置情報を使うか決定する LocationData _lastLocation = gps;//基本はGPS使用 if (gps.Time.AddMinutes(1) < net.Time) { _lastLocation = net;//NetがGPSよりも1分以上新しい→Net } if (gps.Accuracy - net.Accuracy > 30) { _lastLocation = net;//Netの方がGPSよりも30m以上精度が高い→Net } this.lastLocation = _lastLocation; e.Data.Location = _lastLocation; /*** 送信ジョブを作成 ***/ const string FileNameFormat = "pic_{0:yyyyMMdd-HHmmss}.jpg"; DateTime expire = DateTime.Now.AddSeconds(settings.MinInterval * 3); //3倍の時間が掛かったら期限切れにする //ローカル sendJobManager.JobQueue.Enqueue(new LocalSendJob(e.Data, expire) { OutputDir = settings.OutputDir, FileNameFormat = FileNameFormat }); totalCountLocal++; //HTTP if (settings.UseHttp) { sendJobManager.JobQueue.Enqueue(new HttpSendJob(e.Data, expire) { Url = settings.HttpUrl, Credentials = new System.Net.NetworkCredential(settings.HttpUser, settings.HttpPass), FileNameFormat = FileNameFormat, Timeout = 5 + (uint)settings.MinInterval * 2 }); totalCountHttp++; } //画面に位置情報を出す handler.Post(() => { try { RefreshUI(); } catch { } }); } catch (Exception ex) { showError(ex); } }