public void GenerateElevationProfile3(GpsLocation myLocation, double visibility, ElevationProfileData elevationData, Action <int> onProgressChange) { _elevationProfileData = new ElevationProfileData(myLocation, visibility); int progress = 0; foreach (var group in elevationData.GetData()) { progress++; onProgressChange(progress); var points = group.GetPoints() .Where(i => i.Distance > MIN_DISTANCE && i.Distance < visibility * 1000) .OrderBy(i => i.Distance); //Select visible points List <GpsLocation> tmpVisiblePoints = new List <GpsLocation>(); double maxViewAngle = -90; foreach (var point in points) { if (point.VerticalViewAngle > maxViewAngle) { tmpVisiblePoints.Add(point); maxViewAngle = point.VerticalViewAngle.Value; } } //Change order (now from the furthest to the nearest) tmpVisiblePoints.Reverse(); //... and ignore points on descending slope GpsLocation lastPoint = null; GpsLocation lastAddedPoint = null; var ed = new ElevationData(group.Angle); foreach (var point in tmpVisiblePoints) { if (lastPoint == null) { ed.Add(point); lastAddedPoint = point; lastPoint = point; continue; } //TODO: comment-out the folowing if for full rendering var distanceDiff = lastPoint.Distance.Value - point.Distance.Value; if (distanceDiff < lastPoint.Distance / 100 + 50) { lastPoint = point; continue; } ed.Add(point); lastAddedPoint = point; lastPoint = point; } _elevationProfileData.Add(ed); } }
public static Visibility IsPoiVisible(PoiViewItem item, ElevationProfileData elevationProfileData) { if (elevationProfileData == null) { return(Visibility.Visible); } var leftPoints = elevationProfileData.GetData((int)item.GpsLocation.Bearing); var rightPoints = elevationProfileData.GetData((int)GpsUtils.Normalize360(item.GpsLocation.Bearing.Value + 1)); if (leftPoints == null || rightPoints == null) { return(Visibility.Visible); } var maxLeft = new GpsLocation() { VerticalViewAngle = -100, Distance = 100 }; var leftPoints2 = leftPoints.GetPoints().Where(p => p.Distance < item.GpsLocation.Distance); if (leftPoints2.Any()) { maxLeft = leftPoints2.Aggregate((max, item2) => item2?.VerticalViewAngle > max?.VerticalViewAngle ? item2 : max); } var maxRight = new GpsLocation() { VerticalViewAngle = -100, Distance = 100 }; var rightPoints2 = rightPoints.GetPoints().Where(p => p.Distance < item.GpsLocation.Distance); if (rightPoints2.Any()) { maxRight = rightPoints2.Aggregate((max, item2) => item2?.VerticalViewAngle > max?.VerticalViewAngle ? item2 : max); } var maxViewAngle = maxRight.VerticalViewAngle > maxLeft.VerticalViewAngle ? maxRight : maxLeft; var itemViewAngle = item.VerticalViewAngle; var viewAngleDiff = item.VerticalViewAngle - maxViewAngle.VerticalViewAngle; var viewAngleDistance = item.GpsLocation.Distance - maxViewAngle.Distance; var viewAngleVisibilityLimit = -(itemViewAngle * 0.01 + 0.0); var viewAnglePartVisibilityLimit = -(itemViewAngle * 0.2 + 1.0); var distancePartVisibilityLimit = 2000;//m if (viewAngleDiff > viewAngleVisibilityLimit) { return(Visibility.Visible); } if (viewAngleDiff > viewAnglePartVisibilityLimit && viewAngleDistance < distancePartVisibilityLimit) { return(Visibility.PartialyVisible); } return(Visibility.Invisible); }
public void SetElevationProfile(ElevationProfileData elevationProfile) { _elevationProfile = elevationProfile; GenerateElevationProfileLines(); _poisToBeDisplayed = FilterPoisDoBeDisplayed(_poisInVisibilityRange); Invalidate(); }
private void RefreshElevationProfile(ElevationProfileData elevationProfileData) { if (elevationProfileData != null) { ElevationProfileChanged?.Invoke(this, new ElevationProfileChangedEventArgs() { ElevationProfileData = elevationProfileData }); } }
void InitializeAppContext(PhotoData photodata) { var loc = new GpsLocation(photodata.Longitude, photodata.Latitude, photodata.Altitude); /* Fetching altitude from elevation map if available (this is not needed probably) * if (AppContextLiveData.Instance.Settings.AltitudeFromElevationMap) * { * var elevationTile = new ElevationTile(loc); * if (elevationTile.Exists()) * { * if (elevationTile.LoadFromZip()) * { * loc.Altitude = elevationTile.GetElevation(loc); * } * } * }*/ _context = new AppContextStaticData(loc, new PlaceInfo(), photodata.Heading); _context.LeftTiltCorrector = photodata.LeftTiltCorrector ?? 0; _context.RightTiltCorrector = photodata.RightTiltCorrector ?? 0; //### This can be removed later if (photodata.PictureWidth == 0) { photodata.PictureWidth = AppContextLiveData.Instance.Settings.CameraPictureSize.Width; } if (photodata.PictureHeight == 0) { photodata.PictureHeight = AppContextLiveData.Instance.Settings.CameraPictureSize.Height; } //Elavation data will be loaded when user will enable showing of elevation data if (photodata.JsonElevationProfileData == null) { photodata.ShowElevationProfile = false; } Context.Settings.LoadData(this); Context.Settings.IsViewAngleCorrection = false; Context.Settings.Categories = JsonConvert.DeserializeObject <List <PoiCategory> >(photodata.JsonCategories); Context.Settings.SetCameraParameters((float)photodata.ViewAngleHorizontal, (float)photodata.ViewAngleVertical, photodata.PictureWidth, photodata.PictureHeight); Context.Settings.MaxDistance = Convert.ToInt32(photodata.MaxDistance); Context.Settings.MinAltitute = Convert.ToInt32(photodata.MinAltitude); Context.ShowFavoritesOnly = photodata.FavouriteFilter; Context.Settings.ShowElevationProfile = photodata.ShowElevationProfile; Context.ElevationProfileData = ElevationProfileData.Deserialize(photodata.JsonElevationProfileData); }
private bool IsDirty() { var elevationProfileData = ElevationProfileData.Deserialize(_photodata?.JsonElevationProfileData); return (_photodata.ShowElevationProfile != Context.Settings.ShowElevationProfile || _photodata.JsonCategories != JsonConvert.SerializeObject(Context.Settings.Categories) || _photodata.FavouriteFilter != Context.ShowFavoritesOnly || !_photodata.MaxDistance.IsEqual(Context.Settings.MaxDistance, 0.1) || !_photodata.MinAltitude.IsEqual(Context.Settings.MinAltitute, 0.1) || !_photodata.ViewAngleHorizontal.IsEqual(Context.ViewAngleHorizontal, 0.1) || !_photodata.ViewAngleVertical.IsEqual(Context.ViewAngleVertical, 0.1) || !(_photodata.LeftTiltCorrector?.IsEqual(Context.LeftTiltCorrector, 0.01) ?? true) || !(_photodata.RightTiltCorrector?.IsEqual(Context.RightTiltCorrector, 0.01) ?? true) || !(_photodata.Heading ?? 0).IsEqual((Context.HeadingX ?? 0) + Context.HeadingCorrector, 0.1) || (_photodata.ShowElevationProfile && !elevationProfileData.MaxDistance.IsEqual(Context.ElevationProfileData.MaxDistance, 0.1))); }
public void GenerateElevationProfileLines(ElevationProfileData epd, double displayWidth, double displayHeight) { /*foreach(var ed in epd.GetData()) * { * var edMaxDist = ed.GetPoints().Max(p => p.Distance.Value); * if (edMaxDist > maxDist) * { * maxDist = edMaxDist; * } * }*/ List <ProfileLine> listOfLines = new List <ProfileLine>(); for (ushort i = 0; i < 360; i++) { var thisAngle = epd.GetData(i); var prevAngle = epd.GetData(i - 1); if (thisAngle != null && prevAngle != null) { foreach (var point in thisAngle.GetPoints()) { var otherPoint = prevAngle.GetPoints() .Where(x => Math.Abs(point.Distance.Value - x.Distance.Value) <= point.Distance.Value / 12) .OrderBy(x => Math.Abs(point.Distance.Value - x.Distance.Value)) .FirstOrDefault(); if (otherPoint != null) { var y1 = point.VerticalViewAngle.Value; var x1 = (float)point.Bearing.Value; var y2 = otherPoint.VerticalViewAngle.Value; var x2 = (float)otherPoint.Bearing.Value; listOfLines.Add(new ProfileLine { Bearing1 = x1, Bearing2 = x2, VerticalViewAngle1 = (float)y1, VerticalViewAngle2 = (float)y2, distance = point.Distance.Value }); } } } } _context.ListOfProfileLines = listOfLines; }
public void Generate(GpsLocation _myLocation, double maxDistanceKm, ElevationTileCollection etc, Action <int> onProgressChange) { _elevationProfileData = new ElevationProfileData(_myLocation, maxDistanceKm); /*for (ushort angle = 0; angle < 360; angle++) * { * onProgressChange(angle); * * var ed = new ElevationData(angle); * * for (int d = 500; d < 12000; d += 25) * { * var x = GpsUtils.QuickGetGeoLocation(_myLocation, d, angle); * if (etc.TryGetElevation(x, out var elevation, 1)) * { * x.Altitude = elevation; * x.Distance = d; * x.Bearing = angle; * x.GetVerticalViewAngle(_myLocation); * * ed.Add(x); * } * } * * _elevationProfileData.Add(ed); * }*/ for (ushort a = 0; a < 360; a++) { onProgressChange(a); var ed = GetElevationDataForAngle(a, _myLocation, maxDistanceKm * 1000, etc); _elevationProfileData.Add(ed); } }
private void LoadImageAndProfile() { LoadImage(_photodata.PhotoFileName); try { if (Context.Settings.ShowElevationProfile) { if (_photodata.JsonElevationProfileData != null) { Context.ElevationProfileData = ElevationProfileData.Deserialize(_photodata.JsonElevationProfileData); if (Context.ElevationProfileData != null) { ElevationProfileProvider.Instance().CheckAndReloadElevationProfile(this, MaxDistance, Context); } } } } catch (Exception ex) { PopupHelper.ErrorDialog(this, ex.Message); } }
public void CalculateProfile() { GpsUtils.BoundingRect(_myLocation, _visibility * 1000, out var min, out var max); _data = new List <GpsLocation>(); string inputFileName = @"c:\Temp\ElevationMap\ALPSMLC30_N049E018_DSM.tif"; GeoTiffReaderList.ReadTiff(inputFileName, min, max, _myLocation, 3, _data); //Calculate old profile /*ElevationProfile ep = new ElevationProfile(); * ep.GenerateElevationProfile(_myLocation, _visibility, _data, progress => { }); * elevationProfileOld = ep.GetProfile();*/ //Calucate new profile var etc = new ElevationTileCollection(_myLocation, (int)_visibility); var d = etc.GetSizeToDownload(); etc.Download(progress => { }); etc.Read(progress => { }); profileGenerator.Generate(_myLocation, 12, etc, progress => { }); /*ProfileGeneratorOld ep2 = new ProfileGeneratorOld(); * //ep2.GenerateElevationProfile3(_myLocation, _visibility, _data, progress => { }); * ep2.GenerateElevationProfile3(_myLocation, _visibility, elevationPainter3.list, progress => { }); * elevationProfileNew = ep2.GetProfile();*/ ElevationProfile ep3 = new ElevationProfile(); ep3.GenerateElevationProfile3(_myLocation, _visibility, profileGenerator.GetProfile(), progress => { }); elevationProfileNew = ep3.GetProfile(); Invalidate(); }