Пример #1
0
        public static LocationRectangle SetCenter(LocationRectangle rect, GeoCoordinate center)
        {
            double north, west, south, east;

            if (rect.North - center.Latitude < center.Latitude - rect.South)
            {
                north = center.Latitude + center.Latitude - rect.South;
                south = rect.South;
            }
            else
            {
                north = rect.North;
                south = center.Latitude - (rect.North - center.Latitude);
            }

            if (rect.East - center.Longitude < center.Longitude - rect.West)
            {
                west = rect.West;
                east = center.Longitude + (center.Longitude - rect.West);
            }
            else
            {
                west = center.Longitude - (rect.East - center.Longitude);
                east = rect.East;
            }

            return(new LocationRectangle(north, west, south, east));
        }
Пример #2
0
        private async void SetBoundaries(IMapControl map, LocationRectangle boundaries, bool noStopInParameter)
        {
            await Task.Delay(250);

            await initializeMapLabels(map);

            await map.TrySetViewBoundsAsync(boundaries, false);

            //while (page.ZoomLevel < 15)
            //{
            //    page.SetView(boundaries, MapAnimationKind.None);
            //    await Task.Delay(100);
            //}
            //while (page.IsMapEmpty)
            //{
            //    initializeMapLabels(page);
            //    await Task.Delay(100);
            //}

            map.CenterChanged += async(sender, args) =>
            {
                await mapFillingLock.WaitAsync();

                if (map.ZoomLevel >= App.Config.LowStopsMapLevel)
                {
                    await tryCreateStopLabelsAt(map, map.Center);
                }
                else if (map.ZoomLevel >= App.Config.HighStopsMapLevel)
                {
                    await tryCreateHighStopLabelsAt(map, map.Center);

                    clearMap(map, 2.1);
                }
                else
                {
                    clearMap(map);
                }
                mapFillingLock.Release();
            };

            if (isNear && noStopInParameter && mainPoints.Length == 0)
            {
                var nearestResult = await StopTransfers.GetNearestStop(CurrentLocation.Last);

                if (nearestResult != null)
                {
                    this.location   = CurrentLocation.Last;
                    this.mainPoints = nearestResult.Stop.Group.Stops.Select(s => s.Coordinate).ToArray();
                    var boundAddition = new GeoCoordinate[] { CurrentLocation.Last ?? App.Config.CenterLocation };

                    boundaries = calculateBoundaries(mainPoints.Concat(boundAddition));

                    await map.TrySetViewBoundsAsync(boundaries, false);
                    await initializeMapLabels(map);
                }
            }
        }
Пример #3
0
        public static LocationRectangle WidenBoundaries(LocationRectangle rect)
        {
            var               center    = rect.Center;
            double            latUnit   = 150.0 / App.Config.LatitudeDegreeDistance;
            double            lonUnit   = 150.0 / App.Config.LongitudeDegreeDistance;
            LocationRectangle widedRect = new LocationRectangle(
                north: Math.Max(rect.North, rect.Center.Latitude + latUnit),
                south: Math.Min(rect.South, rect.Center.Latitude - latUnit),
                east: Math.Max(rect.East, rect.Center.Longitude + lonUnit),
                west: Math.Min(rect.West, rect.Center.Longitude - lonUnit)
                );

            return(widedRect);
        }