Esempio n. 1
0
        public bool Intersects(Coordinate pt, LineString ring)
        {
            var seq     = ring.CoordinateSequence;
            var seqProj = Project(seq, _facingPlane);
            var ptProj  = Project(pt, _facingPlane);

            return(Location.Exterior != RayCrossingCounter.LocatePointInRing(ptProj, seqProj));
        }
Esempio n. 2
0
        private Location Locate(Coordinate pt, LineString ring)
        {
            var seq     = ring.CoordinateSequence;
            var seqProj = Project(seq, _facingPlane);
            var ptProj  = Project(pt, _facingPlane);

            return(RayCrossingCounter.LocatePointInRing(ptProj, seqProj));
        }
Esempio n. 3
0
        public void TestRunPtInRing4d()
        {
            var cs = new PackedCoordinateSequenceFactory(PackedCoordinateSequenceFactory.PackedType.Double)
                     .Create(new double[] {
                0.0, 0.0, 0.0, 0.0,
                10.0, 0.0, 0.0, 0.0,
                5.0, 10.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0
            }, 4, 1);

            Assert.AreEqual(Location.Interior, RayCrossingCounter.LocatePointInRing(new Coordinate(5.0, 2.0), cs));
        }
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, string wkt)
        {
            var geom = reader.Read(wkt);

            Assert.AreEqual(expectedLoc, RayCrossingCounter.LocatePointInRing(pt, geom.Coordinates));
            var poly = geom as Polygon;

            if (poly == null)
            {
                return;
            }

            Assert.AreEqual(expectedLoc, RayCrossingCounter.LocatePointInRing(pt, poly.ExteriorRing.CoordinateSequence));
        }
        /**
         * Node a LinearRing and return a MultiPolygon containing
         * <ul>
         * <li>a single Polygon if the LinearRing is simple</li>
         * <li>several Polygons if the LinearRing auto-intersects</li>
         * </ul>
         * This is used to repair auto-intersecting Polygons
         */
        private NetTopologySuite.Geometries.Geometry getArealGeometryFromLinearRing(LinearRing ring)
        {
            if (ring.IsSimple)
            {
                return(ring.Factory.CreateMultiPolygon(new Polygon[] {
                    ring.Factory.CreatePolygon(ring, EMPTY_RING_ARRAY)
                }));
            }
            else
            {
                // Node input LinearRing and extract unique segments
                ISet <LineString> lines = nodeLineString(ring.Coordinates, ring.Factory);
                lines = getSegments(lines);

                // Polygonize the line network
                Polygonizer polygonizer = new Polygonizer();
                polygonizer.Add((ICollection <NetTopologySuite.Geometries.Geometry>)lines);

                // Computes intersections to determine the status of each polygon
                ICollection <NetTopologySuite.Geometries.Geometry> geoms = new List <NetTopologySuite.Geometries.Geometry>();
                foreach (NetTopologySuite.Geometries.Geometry g in polygonizer.GetPolygons())
                {
                    Polygon    polygon  = (Polygon)g;
                    Coordinate p        = polygon.InteriorPoint.Coordinate;
                    var        location = RayCrossingCounter.LocatePointInRing(p, ring.CoordinateSequence);
                    if (location == NetTopologySuite.Geometries.Location.Interior)
                    {
                        geoms.Add(polygon);
                    }
                }
                NetTopologySuite.Geometries.Geometry unionPoly  = UnaryUnionOp.Union(geoms);
                NetTopologySuite.Geometries.Geometry unionLines = UnaryUnionOp.Union(lines).Difference(unionPoly.Boundary);
                geoms.Clear();
                decompose(unionPoly, geoms);
                decompose(unionLines, geoms);
                return(ring.Factory.BuildGeometry(geoms));
            }
        }
Esempio n. 6
0
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, String wkt)
        {
            IGeometry geom = reader.Read(wkt);

            Assert.AreEqual(expectedLoc, RayCrossingCounter.LocatePointInRing(pt, geom.Coordinates));
        }