当前位置: 首页>>代码示例>>C#>>正文


C# IGeometry.Contains方法代码示例

本文整理汇总了C#中IGeometry.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# IGeometry.Contains方法的具体用法?C# IGeometry.Contains怎么用?C# IGeometry.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGeometry的用法示例。


在下文中一共展示了IGeometry.Contains方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckContains

            private static bool CheckContains(IGeometry target, IGeometry test)
            {
                bool expectedResult = target.Contains(test);

                PreparedGeometryFactory pgFact = new PreparedGeometryFactory();
                IPreparedGeometry prepGeom = pgFact.Create(target);

                bool prepResult = prepGeom.Contains(test);

                if (prepResult != expectedResult)
                {
                    return false;
                }
                return true;
            }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:15,代码来源:PreparedPolygonStressTest.cs

示例2: DoPredicates

 public void DoPredicates(IGeometry a, IGeometry b)
 {
     Assert.IsTrue(a.Contains(b) == a.Relate(b).IsContains());
     Assert.IsTrue(a.Crosses(b) == a.Relate(b).IsCrosses(a.Dimension, b.Dimension));
     Assert.IsTrue(a.Disjoint(b) == a.Relate(b).IsDisjoint());
     Assert.IsTrue(a.Equals(b) == a.Relate(b).IsEquals(a.Dimension, b.Dimension));
     Assert.IsTrue(a.Intersects(b) == a.Relate(b).IsIntersects());
     Assert.IsTrue(a.Overlaps(b) == a.Relate(b).IsOverlaps(a.Dimension, b.Dimension));
     Assert.IsTrue(a.Touches(b) == a.Relate(b).IsTouches(a.Dimension, b.Dimension));
     Assert.IsTrue(a.Within(b) == a.Relate(b).IsWithin());
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:PredicateShortCircuitTest.cs

示例3: RunRectanglePred

        private void RunRectanglePred(IGeometry rect, IGeometry testGeom)
        {
            bool intersectsValue = rect.Intersects(testGeom);
            bool relateIntersectsValue = rect.Relate(testGeom).IsIntersects();
            bool intersectsOK = intersectsValue == relateIntersectsValue;

            bool containsValue = rect.Contains(testGeom);
            bool relateContainsValue = rect.Relate(testGeom).IsContains();
            bool containsOK = containsValue == relateContainsValue;

            //System.out.println(testGeom);
            if (!intersectsOK || !containsOK)
            {
                Console.WriteLine(testGeom);
            }
            Assert.IsTrue(intersectsOK);
            Assert.IsTrue(containsOK);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:18,代码来源:RectanglePredicateTest.cs

示例4: SplitPolygon

        internal static IGeometry SplitPolygon(IGeometry polygon, IGeometry line)
        {
            var nodedLinework = polygon.Boundary.Union(line);
            var polygons = Polygonize(nodedLinework);

            // only keep polygons which are inside the input
            var output = new List<IGeometry>();
            for (var i = 0; i < polygons.NumGeometries; i++)
            {
                var candpoly = (IPolygon) polygons.GetGeometryN(i);
                if (polygon.Contains(candpoly.InteriorPoint))
                    output.Add(candpoly);
            }
            /*
            return polygon.Factory.CreateGeometryCollection(
                GeometryFactory.ToGeometryArray(output));
             */
            return polygon.Factory.BuildGeometry(output);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:19,代码来源:SplitPolygonExample.cs

示例5: CheckInteriorPoint

 private static void CheckInteriorPoint(IGeometry g)
 {
     var ip = g.InteriorPoint;
     Assert.IsTrue(g.Contains(ip));
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:5,代码来源:InteriorPointTest.cs

示例6: Within

 /// <summary>
 /// Returns <c>true</c> if the DE-9IM intersection matrix for the two
 /// <c>Geometry</c>s is T*F**F***.
 /// </summary>
 /// <param name="g">The <c>Geometry</c> with which to compare this <c>Geometry</c>.</param>
 /// <returns><c>true</c> if this <c>Geometry</c> is within <c>other</c>.</returns>
 public virtual bool Within(IGeometry g)
 {
     return g.Contains(this);
 }
开发者ID:joelmuzz,项目名称:DotSpatial,代码行数:10,代码来源:Geometry.cs

示例7: Within

 /// <summary>
 /// Returns <c>true</c> if the DE-9IM intersection matrix for the two
 /// <c>Geometry</c>s is T*F**F***.
 /// </summary>
 /// <param name="g">The <c>Geometry</c> with which to compare this <c>Geometry</c>.</param>
 /// <returns><c>true</c> if this <c>Geometry</c> is within <c>other</c>.</returns>
 public bool Within(IGeometry g)
 {
     return g.Contains(this); ;
 }
开发者ID:maxm,项目名称:osmuy,代码行数:10,代码来源:Geometry.cs

示例8: GetSampledIntersectionArea

        public static double GetSampledIntersectionArea(IGeometry geometry, IGeometry other)
        {
            const int steps = 10;
            var area = 0.0;
            var envelopeInternal = geometry.EnvelopeInternal;
            var width = envelopeInternal.Width;
            var height = envelopeInternal.Height;
            var widthStep = width/steps;
            var heightStep = height/steps;
            var minX = envelopeInternal.MinX + widthStep/2.0;
            var minY = envelopeInternal.MinY + heightStep/2.0;
            var boxArea = width*height;
            var cellArea = boxArea/(steps*steps);

            for (var i = 0; i < steps; i++)
            {
                var x = minX + i*widthStep;
                for(var j = 0; j < steps; j++)
                {
                    var y = minY + j*heightStep;
                    if (geometry.Contains(new Point(x, y)) && other.Contains(new Point(x,y)))
                    {
                        area += cellArea;
                    }
                }
            }
            return area;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:28,代码来源:GeometryHelper.cs

示例9: ClipPolygon

internal static IGeometry ClipPolygon(IGeometry polygon, IPolygonal clipPolygonal)
{
    var clipPolygon = (IGeometry) clipPolygonal;
    var nodedLinework = polygon.Boundary.Union(clipPolygon.Boundary);
    var polygons = Polygonize(nodedLinework);
            
    /*
    // Build a prepared clipPolygon
    var prepClipPolygon = NetTopologySuite.Geometries.Prepared.PreparedGeometryFactory.Prepare(clipPolygon);
        */
            
    // only keep polygons which are inside the input
    var output = new List<IGeometry>();
    for (var i = 0; i < polygons.NumGeometries; i++)
    {
        var candpoly = (IPolygon) polygons.GetGeometryN(i);
        var interiorPoint = candpoly.InteriorPoint;
        if (polygon.Contains(interiorPoint) &&
            /*prepClipPolygon.Contains(candpoly)*/
            clipPolygon.Contains(interiorPoint))
            output.Add(candpoly);
    }
    /*
    return polygon.Factory.CreateGeometryCollection(
        GeometryFactory.ToGeometryArray(output));
        */
    return polygon.Factory.BuildGeometry(output);
}
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:28,代码来源:SplitPolygonExample.cs

示例10: getWithin

        // get features within geometry
        public List<Feature> getWithin(IGeometry rect)
        {
            // if node is completely inside geometry, return all features
            if (rect.Contains(gboundary))
                return getAll();
            // if node is completely outside geometry, return no features
            if (!rect.Intersects(gboundary))
                return new List<Feature>();

            // create list for returning features
            List<Feature> retfeatures = new List<Feature>();

            // recursively add features from children
            if (hasChildren)
                foreach (QuadTree qt in children)
                    retfeatures.AddRange(qt.getWithin(rect));

            // check each feature in current node
            foreach (Feature f in features)
                if (rect.Intersects(f.Geometry))
                    retfeatures.Add(f);
            return retfeatures;
        }
开发者ID:hakbra,项目名称:SGIS,代码行数:24,代码来源:QuadTree.cs


注:本文中的IGeometry.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。