public void ToGpx_WithAllTypesOffeatures_ShouldBeConverted() { var converter = new GpxGeoJsonConverter(); var geojson = new FeatureCollection(); var table = new AttributesTable { { FeatureAttributes.NAME, FeatureAttributes.NAME } }; geojson.Features.Add(new Feature(new Point(new Coordinate(1, 1)), table)); geojson.Features.Add(new Feature(new MultiPoint(new[] { new Point(new Coordinate(2, 2)) as IPoint }), table)); geojson.Features.Add(new Feature(new Polygon(new LinearRing(new [] { new Coordinate(3, 3), new Coordinate(4, 4), new Coordinate(5, 5), new Coordinate(3, 3) })), table)); geojson.Features.Add(new Feature(new LineString(new[] { new Coordinate(6, 6), new Coordinate(7, 7) }), table)); geojson.Features.Add(new Feature(new MultiPolygon(new IPolygon[] { new Polygon(new LinearRing(new [] { new Coordinate(8, 8), new Coordinate(9, 9), new Coordinate(10, 10), new Coordinate(8, 8) })) }), table)); geojson.Features.Add(new Feature(new MultiLineString(new ILineString[] { new LineString(new[] { new Coordinate(11, 11), new Coordinate(12, 12) }), new LineString(new[] { new Coordinate(12, 12), new Coordinate(13, 13) }), new LineString(new[] { new Coordinate(14, 14), new Coordinate(15, 15) }), }), table)); var gpx = converter.ToGpx(geojson); Assert.AreEqual(2, gpx.Waypoints.Count); Assert.AreEqual(3, gpx.Routes.Count); Assert.AreEqual(2, gpx.Tracks.Count); Assert.AreNotEqual(gpx.Tracks[0].Name, gpx.Tracks[1].Name); Assert.AreEqual(FeatureAttributes.NAME + " 1", gpx.Tracks[1].Name); }
public void TestInitialize() { _randomBytes = new byte[] { 0, 1, 1, 0 }; _simpleGpx = new GpxFile(); _simpleGpx.Waypoints.Add(new GpxWaypoint(new GpxLongitude(0), new GpxLatitude(0), null)); _gpsBabelGateway = Substitute.For <IGpsBabelGateway>(); _imgurGateway = Substitute.For <IImgurGateway>(); _routeDataSplitterService = Substitute.For <IRouteDataSplitterService>(); var gpxGeoJsonConverter = new GpxGeoJsonConverter(); var converterFlowItems = new List <IConverterFlowItem> { new GeoJsonGpxConverterFlow(gpxGeoJsonConverter), new GpxGeoJsonConverterFlow(gpxGeoJsonConverter), new GpxToSingleTrackGpxConverterFlow(), new GpxToRouteGpxConverterFlow(), new KmzToKmlConverterFlow(), new GpxGzToGpxConverterFlow(), new GpxVersion1ToGpxVersion11ConverterFlow(_gpsBabelGateway), new GpxBz2ToGpxConverterFlow(), new JpgToGpxConverterFlow(_gpsBabelGateway, _imgurGateway) }; _converterService = new DataContainerConverterService(_gpsBabelGateway, new GpxDataContainerConverter(), _routeDataSplitterService, converterFlowItems); }
public void ToGpx_WithAllTypesOffeatures_ShouldBeConverted() { var converter = new GpxGeoJsonConverter(); var geojson = new FeatureCollection(); var table = new AttributesTable(); geojson.Features.Add(new Feature(new Point(new Coordinate(1, 1)), table)); geojson.Features.Add(new Feature(new MultiPoint(new[] { new Point(new Coordinate(2, 2)) as IPoint }), table)); geojson.Features.Add(new Feature(new Polygon(new LinearRing(new [] { new Coordinate(3, 3), new Coordinate(4, 4), new Coordinate(5, 5), new Coordinate(3, 3) })), table)); geojson.Features.Add(new Feature(new LineString(new[] { new Coordinate(6, 6), new Coordinate(7, 7) }), table)); geojson.Features.Add(new Feature(new MultiPolygon(new IPolygon[] { new Polygon(new LinearRing(new [] { new Coordinate(8, 8), new Coordinate(9, 9), new Coordinate(10, 10), new Coordinate(8, 8) })) }), table)); geojson.Features.Add(new Feature(new MultiLineString(new ILineString[] { new LineString(new[] { new Coordinate(11, 11), new Coordinate(12, 12) }), new LineString(new[] { new Coordinate(12, 12), new Coordinate(13, 13) }), new LineString(new[] { new Coordinate(14, 14), new Coordinate(15, 15) }), }), table)); var gpx = converter.ToGpx(geojson); Assert.AreEqual(2, gpx.wpt.Length); Assert.AreEqual(3, gpx.rte.Length); Assert.AreEqual(2, gpx.trk.Length); }