コード例 #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));
        }
コード例 #2
0
            public Location Locate(Coordinate p)
            {
                var rcc    = new RayCrossingCounter(p);
                var filter = new RayCrossingSegmentFilter(rcc);

                geom.Apply(filter);
                return(rcc.Location);
            }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        ///<summary>
        /// Determines the <see cref="Location"/> of a point in an areal <see cref="IGeometry"/>.
        ///</summary>
        /// <param name="p">The point to test</param>
        /// <returns>The location of the point in the geometry
        /// </returns>
        public Location Locate(Coordinate p)
        {
            var rcc = new RayCrossingCounter(p);

            var visitor = new SegmentVisitor(rcc);

            _index.Query(p.Y, p.Y, visitor);

            /*
             * // MD - slightly slower alternative
             * List segs = index.query(p.y, p.y);
             * countSegs(rcc, segs);
             */

            return(rcc.Location);
        }
コード例 #7
0
        /// <summary>
        /// Determines the <see cref="Location"/> of a point in an areal <see cref="Geometry"/>.
        /// </summary>
        /// <param name="p">The point to test</param>
        /// <returns>The location of the point in the geometry
        /// </returns>
        public Location Locate(Coordinate p)
        {
            // avoid calling synchronized method improves performance
            if (_index == null)
            {
                CreateIndex();
            }

            var rcc = new RayCrossingCounter(p);

            var visitor = new SegmentVisitor(rcc);

            _index.Query(p.Y, p.Y, visitor);

            /*
             * // MD - slightly slower alternative
             * List segs = index.query(p.y, p.y);
             * countSegs(rcc, segs);
             */

            return(rcc.Location);
        }
コード例 #8
0
        /// <summary>
        /// Determines the <see cref="Location"/> of a point in an areal <see cref="Geometry"/>.
        /// </summary>
        /// <param name="p">The point to test</param>
        /// <returns>The location of the point in the geometry
        /// </returns>
        public Location Locate(Coordinate p)
        {
            if (_index == null)
            {
                _index = new IntervalIndexedGeometry(_geom);
                // no need to hold onto geom
                _geom = null;
            }
            var rcc = new RayCrossingCounter(p);

            var visitor = new SegmentVisitor(rcc);

            _index.Query(p.Y, p.Y, visitor);

            /*
             * // MD - slightly slower alternative
             * List segs = index.query(p.y, p.y);
             * countSegs(rcc, segs);
             */

            return(rcc.Location);
        }
コード例 #9
0
        /**
         * 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));
            }
        }
コード例 #10
0
 public SegmentVisitor(RayCrossingCounter counter)
 {
     _counter = counter;
 }
コード例 #11
0
 public RayCrossingSegmentFilter(RayCrossingCounter rcc)
 {
     this.rcc = rcc;
 }
コード例 #12
0
        protected override void RunPtInRing(Location expectedLoc, Coordinate pt, String wkt)
        {
            IGeometry geom = reader.Read(wkt);

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