コード例 #1
0
        public void FromGeometryMultiLineStringReturnsExpectedResult()
        {
            _fixture.CustomizeGeometryMultiLineString();
            var input  = _fixture.Create <NetTopologySuite.Geometries.MultiLineString>();
            var result = GeometryTranslator.FromGeometryMultiLineString(input);
            var lines  = new List <NetTopologySuite.Geometries.LineString>(input.Geometries.Cast <NetTopologySuite.Geometries.LineString>());

            Assert.Equal(new BoundingBox2D(
                             lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => new Point(line.GetPointN(index).X, line.GetPointN(index).Y))).Min(point => point.X),
                             lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => new Point(line.GetPointN(index).X, line.GetPointN(index).Y))).Min(point => point.Y),
                             lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => new Point(line.GetPointN(index).X, line.GetPointN(index).Y))).Max(point => point.X),
                             lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => new Point(line.GetPointN(index).X, line.GetPointN(index).Y))).Max(point => point.Y)
                             ), result.BoundingBox);
            Assert.Equal(lines.Count, result.NumberOfParts);
            Assert.Equal(lines.Sum(line => line.NumPoints), result.NumberOfPoints);
            var offset = 0;

            Assert.Equal(
                lines.Select(line =>
            {
                var part = offset;
                offset  += line.NumPoints;
                return(part);
            }).ToArray(),
                result.Parts);
            Assert.Equal(
                lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => new Point(line.GetPointN(index).X, line.GetPointN(index).Y))).ToArray(),
                result.Points);
            Assert.Equal(new MeasureRange(
                             lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => line.CoordinateSequence.GetOrdinate(index, NetTopologySuite.Geometries.Ordinate.M))).Min(),
                             lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => line.CoordinateSequence.GetOrdinate(index, NetTopologySuite.Geometries.Ordinate.M))).Max()
                             ), result.MeasureRange);
            Assert.Equal(
                lines.SelectMany(line => Enumerable.Range(0, line.NumPoints).Select(index => line.CoordinateSequence.GetOrdinate(index, NetTopologySuite.Geometries.Ordinate.M))),
                result.Measures);
        }
コード例 #2
0
 public void FromGeometryMultiLineStringCanNotBeNull()
 {
     Assert.Throws <ArgumentNullException>(
         () => GeometryTranslator.FromGeometryMultiLineString(null));
 }