Example #1
0
        private StopGroupModel createStopHeader(StopGroup stop, IList <RouteModel> items, bool showTime, bool showDistance, GeoCoordinate location = null, bool showBtn = false, bool showSeparator = false)
        {
            var model = new StopGroupModel(items, addFooter)
            {
                Stop = stop,
                IsWheelchairVisible = stop.Stops.Any(s => s.WheelchairBoardingAvailable),
                TimeText            = StartTime.ToRelativeString(),
                IsTransferVisible   = showTime,
                IsDistanceVisible   = false,
                IsBtnVisible        = showBtn,
                IsSeparatorVisible  = showSeparator,
            };

            if (showDistance && items.Count > 0)
            {
                double dist = items.Select(i => i.Distance).Average();
                if (dist > MinShowDistance)
                {
                    double walkTime = items.Select(i => i.WalkTime.TotalMinutes).Average();
                    model.NearDistance      = StringFactory.LocalizeDistance(dist);
                    model.NearDirection     = StringFactory.CardinalToString(stop.InverseDirection(location.Latitude, location.Longitude));
                    model.NearWalkingtime   = (int)Math.Ceiling(walkTime);
                    model.IsDistanceVisible = true;
                }
            }
            return(model);
        }
Example #2
0
        //private async Task<DateTime> addWalkTime(DateTime time, GeoCoordinate location)
        //{
        //    if (currentStop.StraightLineDistanceTo(location.Latitude, location.Longitude) > StopPage.MinShowDistance)
        //        time += (await StopTransfers.WalkDistance(currentStop.Coordinate, location)).EstimatedDuration;
        //    return time;
        //}

        private void setDistanceText(string head, GeoCoordinate loc, double distance)
        {
            if (CurrentStop.StraightLineDistanceTo(loc.Latitude, loc.Longitude) > StopViewModel.MinShowDistance)
            {
                //int walkMinutes = (int)Math.Ceiling(distance.TotalMinutes);
                //DistanceText.Text = String.Format("{0}: {1} m ({2})",
                //    head,
                //    Math.Round(currentStop.Distance(loc.Latitude, loc.Longitude)),
                //    StringFactory.XMinutes(walkMinutes)
                //);
                this.DistanceText = StringFactory.LocalizeDistanceWithUnit(distance) + " " +
                                    StringFactory.CardinalToString(CurrentStop.InverseDirectionTo(loc.Latitude, loc.Longitude));
                this.ShowDistance = true;
            }
            else
            {
                this.ShowDistance = false;
            }
            this.NotifyDistanceChanged();
        }