예제 #1
0
            public bool LocationInRange(AZGeoPoint location, Orientation orientation)
            {
                if (orientation == Orientation.Ascending)
                {
                    return(_endPoint.Lat > location.Lat);
                }

                return(_endPoint.Lat <= location.Lat);
            }
예제 #2
0
        private static int Wind(AZGeoPoint location, AZEdge edge, Position position)
        {
            if (edge.RelativePositionOf(location) != position)
            {
                return(0);
            }

            return(1);
        }
예제 #3
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));
        }
예제 #4
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);
        }
예제 #5
0
            public Position RelativePositionOf(AZGeoPoint location)
            {
                double positionCalculation =
                    (_endPoint.Lon - _startPoint.Lon) * (location.Lat - _startPoint.Lat) -
                    (location.Lon - _startPoint.Lon) * (_endPoint.Lat - _startPoint.Lat);

                if (positionCalculation > 0)
                {
                    return(Position.Left);
                }

                if (positionCalculation < 0)
                {
                    return(Position.Right);
                }

                return(Position.Center);
            }
예제 #6
0
 public bool AscendingRelativeTo(AZGeoPoint location)
 {
     return(_startPoint.Lat <= location.Lat);
 }
예제 #7
0
 public AZEdge(AZGeoPoint startPoint, AZGeoPoint endPoint)
 {
     _startPoint = startPoint;
     _endPoint   = endPoint;
 }
예제 #8
0
 public static AZGeoPoint ToWgs84(this AZGeoPoint point)
 {
     return(AZWGSConverter.ToWgs84Point(point.Lat, point.Lon));
 }