private static int Wind(GeographicalPoint location, Edge edge, Position position) { if (edge.RelativePositionOf(location) != position) { return(0); } return(1); }
public bool LocationInRange(GeographicalPoint location, Orientation orientation) { if (orientation == Orientation.Ascending) { return(_endPoint.Latitude > location.Latitude); } return(_endPoint.Latitude <= location.Latitude); }
private static int DescendingIntersection(GeographicalPoint location, Edge edge) { if (edge.AscendingRelativeTo(location)) { return(0); } if (!edge.LocationInRange(location, Orientation.Descending)) { return(0); } return(Wind(location, edge, Position.Right)); }
public bool Contains(GeographicalPoint location) { GeographicalPoint[] polygonPointsWithClosure = PolygonPointsWithClosure(); int windingNumber = 0; for (int pointIndex = 0; pointIndex < polygonPointsWithClosure.Length - 1; pointIndex++) { Edge edge = new Edge(polygonPointsWithClosure[pointIndex], polygonPointsWithClosure[pointIndex + 1]); windingNumber += AscendingIntersection(location, edge); windingNumber -= DescendingIntersection(location, edge); } return(windingNumber != 0); }
public Position RelativePositionOf(GeographicalPoint location) { double positionCalculation = (_endPoint.Longitude - _startPoint.Longitude) * (location.Latitude - _startPoint.Latitude) - (location.Longitude - _startPoint.Longitude) * (_endPoint.Latitude - _startPoint.Latitude); if (positionCalculation > 0) { return(Position.Left); } if (positionCalculation < 0) { return(Position.Right); } return(Position.Center); }
public Edge(GeographicalPoint startPoint, GeographicalPoint endPoint) { _startPoint = startPoint; _endPoint = endPoint; }
public bool AscendingRelativeTo(GeographicalPoint location) { return(_startPoint.Latitude <= location.Latitude); }