Exemplo n.º 1
0
        public void ResetCamera(IEnumerable <ILoadedGpxFileTourInfo>?toursToFocus)
        {
            var boxBuilder = new NavigationBoundingBoxBuilder();

            if (toursToFocus != null)
            {
                foreach (var actTour in toursToFocus)
                {
                    foreach (var actTourSegment in actTour.Segments)
                    {
                        var actGeometry = actTourSegment.Points.GpxWaypointsToMapsuiGeometry(actTour, actTourSegment);
                        if (actGeometry == null)
                        {
                            continue;
                        }

                        boxBuilder.AddGeometry(actGeometry);
                    }
                }
            }

            if (boxBuilder.CanBuildBoundingBox)
            {
                this.RequestNavigateToBoundingBox?.Invoke(
                    this,
                    new RequestNavigateToBoundingBoxEventArgs(boxBuilder.TryBuild() !));
            }
            else
            {
                this.RequestNavigateToBoundingBox?.Invoke(
                    this,
                    new RequestNavigateToBoundingBoxEventArgs(GetDefaultBoundingBox()));
            }
        }
Exemplo n.º 2
0
        private void UpdateLayer_SelectedGpxFiles()
        {
            var boxBuilder = new NavigationBoundingBoxBuilder();

            var newFeatures = new List <IFeature>();

            foreach (var actTour in _selectedTours)
            {
                foreach (var actTourSegment in actTour.Segments)
                {
                    var actGeometry = actTourSegment.Points.GpxWaypointsToMapsuiGeometry(actTour, actTourSegment);
                    if (actGeometry == null)
                    {
                        continue;
                    }

                    boxBuilder.AddGeometry(actGeometry);

                    newFeatures.Add(new Feature()
                    {
                        Geometry = actGeometry,
                        Styles   = { _lineStyleSelected }
                    });
                }
            }
            _layerSelectedGpxFilesProvider.ReplaceFeatures(newFeatures);
            _layerSelectedGpxFiles.DataHasChanged();

            var currentViewPort  = this.TryGetCurrentViewport();
            var selectedRouteBox = boxBuilder.TryBuild();

            if ((selectedRouteBox != null) &&
                (currentViewPort != null) &&
                (!currentViewPort.Contains(selectedRouteBox)))
            {
                this.ResetCamera(_selectedTours);
            }
        }