Ejemplo n.º 1
0
        public void ConvertGpxToDataContainer_NonSiteFileWithTwoSegmenets_ShouldManipulateRouteData()
        {
            var gpxToConvert = new gpxType
            {
                trk = new[]
                {
                    new trkType
                    {
                        trkseg = new[]
                        {
                            new trksegType
                            {
                                trkpt = new[]
                                {
                                    new wptType {
                                        lat = 1, lon = 2
                                    },
                                    new wptType {
                                        lat = 3, lon = 4
                                    }
                                }
                            },
                            new trksegType
                            {
                                trkpt = new[]
                                {
                                    new wptType {
                                        lat = 5, lon = 6
                                    },
                                    new wptType {
                                        lat = 7, lon = 8
                                    }
                                }
                            }
                        }
                    }
                }
            };
            var newRouteData = new RouteData
            {
                segments = new List <RouteSegmentData>
                {
                    new RouteSegmentData(),
                    new RouteSegmentData(),
                    new RouteSegmentData(),
                    new RouteSegmentData()
                }
            };

            _routeDataSplitterService.Split(Arg.Any <RouteData>(), Arg.Any <string>()).Returns(newRouteData);

            var dataContainer = _converterService.ToDataContainer(gpxToConvert.ToBytes(), FlowFormats.GPX).Result;

            Assert.AreEqual(1, dataContainer.routes.Count);
            Assert.AreEqual(newRouteData.segments.Count, dataContainer.routes.First().segments.Count);
        }
Ejemplo n.º 2
0
        public void ConvertGpxToDataContainer_NonSiteFileWithTwoSegmenetsNoName_ShouldManipulateRouteData()
        {
            var gpx = new GpxFile();

            gpx.Tracks.Add(new GpxTrack().WithSegments(
                               new[]
            {
                new GpxTrackSegment(new ImmutableGpxWaypointTable(new[]
                {
                    new GpxWaypoint(new GpxLongitude(1), new GpxLatitude(2), null),
                    new GpxWaypoint(new GpxLongitude(3), new GpxLatitude(4), null)
                }), null),
                new GpxTrackSegment(new ImmutableGpxWaypointTable(new[]
                {
                    new GpxWaypoint(new GpxLongitude(5), new GpxLatitude(6), null),
                    new GpxWaypoint(new GpxLongitude(7), new GpxLatitude(8), null)
                }), null)
            }.ToImmutableArray()));
            var newRouteData = new RouteData
            {
                Segments = new List <RouteSegmentData>
                {
                    new RouteSegmentData(),
                    new RouteSegmentData(),
                    new RouteSegmentData(),
                    new RouteSegmentData()
                }
            };

            _routeDataSplitterService.Split(Arg.Any <RouteData>()).Returns(newRouteData);

            var dataContainer = _converterService.ToDataContainer(gpx.ToBytes(), FlowFormats.GPX).Result;

            Assert.AreEqual(1, dataContainer.Routes.Count);
            Assert.AreEqual(FlowFormats.GPX, dataContainer.Routes.First().Name);
            Assert.AreEqual(newRouteData.Segments.Count, dataContainer.Routes.First().Segments.Count);
        }
Ejemplo n.º 3
0
        ///<inheritdoc />
        public async Task <DataContainer> ToDataContainer(byte[] content, string fileName)
        {
            var gpx       = (await Convert(content, fileName, GPX)).ToGpx();
            var container = _gpxDataContainerConverter.ToDataContainer(gpx);

            if (gpx.creator == ISRAEL_HIKING_MAP)
            {
                return(container);
            }
            foreach (var route in container.routes.Where(r => r.segments.SelectMany(s => s.latlngs).Any()))
            {
                route.segments = _routeDataSplitterService.Split(route, RoutingType.HIKE).segments;
            }
            return(container);
        }
Ejemplo n.º 4
0
        ///<inheritdoc />
        public async Task <DataContainer> ToDataContainer(byte[] content, string fileName)
        {
            var gpx       = (await Convert(content, fileName, GPX)).ToGpx();
            var container = _gpxDataContainerConverter.ToDataContainer(gpx);

            if (gpx.creator == ISRAEL_HIKING_MAP)
            {
                return(container);
            }
            foreach (var route in container.Routes.Where(r => r.Segments.SelectMany(s => s.Latlngs).Any()))
            {
                route.Segments = _routeDataSplitterService.Split(route).Segments;
            }
            foreach (var route in container.Routes.Where(r => string.IsNullOrWhiteSpace(r.Name)))
            {
                route.Name = fileName;
            }
            return(container);
        }