Esempio n. 1
0
        private static int Wind(AZGeoPoint location, AZEdge edge, Position position)
        {
            if (edge.RelativePositionOf(location) != position)
            {
                return(0);
            }

            return(1);
        }
Esempio n. 2
0
        private static int DescendingIntersection(AZGeoPoint location, AZEdge edge)
        {
            if (edge.AscendingRelativeTo(location))
            {
                return(0);
            }

            if (!edge.LocationInRange(location, Orientation.Descending))
            {
                return(0);
            }

            return(Wind(location, edge, Position.Right));
        }
Esempio n. 3
0
        public bool Contains(AZGeoPoint location)
        {
            //AZGeoPoint[] polygonPointsWithClosure = PolygonPointsWithClosure();

            int windingNumber = 0;

            for (int pointIndex = 0; pointIndex < _pointsWithClosure.Length - 1; pointIndex++)
            {
                //AZEdge edge = new AZEdge(_pointsWithClosure.Span[pointIndex], _pointsWithClosure.Span[pointIndex + 1]);
                AZEdge edge = new AZEdge(_pointsWithClosure[pointIndex], _pointsWithClosure[pointIndex + 1]);
                windingNumber += AscendingIntersection(location, edge);

                windingNumber -= DescendingIntersection(location, edge);
            }

            return(windingNumber != 0);
        }