/// <summary> /// /// </summary> /// <param name="points">ordered control points. If empty then this shape is empty.</param> /// <param name="buf">Buffer >= 0</param> /// <param name="expandBufForLongitudeSkew"> /// See <see cref="BufferedLine.ExpandBufForLongitudeSkew(IPoint, IPoint, double)"/> /// If true then the buffer for each segment is computed. /// </param> /// <param name="ctx"></param> public BufferedLineString(IList <IPoint> points, double buf, bool expandBufForLongitudeSkew, SpatialContext ctx) { this.buf = buf; if (!points.Any()) { this.segments = ctx.MakeCollection(new List <IShape>()); } else { List <IShape> segments = new List <IShape>(points.Count - 1); IPoint prevPoint = null; foreach (IPoint point in points) { if (prevPoint != null) { double segBuf = buf; if (expandBufForLongitudeSkew) { //TODO this is faulty in that it over-buffers. See Issue#60. segBuf = BufferedLine.ExpandBufForLongitudeSkew(prevPoint, point, buf); } segments.Add(new BufferedLine(prevPoint, point, segBuf, ctx)); } prevPoint = point; } if (!segments.Any()) {//TODO throw exception instead? segments.Add(new BufferedLine(prevPoint, prevPoint, buf, ctx)); } this.segments = ctx.MakeCollection(segments); } }
public virtual IShape GetBuffered(double distance, SpatialContext ctx) { IList <Shapes.IShape> bufColl = new List <Shapes.IShape>(Count); foreach (Shapes.IShape shape in m_shapes) { bufColl.Add(shape.GetBuffered(distance, ctx)); } return(ctx.MakeCollection(bufColl)); }
public virtual void TestParseMultiPoint() { IShape s1 = ctx.MakeCollection(new IShape[] { ctx.MakePoint(10, 40) }); AssertParses("MULTIPOINT (10 40)", s1); IShape s4 = ctx.MakeCollection(new IShape[] { ctx.MakePoint(10, 40), ctx.MakePoint(40, 30), ctx.MakePoint(20, 20), ctx.MakePoint(30, 10) }); AssertParses("MULTIPOINT ((10 40), (40 30), (20 20), (30 10))", s4); AssertParses("MULTIPOINT (10 40, 40 30, 20 20, 30 10)", s4); AssertParses("MULTIPOINT Z EMPTY", ctx.MakeCollection(new IShape[0])); }
public virtual void TestCollection() { ShapeCollection s = ctx.MakeCollection( (new IShape[] { RandomShape(), RandomShape(), RandomShape() }).ToList() ); AssertRoundTrip(s); }
public virtual ShapeCollection ReadCollection(BinaryReader dataInput) { byte type = dataInput.ReadByte(); int size = dataInput.ReadInt32(); List <IShape> shapes = new List <IShape>(size); for (int i = 0; i < size; i++) { if (type == 0) { shapes.Add(ReadShape(dataInput)); } else { IShape s = ReadShapeByTypeIfSupported(dataInput, (ShapeType)type); if (s == null) { throw new InvalidShapeException("Unsupported shape byte " + type); } shapes.Add(s); } } return(ctx.MakeCollection(shapes)); }