本文整理汇总了C#中NetTopologySuite.Geometries.GeometryFactory.CreateLinearRing方法的典型用法代码示例。如果您正苦于以下问题:C# GeometryFactory.CreateLinearRing方法的具体用法?C# GeometryFactory.CreateLinearRing怎么用?C# GeometryFactory.CreateLinearRing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetTopologySuite.Geometries.GeometryFactory
的用法示例。
在下文中一共展示了GeometryFactory.CreateLinearRing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: main
public static void main(string[] args)
{
ExtendedCoordinateSequenceFactory seqFact = ExtendedCoordinateSequenceFactory.Instance();
ExtendedCoordinate[] array1 = new ExtendedCoordinate[] { new ExtendedCoordinate(0, 0, 0, 91),
new ExtendedCoordinate(10, 0, 0, 92), new ExtendedCoordinate(10, 10, 0, 93),
new ExtendedCoordinate(0, 10, 0, 94), new ExtendedCoordinate(0, 0, 0, 91)};
ICoordinateSequence seq1 = seqFact.Create(array1);
ICoordinateSequence seq2 = seqFact.Create(new ExtendedCoordinate[] { new ExtendedCoordinate(5, 5, 0, 91),
new ExtendedCoordinate(15, 5, 0, 92), new ExtendedCoordinate(15, 15, 0, 93),
new ExtendedCoordinate(5, 15, 0, 94), new ExtendedCoordinate(5, 5, 0, 91)});
GeometryFactory fact = new GeometryFactory(ExtendedCoordinateSequenceFactory.Instance());
IGeometry g1 = fact.CreatePolygon(fact.CreateLinearRing(seq1), null);
IGeometry g2 = fact.CreatePolygon(fact.CreateLinearRing(seq2), null);
Console.WriteLine("WKT for g1: " + g1);
Console.WriteLine("Internal rep for g1: " + ((IPolygon) g1).ExteriorRing.CoordinateSequence);
Console.WriteLine("WKT for g2: " + g2);
Console.WriteLine("Internal rep for g2: " + ((IPolygon)g2).ExteriorRing.CoordinateSequence);
IGeometry gInt = g1.Intersection(g2);
Console.WriteLine("WKT for gInt: " + gInt);
Console.WriteLine("Internal rep for gInt: " + ((IPolygon)gInt).ExteriorRing.CoordinateSequence);
}
示例2: LoadParcels
private void LoadParcels(List<PointD> pt, Color color, string labelname)
{
SharpMap.Map map = new SharpMap.Map();
List<GeoAPI.Geometries.Coordinate> vertices = new List<GeoAPI.Geometries.Coordinate>();
foreach (PointD i in pt)
{
GeoAPI.Geometries.Coordinate p = new GeoAPI.Geometries.Coordinate();
p.X = i.X;
p.Y = i.Y;
vertices.Add(p);
}
GeoAPI.Geometries.Coordinate l = new GeoAPI.Geometries.Coordinate();
l.X = pt[0].X;
l.Y = pt[0].Y;
vertices.Add(l);
//Collection<GeoAPI.Geometries.IGeometry> geom = new Collection<GeoAPI.Geometries.IGeometry>();
GeometryFactory gf = new NetTopologySuite.Geometries.GeometryFactory();
GeoAPI.Geometries.ILinearRing shell = gf.CreateLinearRing(vertices.ToArray());
GeoAPI.Geometries.IPolygon polygon = gf.CreatePolygon(shell, null);
SharpMap.Data.Providers.GeometryProvider geomProvider= new SharpMap.Data.Providers.GeometryProvider(polygon);
SharpMap.Layers.VectorLayer layerParcels = new SharpMap.Layers.VectorLayer("Parcels");
SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle();
style.Fill = new SolidBrush(Color.FromArgb(200,color));
style.Outline = new Pen(new SolidBrush(color));
layerParcels.Style = style;
layerParcels.Style.EnableOutline = true;
layerParcels.DataSource = geomProvider;
layerParcels.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
mapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan;
var fdt = new SharpMap.Data.FeatureDataTable();
fdt.Columns.Add(new System.Data.DataColumn("id", typeof(uint)));
fdt.Columns.Add(new System.Data.DataColumn("label", typeof(string)));
var fdr = (SharpMap.Data.FeatureDataRow)fdt.NewRow();
fdr.ItemArray = new object[] { 1, labelname };
fdr.Geometry = polygon;
fdt.AddRow(fdr);
var dataprovider = new SharpMap.Data.Providers.GeometryFeatureProvider(fdt);
var ll = new SharpMap.Layers.LabelLayer("llayer");
ll.DataSource = dataprovider;
ll.LabelColumn = "label";
ll.Style.Font = new Font("Eurostile Extended", 16,FontStyle.Bold);
mapBox1.Map.Layers.Add(layerParcels);
mapBox1.Map.Layers.Add(ll);
mapBox1.Map.ZoomToExtents();
mapBox1.Refresh();
}
示例3: ToPolygon
public static IGeometry ToPolygon(Vertex[] v)
{
var ringPts = new[]
{
v[0].Coordinate,
v[1].Coordinate,
v[2].Coordinate,
v[0].Coordinate
};
var fact = new GeometryFactory();
var ring = fact.CreateLinearRing(ringPts);
var tri = fact.CreatePolygon(ring, null);
return tri;
}
示例4: GetGeometry
public IGeometry GetGeometry(GeometryFactory fact)
{
ILinearRing ring = fact.CreateLinearRing(GetCoordinates());
IPolygon tri = fact.CreatePolygon(ring, null);
return tri;
}