private IPolygon GetResult()
            {
                IGeometryFactory  gf        = _poly.Factory;
                ILinearRing       shell     = (ILinearRing)_poly.ExteriorRing;
                IPreparedGeometry shellPrep = PreparedGeometryFactory.Prepare(gf.CreatePolygon(shell));

                IList <IGeometry> holes = new List <IGeometry>();

                for (int i = 0; i < _poly.NumInteriorRings; i++)
                {
                    IGeometry hole = _poly.GetInteriorRingN(i);
                    if (shellPrep.Covers(hole))
                    {
                        holes.Add(hole);
                    }
                }
                // all holes valid, so return original
                if (holes.Count == _poly.NumInteriorRings)
                {
                    return(_poly);
                }

                // return new polygon with covered holes only
                ILinearRing[] arr    = GeometryFactory.ToLinearRingArray(holes);
                IPolygon      result = gf.CreatePolygon(shell, arr);

                return(result);
            }
示例#2
0
 protected virtual SpatialRelation Relate(IGeometry oGeom)
 {
     //see http://docs.geotools.org/latest/userguide/library/jts/dim9.html#preparedgeometry
     if (oGeom is GeoAPI.Geometries.IPoint) // TODO: This may not be the correct data type....
     {
         if (preparedGeometry != null)
         {
             return(preparedGeometry.Disjoint(oGeom) ? SpatialRelation.DISJOINT : SpatialRelation.CONTAINS);
         }
         return(geom.Disjoint(oGeom) ? SpatialRelation.DISJOINT : SpatialRelation.CONTAINS);
     }
     if (preparedGeometry == null)
     {
         return(IntersectionMatrixToSpatialRelation(geom.Relate(oGeom)));
     }
     else if (preparedGeometry.Covers(oGeom))
     {
         return(SpatialRelation.CONTAINS);
     }
     else if (preparedGeometry.CoveredBy(oGeom))
     {
         return(SpatialRelation.WITHIN);
     }
     else if (preparedGeometry.Intersects(oGeom))
     {
         return(SpatialRelation.INTERSECTS);
     }
     return(SpatialRelation.DISJOINT);
 }
示例#3
0
        private static void CheckCovers(IPreparedGeometry pg, IGeometry g2)
        {
            bool pgResult = pg.Covers(g2);
            bool expected = pg.Geometry.Covers(g2);

            if (pgResult != expected)
            {
                throw new InvalidOperationException("PreparedGeometry.covers result does not match expected");
            }

            // System.out.println("Results match!");
        }
示例#4
0
 public void RunPreparedPolygon()
 {
     for (int i = 0; i < NUM_ITER; i++)
     {
         prepGeom = (new PreparedGeometryFactory()).Create(sinePoly);
         foreach (var pt in testPoints)
         {
             prepGeom.Covers(pt);
             //prepGeom.contains(pt);
         }
     }
 }
        private static void CheckCovers(IPreparedGeometry pg, IGeometry g2)
        {
            var pgResult = pg.Covers(g2);
            var expected = pg.Geometry.Covers(g2);

            if (pgResult != expected)
                throw new InvalidOperationException("PreparedGeometry.covers result does not match expected");

            //		System.out.println("Results match!");
        }