Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void UpdateHeading(double?heading)
 {
     if (heading.HasValue)
     {
         _editTextHeading.Text = $"{GpsUtils.Normalize360(heading.Value):F1}".Replace(",", ".");
     }
     else
     {
         _editTextHeading.Text = "";
     }
 }