本文整理汇总了C#中IGeometry.Union方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.Union方法的具体用法?C# IGeometry.Union怎么用?C# IGeometry.Union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.Union方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Union
/// <summary>
/// Computes the set-theoretic union 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 union of the input Geometries.</returns>
public static IGeometry Union(IGeometry geom0, IGeometry geom1)
{
ApplicationException originalEx = null;
try
{
IGeometry result = geom0.Union(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.Union(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: DissolveLines
private static IGeometry DissolveLines(IGeometry lines)
{
IGeometry dissolved = lines.Union();
LineMerger merger = new LineMerger();
merger.Add(dissolved);
IList<IGeometry> mergedColl = merger.GetMergedLineStrings();
IGeometry merged = lines.Factory.BuildGeometry(mergedColl);
return merged;
}
示例4: 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);
}
示例5: UnionWithNull
//private static ICollection<IGeometry> ToCollection<T>(IEnumerable<T> items) where T : IGeometry
//{
// var ret = new List<IGeometry>();
// foreach (IGeometry geometry in items)
// ret.Add(geometry);
// return ret;
//}
///<summary>
/// Computes the union of two geometries, either of both of which may be null.
///</summary>
/// <param name="g0"></param>
/// <param name="g1"></param>
/// <returns>
/// The union of the input(s)
/// or <value>null</value> if both inputs are <value>null</value>
/// </returns>
private static IGeometry UnionWithNull(IGeometry g0, IGeometry g1)
{
if (g0 == null && g1 == null)
return null;
if (g1 == null)
return g0;
if (g0 == null)
return g1;
return g0.Union(g1);
}
示例6: UnionGeometryCollection
private static IGeometry UnionGeometryCollection(IGeometry geom)
{
if (geom is GeometryCollection)
{
return geom.Union();
}
return geom;
}
示例7: UnionActual
/// <summary>
/// Encapsulates the actual unioning of two polygonal geometries.
/// </summary>
private static IGeometry UnionActual(IGeometry g0, IGeometry g1)
{
return RestrictToPolygons(g0.Union(g1));
}
示例8: 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");
}
示例9: measure
/*
public static double measure(Geometry a, Geometry b)
{
AreaSimilarityMeasure gv = new AreaSimilarityMeasure(a, b);
return gv.measure();
}
*/
public double Measure(IGeometry g1, IGeometry g2)
{
double areaInt = g1.Intersection(g2).Area;
double areaUnion = g1.Union(g2).Area;
return areaInt / areaUnion;
}
示例10: InsertCurvePoint
public static IGeometry InsertCurvePoint(IGeometry geometry, ICoordinate coordinate, int index)
{
var vertices = new List<ICoordinate>(geometry.Coordinates);
vertices.Insert(index, coordinate);
var geometryFactory = new GeometryFactory();
if (geometry is ILineString)
{
return geometryFactory.CreateLineString(vertices.ToArray());
}
if (geometry is IPolygon)
{
return geometryFactory.CreatePolygon(geometryFactory.CreateLinearRing(vertices.ToArray()), null);
}
return geometry.Union(geometryFactory.CreatePoint(coordinate));
}
示例11: unaryUnion
public static IGeometry unaryUnion(IGeometry a)
{
return a.Union();
}
示例12: union
public static IGeometry union(IGeometry a, IGeometry b)
{
return a.Union(b);
}
示例13: UnionActual
private IGeometry UnionActual(IGeometry g0, IGeometry g1)
{
return g0.Union(g1);
}