本文整理汇总了C#中IGeometry.Difference方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.Difference方法的具体用法?C# IGeometry.Difference怎么用?C# IGeometry.Difference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.Difference方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Difference
/// <summary>
/// Computes the set-theoretic difference of two <c>Geometry</c>s, using enhanced precision.
/// </summary>
/// <param name="geom0">The first Geometry.</param>
/// <param name="geom1">The second Geometry.</param>
/// <returns>The Geometry representing the set-theoretic difference of the input Geometries.</returns>
public static IGeometry Difference(IGeometry geom0, IGeometry geom1)
{
ApplicationException originalEx = null;
try
{
IGeometry result = geom0.Difference(geom1);
return result;
}
catch (ApplicationException ex)
{
originalEx = ex;
}
/*
* If we are here, the original op encountered a precision problem
* (or some other problem). Retry the operation with
* enhanced precision to see if it succeeds
*/
try
{
CommonBitsOp cbo = new CommonBitsOp(true);
IGeometry resultEP = cbo.Difference(geom0, geom1);
// check that result is a valid point after the reshift to orginal precision
if (!resultEP.IsValid)
throw originalEx;
return resultEP;
}
catch (ApplicationException)
{
throw originalEx;
}
}
示例2: BufferBySegments
/// <summary>
/// Buffer polygons by buffering the individual boundary segments and
/// either unioning or differencing them.
/// </summary>
/// <param name="g"></param>
/// <param name="distance"></param>
/// <returns>The buffer geometry</returns>
public static IGeometry BufferBySegments(IGeometry g, double distance)
{
var segs = LineHandlingFunctions.ExtractSegments(g);
var posDist = Math.Abs(distance);
var segBuf = BufferByComponents(segs, posDist);
if (distance < 0.0)
return g.Difference(segBuf);
return g.Union(segBuf);
}
示例3: BufferByChains
public static IGeometry BufferByChains(IGeometry g, double distance, int maxChainSize)
{
if (maxChainSize <= 0)
throw new ArgumentOutOfRangeException("maxChainSize", "Maximum Chain Size must be specified as an input parameter");
var segs = LineHandlingFunctions.ExtractChains(g, maxChainSize);
double posDist = Math.Abs(distance);
var segBuf = BufferByComponents(segs, posDist);
if (distance < 0.0)
return g.Difference(segBuf);
return g.Union(segBuf);
}
示例4: InvokeGeometryOverlayMethod
public static IGeometry InvokeGeometryOverlayMethod(SpatialFunction opCode, IGeometry g0, IGeometry g1)
{
switch (opCode)
{
case SpatialFunction.Intersection:
return g0.Intersection(g1);
case SpatialFunction.Union:
return g0.Union(g1);
case SpatialFunction.Difference:
return g0.Difference(g1);
case SpatialFunction.SymDifference:
return g0.SymmetricDifference(g1);
}
throw new ArgumentException(@"Unknown overlay op code");
}
示例5: AreaDiff
public static double AreaDiff(IGeometry g0, IGeometry g1)
{
double areaA = g0.Area;
double areaAdiffB = g0.Difference(g1).Area;
double areaAintB = g0.Intersection(g1).Area;
return areaA - areaAdiffB - areaAintB;
}
示例6: RemoveCurvePoint
public static IGeometry RemoveCurvePoint(IGeometry geometry, int index, bool keepLineStringEndPoints=false)
{
var vertices = new List<ICoordinate>(geometry.Coordinates);
vertices.RemoveAt(index);
var geometryFactory = new GeometryFactory();
var lastIndex = geometry.Coordinates.Length - 1;
if (geometry is ILineString)
{
if (vertices.Count < 2)
{
return null;
}
if (keepLineStringEndPoints && (index == 0 || index == lastIndex))
{
return null;
}
return geometryFactory.CreateLineString(vertices.ToArray());
}
if (geometry is IPolygon)
{
// If first or last index is removed -> remove corresponding duplicate at the other end and close the ring.
if (index == lastIndex)
{
vertices[0] = vertices[lastIndex];
}
if (index == 0)
{
vertices[lastIndex - 1] = vertices[0];
}
if (vertices.Count < 4)
{
return null;
}
return geometryFactory.CreatePolygon(geometryFactory.CreateLinearRing(vertices.ToArray()), null);
}
if (index < geometry.Coordinates.Length)
{
var coordinate = geometry.Coordinates[index];
var point = geometryFactory.CreatePoint(coordinate);
return geometry.Difference(point);
}
return geometry;
}
示例7: differenceBA
public static IGeometry differenceBA(IGeometry a, IGeometry b)
{
return b.Difference(a);
}
示例8: difference
public static IGeometry difference(IGeometry a, IGeometry b)
{
return a.Difference(b);
}