有人使用 .Net 拓扑套件吗? 我有点卡住了,我正在尝试拿到信封以便验证尺寸
根据 http://resources.esri.com/help/9.3/arcgisengine/dotnet/c6e6b26c-be52-4176-b1e5-bb628d10acd0.htm (使用页面底部的 C# 示例)
我采用 IGeometry 类型(边界)并将该多边形的包络转换到 IEnvelope(包络),我希望通过它查看宽度和高度属性
但信封始终为空
IGeometry boundary;
var wktReader = new WKTReader(OSGBGeometryFactory.Factory);
boundary = wktReader.Read(projectDTO.BoundaryWKT);
IEnvelope envelope = boundary.Envelope as IEnvelope;
谁能帮忙,这是我第一次使用这个套件。
我想弄明白的是,如果按照这个例子,我已经有一个 IGeometry 类型(我的边界变量),为什么当我尝试转换它时它为空。
using ESRI.ArcGIS.Geometry;
class temp
{
public void test()
{
// Create an empty polygon object.
IArea areaPolygon = new PolygonClass();
// Cast to the IGeometry interface of the polygon object.
IGeometry geometryPolygon = (IGeometry)areaPolygon;
// Use the .Envelope property on the IGeometry interface of the
// polygon object to get an envelope object.
IEnvelope envelope = geometryPolygon.Envelope;
// Test to make sure you have an envelope object.
if (envelope is Envelope)
{
// The polygon object and resulting envelope are empty.
if (envelope.IsEmpty)
{
System.Windows.Forms.MessageBox.Show("The envelope is empty.");
}
}
}
}
我是否需要创建一个新的多边形并尝试对其进行转换(即复制 IArea areaPolygon = new PolygonClass();)?
请您参考如下方法:
我也遇到了同样的问题。这是 API 开发人员使用奇怪的 Envelope 命名约定的问题。 IGeometry.Envelope 实际上是一个 IGeometry 对象。您应该改用 IGeometry.EnvelopeInternal。
IGeometry boundary;
var wktReader = new WKTReader(OSGBGeometryFactory.Factory);
boundary = wktReader.Read(projectDTO.BoundaryWKT);
IEnvelope envelope = boundary.EnvelopeInternal;
