// these are special implementations, all others delegate to the topo-graph.
 internal static com.epl.geometry.Geometry PointMinusPolygon_(com.epl.geometry.Point point, com.epl.geometry.Polygon polygon, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
 {
     com.epl.geometry.PolygonUtils.PiPResult result = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, point, tolerance);
     if (result == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside)
     {
         return(point);
     }
     return(point.CreateInstance());
 }
        internal static com.epl.geometry.Geometry MultiPointMinusPolygon_(com.epl.geometry.MultiPoint multi_point, com.epl.geometry.Polygon polygon, double tolerance, com.epl.geometry.ProgressTracker progress_tracker)
        {
            com.epl.geometry.Envelope2D env = new com.epl.geometry.Envelope2D();
            polygon.QueryEnvelope2D(env);
            env.Inflate(tolerance, tolerance);
            int  point_count     = multi_point.GetPointCount();
            bool b_found_covered = false;

            bool[] covered = new bool[point_count];
            for (int i = 0; i < point_count; i++)
            {
                covered[i] = false;
            }
            com.epl.geometry.Point2D pt = new com.epl.geometry.Point2D();
            for (int i_1 = 0; i_1 < point_count; i_1++)
            {
                multi_point.GetXY(i_1, pt);
                if (!env.Contains(pt))
                {
                    continue;
                }
                com.epl.geometry.PolygonUtils.PiPResult result = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(polygon, pt, tolerance);
                if (result == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside)
                {
                    continue;
                }
                b_found_covered = true;
                covered[i_1]    = true;
            }
            if (!b_found_covered)
            {
                return(multi_point);
            }
            com.epl.geometry.MultiPoint new_multipoint = (com.epl.geometry.MultiPoint)multi_point.CreateInstance();
            for (int i_2 = 0; i_2 < point_count; i_2++)
            {
                if (!covered[i_2])
                {
                    new_multipoint.Add(multi_point, i_2, i_2 + 1);
                }
            }
            return(new_multipoint);
        }
 private static int QuickTest2DPolygonPoint(com.epl.geometry.Polygon geomA, com.epl.geometry.Point2D ptB, double tolerance)
 {
     com.epl.geometry.PolygonUtils.PiPResult pipres = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(geomA, ptB, tolerance);
     // this method uses the accelerator if available
     if (pipres == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside)
     {
         return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Disjoint);
     }
     // clementini's disjoint
     if (pipres == com.epl.geometry.PolygonUtils.PiPResult.PiPInside)
     {
         return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Contains);
     }
     // clementini's contains
     if (pipres == com.epl.geometry.PolygonUtils.PiPResult.PiPBoundary)
     {
         return((int)com.epl.geometry.OperatorInternalRelationUtils.Relation.Touches);
     }
     // clementini's touches
     throw com.epl.geometry.GeometryException.GeometryInternalError();
 }
Example #4
0
        internal virtual bool RgHelper(com.epl.geometry.RasterizedGeometry2D rg, com.epl.geometry.MultiPath mp)
        {
            com.epl.geometry.SegmentIterator iter = mp.QuerySegmentIterator();
            while (iter.NextPath())
            {
                while (iter.HasNextSegment())
                {
                    com.epl.geometry.Segment seg = iter.NextSegment();
                    int count = 20;
                    for (int i = 0; i < count; i++)
                    {
                        double t = (1.0 * i / count);
                        com.epl.geometry.Point2D pt = seg.GetCoord2D(t);
                        com.epl.geometry.RasterizedGeometry2D.HitType hit = rg.QueryPointInGeometry(pt.x, pt.y);
                        if (hit != com.epl.geometry.RasterizedGeometry2D.HitType.Border)
                        {
                            return(false);
                        }
                    }
                }
            }
            if (mp.GetType() != com.epl.geometry.Geometry.Type.Polygon)
            {
                return(true);
            }
            com.epl.geometry.Polygon    poly = (com.epl.geometry.Polygon)mp;
            com.epl.geometry.Envelope2D env  = new com.epl.geometry.Envelope2D();
            poly.QueryEnvelope2D(env);
            int count_1 = 100;

            for (int iy = 0; iy < count_1; iy++)
            {
                double ty = 1.0 * iy / count_1;
                double y  = env.ymin * (1.0 - ty) + ty * env.ymax;
                for (int ix = 0; ix < count_1; ix++)
                {
                    double tx = 1.0 * ix / count_1;
                    double x  = env.xmin * (1.0 - tx) + tx * env.xmax;
                    com.epl.geometry.RasterizedGeometry2D.HitType hit = rg.QueryPointInGeometry(x, y);
                    com.epl.geometry.PolygonUtils.PiPResult       res = com.epl.geometry.PolygonUtils.IsPointInPolygon2D(poly, new com.epl.geometry.Point2D(x, y), 0);
                    if (res == com.epl.geometry.PolygonUtils.PiPResult.PiPInside)
                    {
                        bool bgood = (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Border || hit == com.epl.geometry.RasterizedGeometry2D.HitType.Inside);
                        if (!bgood)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (res == com.epl.geometry.PolygonUtils.PiPResult.PiPOutside)
                        {
                            bool bgood = (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Border || hit == com.epl.geometry.RasterizedGeometry2D.HitType.Outside);
                            if (!bgood)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            bool bgood = (hit == com.epl.geometry.RasterizedGeometry2D.HitType.Border);
                            if (!bgood)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            return(true);
        }