internal static void Populate(IGeometrySink sink, IList<PointNode> points, GeometryType type) { if (points.Count>0) { if (type!=GeometryType.LineString) sink.BeginGeometry(GeometryType.Point); sink.BeginFigure(points[0].X, points[0].Y, null); if (type==GeometryType.MultiPoint) sink.EndFigure(); for (int i=1; i<points.Count; ++i) if (type==GeometryType.MultiPoint) { sink.BeginFigure(points[i].X, points[i].Y, null); sink.EndFigure(); } else sink.AddLine(points[i].X, points[i].Y, null); if (type!=GeometryType.MultiPoint) sink.EndFigure(); if (type!=GeometryType.LineString) sink.EndGeometry(); } }
public void Populate(IGeometrySink sink) { if (srsName!=null) sink.SetCoordinateSystem(CoordinateSystem); InternalPopulate(sink); }
private static void CreateFigure(IGeometrySink sink, IList <SmGeometries.Point> points) { if ((points == null) || (points.Count == 0)) { return; } var p0 = points[0]; var p03 = p0 as SmGeometries.Point3D; if (p03 != null) { sink.BeginFigure(p03.X, p03.Y, p03.Z); } else { sink.BeginFigure(p0.X, p0.Y, null); } for (int i = 1; i < points.Count; ++i) { var pi = points[i]; var pi3 = pi as SmGeometries.Point3D; if (pi3 != null) { sink.AddLine(pi3.X, pi3.Y, pi3.Z); } else { sink.AddLine(pi.X, pi.Y, null); } } sink.EndFigure(); }
public void Populate(IGeometrySink sink) { sink.SetCoordinateSystem(CoordinateSystem); sink.BeginGeometry(GeometryType.Polygon); if ( (lowerCorner!=null) && (lowerCorner.TypedValue!=null) && (lowerCorner.TypedValue.Count==2) && (upperCorner!=null) && (upperCorner.TypedValue!=null) && (upperCorner.TypedValue.Count==2) ) { double minlon=Math.Min(lowerCorner.TypedValue[0], upperCorner.TypedValue[0]); double maxlon=Math.Max(lowerCorner.TypedValue[0], upperCorner.TypedValue[0]); double minlat=Math.Min(lowerCorner.TypedValue[1], upperCorner.TypedValue[1]); double maxlat=Math.Max(lowerCorner.TypedValue[1], upperCorner.TypedValue[1]); sink.BeginFigure(minlon, minlat, null); sink.AddLine(maxlon, minlat, null); sink.AddLine(maxlon, maxlat, null); sink.AddLine(minlon, maxlat, null); sink.AddLine(minlon, minlat, null); sink.EndFigure(); } sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> /// <remarks> /// <para>The call sequence is a set of figures, lines, and points for geometry types.</para> /// </remarks> public void Populate(IGeometrySink sink) { sink.SetCoordinateSystem(CoordinateSystem); switch (_Geometry.GeometryType) { case SmGeometries.GeometryType2.LineString: case SmGeometries.GeometryType2.Point: case SmGeometries.GeometryType2.Polygon: _PopulateSimpleType(sink, _Geometry); break; case SmGeometries.GeometryType2.GeometryCollection: case SmGeometries.GeometryType2.MultiLineString: case SmGeometries.GeometryType2.MultiPoint: case SmGeometries.GeometryType2.MultiPolygon: sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.GeometryType)); foreach (SmGeometries.Geometry g in (IEnumerable <SmGeometries.Geometry>)_Geometry) { _PopulateSimpleType(sink, g); } sink.EndGeometry(); break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, _Geometry.GeometryType ) ); } }
public void Populate(IGeometrySink sink) { sink.SetCoordinateSystem(CoordinateSystem); sink.BeginGeometry(GeometryType.Polygon); if ( (lowerCorner != null) && (lowerCorner.TypedValue != null) && (lowerCorner.TypedValue.Count == 2) && (upperCorner != null) && (upperCorner.TypedValue != null) && (upperCorner.TypedValue.Count == 2) ) { double minlon = Math.Min(lowerCorner.TypedValue[0], upperCorner.TypedValue[0]); double maxlon = Math.Max(lowerCorner.TypedValue[0], upperCorner.TypedValue[0]); double minlat = Math.Min(lowerCorner.TypedValue[1], upperCorner.TypedValue[1]); double maxlat = Math.Max(lowerCorner.TypedValue[1], upperCorner.TypedValue[1]); sink.BeginFigure(minlon, minlat, null); sink.AddLine(maxlon, minlat, null); sink.AddLine(maxlon, maxlat, null); sink.AddLine(minlon, maxlat, null); sink.AddLine(minlon, minlat, null); sink.EndFigure(); } sink.EndGeometry(); }
public unsafe static void AddLines(this IGeometrySink sink, ReadOnlySpan <PointF> points) { fixed(PointF *p = &MemoryMarshal.GetReference(points)) { sink.AddLines(p, (uint)points.Length); } }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.GeometryCollection); foreach (IGeometryTap g in _Geometries) g.Populate(sink); sink.EndGeometry(); }
internal protected override void InternalPopulate(IGeometrySink sink) { int dim = 2; if (srsDimension.HasValue) { dim = Convert.ToInt32(srsDimension.Value); } sink.BeginGeometry(GeometryType.Point); //if (pos!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}pos").Any <XElement>()) { if (pos.srsDimension.HasValue) { dim = Convert.ToInt32(pos.srsDimension.Value); } if ((pos.TypedValue != null) && (pos.TypedValue.Count >= dim)) { sink.BeginFigure(pos.TypedValue[0], pos.TypedValue[1], dim > 2 ? pos.TypedValue[2] : (double?)null); sink.EndFigure(); } } sink.EndGeometry(); }
public Sink(IGeometrySink sink) { Debug.Assert(sink!=null); if (sink==null) throw new ArgumentNullException("sink"); _Sink=sink; }
private void PopulateFigure(IGeometrySink sink) { m_figure[0].BeginFigure(sink); for (int i = 1; i < m_figure.Count; i++) { m_figure[i].AddLine(sink); } sink.EndFigure(); }
public void Populate(IGeometrySink sink) { if (srsName != null) { sink.SetCoordinateSystem(CoordinateSystem); } InternalPopulate(sink); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.GeometryCollection); foreach (IGeometryTap g in _Geometries) { g.Populate(sink); } sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.Point); if (_Point!=null) { sink.BeginFigure(_Point.X, _Point.Y, null); sink.EndFigure(); } sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.Point); if (_Point != null) { sink.BeginFigure(_Point.X, _Point.Y, null); sink.EndFigure(); } sink.EndGeometry(); }
public Sink(IGeometrySink sink) { Debug.Assert(sink != null); if (sink == null) { throw new ArgumentNullException("sink"); } _Sink = sink; }
/// <summary>Creates a new instance of the <see cref="ReversedGeometrySink" /> class.</summary> public ReversedGeometrySink(IGeometrySink sink) : base() { Debug.Assert(sink!=null); if (sink==null) throw new ArgumentNullException("sink"); _Sink=sink; _Figures=new Stack<LinkedList<Point>>(); }
protected internal override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.MultiPoint); //if ((pointMember!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}pointMember").Any<XElement>()) foreach (pointMember p in pointMember) p.Point.Populate(sink); sink.EndGeometry(); }
protected internal override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.GeometryCollection); //if ((geometryMember!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}geometryMember").Any<XElement>()) foreach (geometryMember g in geometryMember) g._Geometry.Populate(sink); sink.EndGeometry(); }
protected internal override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.MultiLineString); //if ((lineStringMember!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}lineStringMember").Any<XElement>()) foreach (lineStringMember l in lineStringMember) l.LineString.Populate(sink); sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> /// <remarks> /// <para>The call sequence is a set of figures, lines, and points for geometry types.</para> /// </remarks> public void Populate(IGeometrySink sink) { var sgs = sink as SqlTypes.IGeometrySink110; if (sgs == null) { sgs = new Sink(sink); } _Geometry.Populate(sgs); }
internal protected override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.Polygon); if ((exterior!=null) && (exterior._Ring!=null)) exterior._Ring.Populate(sink); if (interior!=null) foreach (interior intr in interior) intr._Ring.Populate(sink); sink.EndGeometry(); }
/// <summary>Creates a new instance of the <see cref="ReversedGeometrySink" /> class.</summary> public ReversedGeometrySink(IGeometrySink sink) : base() { Debug.Assert(sink != null); if (sink == null) { throw new ArgumentNullException("sink"); } _Sink = sink; _Figures = new Stack <LinkedList <Point> >(); }
protected internal override void InternalPopulate(IGeometrySink sink) { int dim=2; if (srsDimension.HasValue) dim=Convert.ToInt32(srsDimension.Value); if (posList.srsDimension.HasValue) dim=Convert.ToInt32(posList.srsDimension.Value); sink.BeginFigure(posList.TypedValue[0], posList.TypedValue[1], dim>2 ? posList.TypedValue[2] : (double?)null); for (int i=dim; i<posList.TypedValue.Count; i+=dim) sink.AddLine(posList.TypedValue[i], posList.TypedValue[i+1], dim>2 ? posList.TypedValue[i+2] : (double?)null); sink.EndFigure(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType); foreach (SeriesNode series in _PolygonsSeries) { sink.BeginGeometry(GeometryType.Polygon); List<SeriesNode> lineStrings=series.Select<ParseTreeNode, SeriesNode>(n => (SeriesNode)n.AstNode).ToList<SeriesNode>(); MultiLineStringNode.Populate(sink, lineStrings, GeometryType.Polygon); sink.EndGeometry(); } sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType); foreach (SeriesNode series in _PolygonsSeries) { sink.BeginGeometry(GeometryType.Polygon); List <SeriesNode> lineStrings = series.Select <ParseTreeNode, SeriesNode>(n => (SeriesNode)n.AstNode).ToList <SeriesNode>(); MultiLineStringNode.Populate(sink, lineStrings, GeometryType.Polygon); sink.EndGeometry(); } sink.EndGeometry(); }
internal static void Populate(IGeometrySink sink, IList<SeriesNode> pointSeries, GeometryType type) { foreach (SeriesNode series in pointSeries) { if (type!=GeometryType.Polygon) sink.BeginGeometry(GeometryType.LineString); List<PointNode> points=series.Select<ParseTreeNode, PointNode>(n => (PointNode)n.AstNode).ToList<PointNode>(); MultiPointNode.Populate(sink, points, GeometryType.LineString); if (type!=GeometryType.Polygon) sink.EndGeometry(); } }
protected internal override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.GeometryCollection); //if ((geometryMember!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}geometryMember").Any <XElement>()) { foreach (geometryMember g in geometryMember) { g._Geometry.Populate(sink); } } sink.EndGeometry(); }
protected internal override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.MultiLineString); //if ((lineStringMember!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}lineStringMember").Any <XElement>()) { foreach (lineStringMember l in lineStringMember) { l.LineString.Populate(sink); } } sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> /// <remarks> /// <para>The call sequence is a set of figures, lines, and points for geometry types.</para> /// </remarks> public void Populate(IGeometrySink sink) { sink.SetCoordinateSystem(CoordinateSystem); sink.BeginGeometry(GeometryType.Polygon); sink.BeginFigure(_Envelope.MinX, _Envelope.MinY, null); sink.AddLine(_Envelope.MaxX, _Envelope.MinY, null); sink.AddLine(_Envelope.MaxX, _Envelope.MaxY, null); sink.AddLine(_Envelope.MinX, _Envelope.MaxY, null); sink.AddLine(_Envelope.MinX, _Envelope.MinY, null); sink.EndFigure(); sink.EndGeometry(); }
protected internal override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.MultiPolygon); //if ((polygonMember!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}polygonMember").Any <XElement>()) { foreach (polygonMember p in polygonMember) { p.Polygon.Populate(sink); } } sink.EndGeometry(); }
private static void _PopulateSimpleType(IGeometrySink sink, FGeometry.IGeometry geometry) { sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.DerivedType)); switch (geometry.DerivedType) { case FCommon.GeometryType.GeometryType_LineString: using (FGeometry.DirectPositionCollection positions = ((FGeometry.ILineString)geometry).Positions) CreateFigure(sink, positions); break; case FCommon.GeometryType.GeometryType_Point: using (FGeometry.DirectPositionCollection positions = new FGeometry.DirectPositionCollection()) using (FGeometry.IDirectPosition dp = ((FGeometry.IPoint)geometry).Position) { positions.Add(dp); CreateFigure(sink, positions); } break; case FCommon.GeometryType.GeometryType_Polygon: { var polygon = (FGeometry.IPolygon)geometry; using (FGeometry.ILinearRing exterior = polygon.ExteriorRing) using (FGeometry.DirectPositionCollection positions = exterior.Positions) CreateFigure(sink, positions); for (int i = 0; i < polygon.InteriorRingCount; ++i) { using (FGeometry.ILinearRing interior = polygon.GetInteriorRing(i)) using (FGeometry.DirectPositionCollection positions = interior.Positions) CreateFigure(sink, positions); } } break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, geometry.DerivedType ) ); } sink.EndGeometry(); }
internal protected override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.LineString); //if (posList!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}posList").Any<XElement>()) if ((posList.TypedValue!=null) && (posList.TypedValue.Count>=2)) { sink.BeginFigure(posList.TypedValue[0], posList.TypedValue[1], null); for (int i=2; i<posList.TypedValue.Count; i+=2) sink.AddLine(posList.TypedValue[i], posList.TypedValue[i+1], null); sink.EndFigure(); } sink.EndGeometry(); }
internal static void Populate(IGeometrySink sink, IList <SeriesNode> pointSeries, GeometryType type) { foreach (SeriesNode series in pointSeries) { if (type != GeometryType.Polygon) { sink.BeginGeometry(GeometryType.LineString); } List <PointNode> points = series.Select <ParseTreeNode, PointNode>(n => (PointNode)n.AstNode).ToList <PointNode>(); MultiPointNode.Populate(sink, points, GeometryType.LineString); if (type != GeometryType.Polygon) { sink.EndGeometry(); } } }
internal protected override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.Polygon); if ((exterior != null) && (exterior._Ring != null)) { exterior._Ring.Populate(sink); } if (interior != null) { foreach (interior intr in interior) { intr._Ring.Populate(sink); } } sink.EndGeometry(); }
// Selectively filter unwanted artifacts in input object: // - empty shapes (if [filterEmptyShapes] is true) // - points (if [filterPoints] is true) // - linestrings shorter than provided tolerance (if lineString.STLength < [lineStringTolerance]) // - polygon rings thinner than provied tolerance (if ring.STArea < ring.STLength * [ringTolerance]) // - general behaviour: Returned spatial objects will always to the simplest OGC construction // public static SqlGeometry FilterArtifactsGeometry(SqlGeometry g, bool filterEmptyShapes, bool filterPoints, double lineStringTolerance, double ringTolerance) { if (g == null || g.IsNull) { return(g); } SqlGeometryBuilder b = new SqlGeometryBuilder(); IGeometrySink filter = b; if (filterEmptyShapes) { filter = new GeometryEmptyShapeFilter(filter); } if (ringTolerance > 0) { filter = new GeometryThinRingFilter(filter, ringTolerance); } if (lineStringTolerance > 0) { filter = new GeometryShortLineStringFilter(filter, lineStringTolerance); } if (filterPoints) { filter = new GeometryPointFilter(filter); } g.Populate(filter); g = b.ConstructedGeometry; if (g == null || g.IsNull || !g.STIsValid().Value) { return(g); } // Strip collections with single element while (g.STNumGeometries().Value == 1 && g.InstanceOf("GEOMETRYCOLLECTION").Value) { g = g.STGeometryN(1); } return(g); }
protected internal override void InternalPopulate(IGeometrySink sink) { int dim = 2; if (srsDimension.HasValue) { dim = Convert.ToInt32(srsDimension.Value); } if (posList.srsDimension.HasValue) { dim = Convert.ToInt32(posList.srsDimension.Value); } sink.BeginFigure(posList.TypedValue[0], posList.TypedValue[1], dim > 2 ? posList.TypedValue[2] : (double?)null); for (int i = dim; i < posList.TypedValue.Count; i += dim) { sink.AddLine(posList.TypedValue[i], posList.TypedValue[i + 1], dim > 2 ? posList.TypedValue[i + 2] : (double?)null); } sink.EndFigure(); }
internal protected override void InternalPopulate(IGeometrySink sink) { sink.BeginGeometry(GeometryType.LineString); //if (posList!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}posList").Any <XElement>()) { if ((posList.TypedValue != null) && (posList.TypedValue.Count >= 2)) { sink.BeginFigure(posList.TypedValue[0], posList.TypedValue[1], null); for (int i = 2; i < posList.TypedValue.Count; i += 2) { sink.AddLine(posList.TypedValue[i], posList.TypedValue[i + 1], null); } sink.EndFigure(); } } sink.EndGeometry(); }
private static void _PopulateSimpleType(IGeometrySink sink, SmGeometries.Geometry geometry) { sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.GeometryType)); switch (geometry.GeometryType) { case SmGeometries.GeometryType2.LineString: CreateFigure(sink, ((SmGeometries.LineString)geometry).Vertices); break; case SmGeometries.GeometryType2.Point: CreateFigure(sink, new SmGeometries.Point[] { (SmGeometries.Point)geometry }); break; case SmGeometries.GeometryType2.Polygon: { var pol = (SmGeometries.Polygon)geometry; CreateFigure(sink, pol.ExteriorRing.Vertices); if (pol.InteriorRings != null) { foreach (SmGeometries.LinearRing lr in pol.InteriorRings) { CreateFigure(sink, lr.Vertices); } } } break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, geometry.GeometryType ) ); } sink.EndGeometry(); }
private void AddRandomSegment(IGeometrySink sink) { double which = Random.NextDouble(); if (which < 0.25) { sink.AddLine(RandomNearPoint()); } else if (which < 0.5) { sink.AddArc(RandomArc()); } else if (which < 0.75) { sink.AddBezier(RandomBezier()); } else if (which < 1.0) { sink.AddQuadraticBezier(RandomQuadraticBezier()); } }
internal static void Populate(IGeometrySink sink, IList <PointNode> points, GeometryType type) { if (points.Count > 0) { if (type != GeometryType.LineString) { sink.BeginGeometry(GeometryType.Point); } sink.BeginFigure(points[0].X, points[0].Y, null); if (type == GeometryType.MultiPoint) { sink.EndFigure(); } for (int i = 1; i < points.Count; ++i) { if (type == GeometryType.MultiPoint) { sink.BeginFigure(points[i].X, points[i].Y, null); sink.EndFigure(); } else { sink.AddLine(points[i].X, points[i].Y, null); } } if (type != GeometryType.MultiPoint) { sink.EndFigure(); } if (type != GeometryType.LineString) { sink.EndGeometry(); } } }
internal protected override void InternalPopulate(IGeometrySink sink) { int dim=2; if (srsDimension.HasValue) dim=Convert.ToInt32(srsDimension.Value); sink.BeginGeometry(GeometryType.Point); //if (pos!=null) if (Untyped.Descendants("{http://www.opengis.net/gml}pos").Any<XElement>()) { if (pos.srsDimension.HasValue) dim=Convert.ToInt32(pos.srsDimension.Value); if ((pos.TypedValue!=null) && (pos.TypedValue.Count>=dim)) { sink.BeginFigure(pos.TypedValue[0], pos.TypedValue[1], dim>2 ? pos.TypedValue[2] : (double?)null); sink.EndFigure(); } } sink.EndGeometry(); }
private void AddRandomFigure(IGeometrySink sink, int segmentCount) { previousPoint = null; sink.BeginFigure( RandomNearPoint(), CoinFlip ? FigureBegin.Filled : FigureBegin.Hollow); FigureEnd end = CoinFlip ? FigureEnd.Closed : FigureEnd.Closed; if (end == FigureEnd.Closed) { segmentCount--; } if (CoinFlip) { for (int i = 0; i < segmentCount; i++) { AddRandomSegment(sink); } } else { double which = Random.NextDouble(); if (which < 0.33) { sink.AddLines(RandomLines(segmentCount)); } else if (which < 0.67) { sink.AddQuadraticBeziers(RandomQuadraticBeziers(segmentCount)); } else { sink.AddBeziers(RandomBeziers(segmentCount)); } } sink.EndFigure(end); }
private static void CreateFigure(IGeometrySink sink, FGeometry.DirectPositionCollection positions) { if ((positions == null) || (positions.Count == 0)) { return; } using (FGeometry.IDirectPosition p0 = positions[0]) { if (p0.Dimensionality > 2) { sink.BeginFigure(p0.X, p0.Y, p0.Z); } else { sink.BeginFigure(p0.X, p0.Y, null); } } for (int i = 1; i < positions.Count; ++i) { using (FGeometry.IDirectPosition pi = positions[i]) { if (pi.Dimensionality > 2) { sink.AddLine(pi.X, pi.Y, pi.Z); } else { sink.AddLine(pi.X, pi.Y, null); } } } sink.EndFigure(); }
private static void _PopulateSimpleType(IGeometrySink sink, FGeometry.IGeometry geometry) { sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.DerivedType)); switch (geometry.DerivedType) { case FCommon.GeometryType.GeometryType_LineString: using (FGeometry.DirectPositionCollection positions=((FGeometry.ILineString)geometry).Positions) CreateFigure(sink, positions); break; case FCommon.GeometryType.GeometryType_Point: using (FGeometry.DirectPositionCollection positions=new FGeometry.DirectPositionCollection()) using (FGeometry.IDirectPosition dp=((FGeometry.IPoint)geometry).Position) { positions.Add(dp); CreateFigure(sink, positions); } break; case FCommon.GeometryType.GeometryType_Polygon: { var polygon=(FGeometry.IPolygon)geometry; using (FGeometry.ILinearRing exterior=polygon.ExteriorRing) using (FGeometry.DirectPositionCollection positions=exterior.Positions) CreateFigure(sink, positions); for (int i=0; i<polygon.InteriorRingCount; ++i) using (FGeometry.ILinearRing interior=polygon.GetInteriorRing(i)) using (FGeometry.DirectPositionCollection positions=interior.Positions) CreateFigure(sink, positions); } break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, geometry.DerivedType ) ); } sink.EndGeometry(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> /// <remarks> /// <para>The call sequence is a set of figures, lines, and points for geometry types.</para> /// </remarks> public void Populate(IGeometrySink sink) { Gml._Geometry g=Gml._Geometry.Parse(_Geometry.AsGml()); g.Populate(sink); }
private void AddRandomSegment(IGeometrySink sink) { double which = Random.NextDouble(); if (which < 0.25) sink.AddLine(RandomNearPoint()); else if (which < 0.5) sink.AddArc(RandomArc()); else if (which < 0.75) sink.AddBezier(RandomBezier()); else if (which < 1.0) sink.AddQuadraticBezier(RandomQuadraticBezier()); }
private void AddRandomFigure(IGeometrySink sink, int segmentCount) { previousPoint = null; sink.BeginFigure( RandomNearPoint(), CoinFlip ? FigureBegin.Filled : FigureBegin.Hollow); FigureEnd end = CoinFlip ? FigureEnd.Closed : FigureEnd.Closed; if (end == FigureEnd.Closed) segmentCount--; if (CoinFlip) for (int i = 0; i < segmentCount; i++) AddRandomSegment(sink); else { double which = Random.NextDouble(); if (which < 0.33) sink.AddLines(RandomLines(segmentCount)); else if (which < 0.67) sink.AddQuadraticBeziers(RandomQuadraticBeziers(segmentCount)); else sink.AddBeziers(RandomBeziers(segmentCount)); } sink.EndFigure(end); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> /// <remarks> /// <para>The call sequence is a set of figures, lines, and points for geometry types.</para> /// </remarks> public void Populate(IGeometrySink sink) { var sgs=sink as SqlTypes.IGeographySink110; if (sgs==null) sgs=new Sink(sink); _Geography.Populate(sgs); }
public void Stream(IGeometrySink geometrySink) { base.innerRefT.Stream(geometrySink); }
private static void CreateFigure(IGeometrySink sink, IList<SmGeometries.Point> points) { if ((points==null) || (points.Count==0)) return; var p0=points[0]; var p03=p0 as SmGeometries.Point3D; if (p03!=null) sink.BeginFigure(p03.X, p03.Y, p03.Z); else sink.BeginFigure(p0.X, p0.Y, null); for (int i=1; i<points.Count; ++i) { var pi=points[i]; var pi3=pi as SmGeometries.Point3D; if (pi3!=null) sink.AddLine(pi3.X, pi3.Y, pi3.Z); else sink.AddLine(pi.X, pi.Y, null); } sink.EndFigure(); }
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> public void Populate(IGeometrySink sink) { sink.BeginGeometry(GeometryType); Populate(sink, _Points, GeometryType); sink.EndGeometry(); }
internal protected abstract void InternalPopulate(IGeometrySink sink);
/// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary> /// <param name="sink">The sink to populate.</param> /// <remarks> /// <para>The call sequence is a set of figures, lines, and points for geometry types.</para> /// </remarks> public void Populate(IGeometrySink sink) { sink.SetCoordinateSystem(CoordinateSystem); switch (_Geometry.DerivedType) { case FCommon.GeometryType.GeometryType_LineString: case FCommon.GeometryType.GeometryType_Point: case FCommon.GeometryType.GeometryType_Polygon: _PopulateSimpleType(sink, _Geometry); break; case FCommon.GeometryType.GeometryType_MultiLineString: sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType)); { var multiLineString=(FGeometry.IMultiLineString)_Geometry; for (int i=0; i<multiLineString.Count; ++i) using (FGeometry.ILineString lineString=multiLineString[i]) _PopulateSimpleType(sink, lineString); } sink.EndGeometry(); break; case FCommon.GeometryType.GeometryType_MultiPoint: sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType)); { var multiPoint=(FGeometry.IMultiPoint)_Geometry; using (FGeometry.DirectPositionCollection positions=new FGeometry.DirectPositionCollection()) for (int i=0; i<multiPoint.Count; ++i) using (FGeometry.IPoint point=multiPoint[i]) _PopulateSimpleType(sink, point); } sink.EndGeometry(); break; case FCommon.GeometryType.GeometryType_MultiPolygon: sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType)); { var multiPolygon=(FGeometry.IMultiPolygon)_Geometry; for (int i=0; i<multiPolygon.Count; ++i) using (FGeometry.IPolygon polygon=multiPolygon[i]) _PopulateSimpleType(sink, polygon); } sink.EndGeometry(); break; case FCommon.GeometryType.GeometryType_MultiGeometry: sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType)); { var multiGeometry=(FGeometry.IMultiGeometry)_Geometry; for (int i=0; i<multiGeometry.Count; ++i) using (FGeometry.IGeometry geometry=multiGeometry[i]) _PopulateSimpleType(sink, geometry); } sink.EndGeometry(); break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, _Geometry.DerivedType ) ); } }
internal protected override void InternalPopulate(IGeometrySink sink) { throw new NotImplementedException(); }
protected internal override void InternalPopulate(IGeometrySink sink) { throw new NotImplementedException(); }
private static void _PopulateSimpleType(IGeometrySink sink, SmGeometries.Geometry geometry) { sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.GeometryType)); switch (geometry.GeometryType) { case SmGeometries.GeometryType2.LineString: CreateFigure(sink, ((SmGeometries.LineString)geometry).Vertices); break; case SmGeometries.GeometryType2.Point: CreateFigure(sink, new SmGeometries.Point[] { (SmGeometries.Point)geometry }); break; case SmGeometries.GeometryType2.Polygon: { var pol=(SmGeometries.Polygon)geometry; CreateFigure(sink, pol.ExteriorRing.Vertices); if (pol.InteriorRings!=null) foreach (SmGeometries.LinearRing lr in pol.InteriorRings) CreateFigure(sink, lr.Vertices); } break; default: throw new NotSupportedException( string.Format( CultureInfo.CurrentCulture, SR.UnsupportedGeometryTypeException, geometry.GeometryType ) ); } sink.EndGeometry(); }
private static void CreateFigure(IGeometrySink sink, FGeometry.DirectPositionCollection positions) { if ((positions==null) || (positions.Count==0)) return; using (FGeometry.IDirectPosition p0=positions[0]) { if (p0.Dimensionality>2) sink.BeginFigure(p0.X, p0.Y, p0.Z); else sink.BeginFigure(p0.X, p0.Y, null); } for (int i=1; i<positions.Count; ++i) using (FGeometry.IDirectPosition pi=positions[i]) { if (pi.Dimensionality>2) sink.AddLine(pi.X, pi.Y, pi.Z); else sink.AddLine(pi.X, pi.Y, null); } sink.EndFigure(); }
/// <summary>Populates the specified <paramref name="sink" /> with the specified <paramref name="text" /> and <paramref name="coordinateSystem" />.</summary> /// <param name="sink">The object to fill.</param> /// <param name="text">The WKT representation of the source geometry.</param> /// <param name="coordinateSystem">The coordinate system of the WKT representation.</param> public static void Populate(IGeometrySink sink, string text, ICoordinateSystem coordinateSystem) { Debug.Assert(sink!=null); if (sink==null) throw new ArgumentNullException("sink"); Debug.Assert(coordinateSystem!=null); if (coordinateSystem==null) throw new ArgumentNullException("coordinateSystem"); sink.SetCoordinateSystem(coordinateSystem); if (string.IsNullOrEmpty(text)) return; // Parse the WKT var parser=new Parser(LanguageData); ParseTree tree=parser.Parse(text); if (tree.ParserMessages.Count>0) { var logger=LogManager.GetCurrentClassLogger(); var exl=new List<Exception>(); foreach (LogMessage lm in tree.ParserMessages) switch (lm.Level) { case ErrorLevel.Error: logger.Error(CultureInfo.InvariantCulture, m => m("({0},{1}): {2}", lm.Location.Line, lm.Location.Column, lm.Message)); exl.Add( new ArgumentException( string.Format( parser.Context.Culture, "({0},{1}): {2}: {3}", lm.Location.Line, lm.Location.Column, lm.Level, lm.Message ), "text" ) ); break; case ErrorLevel.Info: logger.Info(CultureInfo.InvariantCulture, m => m("({0},{1}): {2}", lm.Location.Line, lm.Location.Column, lm.Message)); break; default: logger.Warn(CultureInfo.InvariantCulture, m => m("({0},{1}): {2}", lm.Location.Line, lm.Location.Column, lm.Message)); break; } if (exl.Count>0) throw new AggregateException(exl); } // Fill the sink ((IGeometryTap)tree.Root.AstNode).Populate(sink); }