几何构造函数
Contents
[
Hide
]
点几何
创建点
使用 API 创建地理空间点非常简单方便,如下面的代码示例所示。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(40.7128, -74.006); |
创建多点
Aspose.GIS for .NET 提供了将多个点表示为单个 MultiPoint 类的方法。它可以包含由每个点的经纬度信息定义的一个或多个点。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
MultiPoint multipoint = new MultiPoint(); | |
multipoint.Add(new Point(1, 2)); | |
multipoint.Add(new Point(3, 4)); |
线字符串几何
您可以指定 Point Geometry 创建 Line String。
创建线字符串
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); |
创建多线字符串
MultiLine 字符串是由 Point geometries 构建的 Line Strings 的集合。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LineString firstLine = new LineString(); | |
firstLine.AddPoint(7.5, -3.5); | |
firstLine.AddPoint(-9.6, 12.6); | |
LineString secondLine = new LineString(); | |
secondLine.AddPoint(8.5, -2.6); | |
secondLine.AddPoint(-8.6, 1.5); | |
MultiLineString multiLineString = new MultiLineString(); | |
multiLineString.Add(firstLine); | |
multiLineString.Add(secondLine); |
多边形几何
多边形是由 Point geometries 的集合,以 LinearRing 形式定义 Points。
创建多边形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Polygon polygon = new Polygon(); | |
LinearRing ring = new LinearRing(); | |
ring.AddPoint(50.02, 36.22); | |
ring.AddPoint(49.99, 36.26); | |
ring.AddPoint(49.97, 36.23); | |
ring.AddPoint(49.98, 36.17); | |
ring.AddPoint(50.02, 36.22); | |
polygon.ExteriorRing = ring; |
创建多边形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
LinearRing firstRing = new LinearRing(); | |
firstRing.AddPoint(8.5, -2.5); | |
firstRing.AddPoint(-8.5, 2.5); | |
firstRing.AddPoint(8.5, -2.5); | |
Polygon firstPolygon = new Polygon(firstRing); | |
LinearRing secondRing = new LinearRing(); | |
secondRing.AddPoint(7.6, -3.6); | |
secondRing.AddPoint(-9.6, 1.5); | |
secondRing.AddPoint(7.6, -3.6); | |
Polygon secondPolygon = new Polygon(secondRing); | |
MultiPolygon multiPolygon = new MultiPolygon(); | |
multiPolygon.Add(firstPolygon); | |
multiPolygon.Add(secondPolygon); |
创建带孔的多边形
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Polygon polygon = new Polygon(); | |
LinearRing ring = new LinearRing(); | |
ring.AddPoint(50.02, 36.22); | |
ring.AddPoint(49.99, 36.26); | |
ring.AddPoint(49.97, 36.23); | |
ring.AddPoint(49.98, 36.17); | |
ring.AddPoint(50.02, 36.22); | |
LinearRing hole = new LinearRing(); | |
hole.AddPoint(50.00, 36.22); | |
hole.AddPoint(49.99, 36.20); | |
hole.AddPoint(49.98, 36.23); | |
hole.AddPoint(50.00, 36.24); | |
hole.AddPoint(50.00, 36.22); | |
polygon.ExteriorRing = ring; | |
polygon.AddInteriorRing(hole); |
创建几何集合
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-gis/Aspose.GIS-for-.NET | |
Point point = new Point(40.7128, -74.006); | |
LineString line = new LineString(); | |
line.AddPoint(78.65, -32.65); | |
line.AddPoint(-98.65, 12.65); | |
GeometryCollection geometryCollection = new GeometryCollection(); | |
geometryCollection.Add(point); | |
geometryCollection.Add(line); |