Beispiel #1
0
        private GpxInformation GetGPXData(string fileName)
        {
            var gpxFileInformation = new GpxFileReader().LoadFile(fileName);

            gpxFileInformation.Tracks.ForEach(t => t.IsConvertedToRoute = true);
            var factory = new GeometryFactory(gpxFileInformation);

            factory.CreateGeometries();
            return(gpxFileInformation);
        }
Beispiel #2
0
        // bug #34
        public void LoadFile_Check_If_All_Have_Length()
        {
            var gpxInfo = LoadGPXData("Sample.gpx");

            gpxInfo.Tracks.ForEach(x => x.IsConvertedToRoute = true);
            _geometryFactory.CreateGeometries();
            foreach (var route in gpxInfo.Routes)
            {
                var layer = new BikeTouringGISLayer("testroute", route);
                layer.Extent.Should().NotBeNull($"route, {route.Name}");
            }
        }
Beispiel #3
0
        private BikeTouringGISLayer CreateLayer(string fileName)
        {
            var path    = Path.Combine(UnitTestDirectory, fileName);
            var gpxInfo = new GpxFileReader().LoadFile(path);

            gpxInfo.Tracks.ForEach(x => x.IsConvertedToRoute = true);
            var factory = new GeometryFactory(gpxInfo);

            factory.CreateGeometries();
            var layer = new BikeTouringGISLayer("testroute", gpxInfo.Routes.First());

            layer.SetExtentToFitWithWaypoints(gpxInfo.WayPointsExtent);
            return(layer);
        }
Beispiel #4
0
        internal async void OpenGpxFile(BikeTouringGISMapViewModel mapViewModel, string path)
        {
            if (_loadedFiles.Exists(x => x.Equals(path)))
            {
                return;
            }
            var gpxFileInformation = new GpxFileReader().LoadFile(path);

            foreach (var track in gpxFileInformation.Tracks)
            {
                bool convertTrack             = ConvertTracksToRoutesAutomatically;
                var  convertTrackDialogResult = convertTrack ? MessageDialogResult.Affirmative : MessageDialogResult.FirstAuxiliary;
                if (!convertTrack)
                {
                    StringBuilder textBuilder = new StringBuilder();
                    textBuilder.AppendLine($"Track {track.Name} is defined as track and not as route");
                    textBuilder.AppendLine();
                    textBuilder.AppendLine("routes are used by navigation-devices");
                    textBuilder.AppendLine("tracks are to register where you have been");
                    textBuilder.AppendLine();
                    textBuilder.AppendLine("Do you want to convert it to a route?");
                    convertTrackDialogResult = await ConvertTrackToRoute(textBuilder.ToString());
                }
                switch (convertTrackDialogResult)
                {
                case MessageDialogResult.Affirmative:
                    track.IsConvertedToRoute = true;
                    break;

                case MessageDialogResult.Negative:
                    break;

                case MessageDialogResult.FirstAuxiliary:
                    return;
                }
            }
            _loadedFiles.Add(path);
            var geometryFactory = new GeometryFactory(gpxFileInformation);

            geometryFactory.CreateGeometries();
            var layerFactory = new LayerFactory(gpxFileInformation.WayPointsExtent);
            var routes       = layerFactory.CreateRoutes(path, gpxFileInformation.Routes);

            mapViewModel.AddRoutes(routes);
            var tracks = layerFactory.CreateTracks(path, gpxFileInformation.Tracks);

            mapViewModel.AddTracks(tracks);
            mapViewModel.AddPoIs(gpxFileInformation.WayPoints);
        }