示例#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));
 }