本文整理汇总了C#中IGeometry.SnapToSpatialReference方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.SnapToSpatialReference方法的具体用法?C# IGeometry.SnapToSpatialReference怎么用?C# IGeometry.SnapToSpatialReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.SnapToSpatialReference方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIntersectFeature
public static ArrayList GetIntersectFeature(IGeoFeatureLayer pLayer, IGeometry pGeom)
{
ArrayList list = new ArrayList();
if (pLayer != null)
{
if ((pGeom == null) || pGeom.IsEmpty)
{
return list;
}
ISpatialReference reference = (pLayer.FeatureClass as IGeoDataset).SpatialReference;
if (reference != null)
{
pGeom.SpatialReference = reference;
pGeom.SnapToSpatialReference();
}
ISpatialFilter filter = new SpatialFilterClass();
filter.Geometry = pGeom;
filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureCursor o = pLayer.FeatureClass.Search(filter, false);
for (IFeature feature = o.NextFeature(); feature != null; feature = o.NextFeature())
{
list.Add(feature);
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(o);
}
return list;
}
示例2: merge
public static IGeometry merge(IGeometry g1, IGeometry g2, ISDUTExtension ext)
{
ITopologicalOperator2 op_2 = (ITopologicalOperator2)g2;
if(g1 == null)
{
if( g2 == null )
return null;
op_2.IsKnownSimple_2 = false;
try
{
op_2.Simplify();
}
catch (Exception e)
{
Logger.Warn(e);
}
return g2;
}
ITopologicalOperator2 op_1 = (ITopologicalOperator2)g1;
if(g2 == null)
{
op_1.IsKnownSimple_2 = false;
try
{
op_1.Simplify();
}
catch (Exception e)
{
Logger.Warn(e);
}
return g1;
}
// http://forums.esri.com/Thread.asp?c=93&f=1170&t=88297#242834
op_1.IsKnownSimple_2 = false;
try
{
op_1.Simplify();
}
catch (Exception e)
{
Logger.Warn(e);
}
op_2.IsKnownSimple_2 = false;
try
{
op_2.Simplify();
}
catch (Exception e)
{
Logger.Warn(e);
}
if (g1.SpatialReference == null || g1.SpatialReference is IUnknownCoordinateSystem)
{
g1.SpatialReference = ext.FocusMap.SpatialReference;
}
if (g2.SpatialReference == null || g2.SpatialReference is IUnknownCoordinateSystem)
{
g2.SpatialReference = ext.FocusMap.SpatialReference;
}
g2.Project(g1.SpatialReference);
ISpatialReference sr = g1.SpatialReference;
g1.SnapToSpatialReference();
g2.SnapToSpatialReference();
IGeometry r = (IGeometry)(op_1.Union(g2));
r.SpatialReference = sr;
if (r.SpatialReference == null || r.SpatialReference is IUnknownCoordinateSystem)
{
r.SpatialReference = ext.FocusMap.SpatialReference;
}
ITopologicalOperator2 op_r = (ITopologicalOperator2)r;
op_r.IsKnownSimple_2 = false;
try
{
op_r.Simplify();
}
catch (Exception e)
{
Logger.Warn(e);
}
return r;
}