本文整理汇总了C#中IGeometry.Intersection方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.Intersection方法的具体用法?C# IGeometry.Intersection怎么用?C# IGeometry.Intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGeometry
的用法示例。
在下文中一共展示了IGeometry.Intersection方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intersection
/// <summary>
/// Computes the set-theoretic intersection 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 intersection of the input Geometries.</returns>
public static IGeometry Intersection(IGeometry geom0, IGeometry geom1)
{
ApplicationException originalEx;
try
{
IGeometry result = geom0.Intersection(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.Intersection(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: Perform
private static long Perform(IGeometry geom1, IGeometry geom2)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
var result = geom1.Intersection(geom2);
stopWatch.Stop();
Assert.IsNotNull(result);
Assert.IsTrue(result.IsValid);
return stopWatch.ElapsedMilliseconds;
}
示例3: DoIntersection
private static void DoIntersection(IGeometry poly1, IGeometry poly2, IGeometry clip = null)
{
Assert.IsTrue(poly1.IsValid);
Assert.IsTrue(poly1 is IPolygon);
Assert.IsTrue(poly2.IsValid);
Assert.IsTrue(poly2 is IPolygon);
IGeometry intersection = poly1.Intersection(poly2);
Assert.IsNotNull(intersection);
Assert.IsTrue(intersection.IsValid);
WKTReader reader = new WKTReader();
IGeometry expectedIntersection = reader.Read(ExpectedResult);
if (clip != null)
expectedIntersection = expectedIntersection.Intersection(clip);
double hd = DiscreteHausdorffDistance.Distance(intersection, expectedIntersection);
Assert.That(hd < 0.001, "Intersection error: result not same as JTS");
}
示例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: 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;
}
示例7: IntersectionArea
private static double IntersectionArea(IGeometry geometry, IGeometry other)
{
if (geometry.Intersects(other.Envelope))
{
OverlayOp.NodingValidatorDisabled = true;
double area;
try
{
area = geometry.Intersection(other).Area;
}
catch (Exception)
{
area = GetSampledIntersectionArea(geometry, other);
}
OverlayOp.NodingValidatorDisabled = false;
return area;
}
return 0.0;
}
示例8: GetRightHalfGeometry
private static IGeometry GetRightHalfGeometry(IGeometry geometry, double splitPointX)
{
double maxXValue = geometry.EnvelopeInternal.MaxX + 1;
double minYValue = geometry.EnvelopeInternal.MinY - 1;
double maxYValue = geometry.EnvelopeInternal.MaxY + 1;
var coordinatesRight = new[]
{
new Coordinate(splitPointX, maxYValue),
new Coordinate(splitPointX, minYValue),
new Coordinate(maxXValue, minYValue),
new Coordinate(maxXValue, maxYValue),
new Coordinate(splitPointX, maxYValue)
};
//
var leftRectangle = new Polygon(new LinearRing(coordinatesRight));
return geometry.Intersection(leftRectangle);
}
示例9: intersection
public static IGeometry intersection(IGeometry a, IGeometry b)
{
return a.Intersection(b);
}
示例10: CheckIntersection
public void CheckIntersection(IGeometry baseGeom, IGeometry testGeom)
{
// this line can be used to test for the presence of noding failures for
// non-tricky cases
// Geometry star = rr2;
Console.WriteLine("Star:");
Console.WriteLine(baseGeom);
Console.WriteLine("Rectangle:");
Console.WriteLine(testGeom);
// test to see whether the basic overlay code fails
try
{
var intTrial = baseGeom.Intersection(testGeom);
NetTopologySuite.Utilities.Assert.IsTrue(intTrial != null);
}
catch (Exception)
{
_failureCount++;
}
// this will throw an intersection if a robustness error occurs,
// stopping the run
var intersection = SnapIfNeededOverlayOp.Intersection(baseGeom, testGeom);
Console.WriteLine("Intersection:");
Console.WriteLine(intersection);
}