fn contains(point: &Coordinates, points: &[Coordinates]) -> bool {
    // Find the horizontal line equation that passes through the point.
    // Use the Ax + By = C format and depict as a tuple of (A, B, C).

    let point_horizon_eqn: (f64, f64, f64) = (0.0, 1.0, point.lon);
    let points_len = points.len();
    let mut retval = false;
    if points.len() < 3 {
        panic!("The supplied fence points should be more than 3 for creating proper polygon");
    }
    let line_eq: Vec<(f64, f64, f64)> = get_lineequation(&points, points_len);
    let mut intersection_left: Vec<Coordinates> = Vec::new();
    let mut intersection_right: Vec<Coordinates> = Vec::new();
    for (_pos, coord) in line_eq.iter().enumerate() {
        // find_intersect() function uses Cramers rule to verify if the line intersects or not.
        let det1 = (coord.0 * point_horizon_eqn.1) - (coord.1 * point_horizon_eqn.0);
        let detx = (coord.2 * point_horizon_eqn.1) - (coord.1 * point_horizon_eqn.2);
        let dety = (coord.0 * point_horizon_eqn.2) - (coord.2 * point_horizon_eqn.0);

        if det1 != 0.0 {
            let point_coordinate = Coordinates::new(detx / det1, dety / det1);
            let point1 = &points[_pos];
            let point2 = &(points[((_pos + 1) % points_len)]);
            let check_inbound: bool = check_inbounds(&point_coordinate, point1, point2);
            if point_coordinate.lat < point.lat {
                if !vec_contains(&point_coordinate, &intersection_left) && check_inbound {
                    intersection_left.push(point_coordinate);
                }
            } else if !vec_contains(&point_coordinate, &intersection_right) && check_inbound {
                intersection_right.push(point_coordinate);
            }
        }
    }

    if (!intersection_left.is_empty() && !intersection_right.is_empty())
        && (intersection_left.len() % 2 == 1 && intersection_right.len() % 2 == 1)
    {
        retval = true;
    }
    retval
}
///
/// This method checks if a particular coordinate is within the polygon fence.
/// This method uses Cramer's rule in verifying if a line drawn from a point is intersecting
/// within the boundaries of the created fence.
/// It returns boolean true if the coordinates are within the fence and
/// false if the coordinates are outside the fence.
///
This method checks if a particular coordinate is within the polygon fence.
This method uses Cramer's rule in verifying if a line drawn from a point is intersecting
within the boundaries of the created fence.
It returns boolean true if the coordinates are within the fence and
false if the coordinates are outside the fence.
This method checks if a particular coordinate is within the polygon fence . This method uses Cramer ' s rule in verifying if a line drawn from a point is intersecting within the boundaries of the created fence . It returns boolean true if the coordinates are within the fence and false if the coordinates are outside the fence .
fn contains(point: &Coordinates, points: &[Coordinates]) -> bool {
    // Find the horizontal line equation that passes through the point.
    // Use the Ax + By = C format and depict as a tuple of (A, B, C).
    let point_horizon_eqn: (f64, f64, f64) = (0.0, 1.0, point.lon);
    let points_len = points.len();
    let mut retval = false;
    if points.len() < 3 {
        panic!("The supplied fence points should be more than 3 for creating proper polygon");
    }
    let line_eq: Vec<(f64, f64, f64)> = get_lineequation(&points, points_len);
    let mut intersection_left: Vec<Coordinates> = Vec::new();
    let mut intersection_right: Vec<Coordinates> = Vec::new();
    for (_pos, coord) in line_eq.iter().enumerate() {
        // find_intersect() function uses Cramers rule to verify if the line intersects or not.
        let det1 = (coord.0 * point_horizon_eqn.1) - (coord.1 * point_horizon_eqn.0);
        let detx = (coord.2 * point_horizon_eqn.1) - (coord.1 * point_horizon_eqn.2);
        let dety = (coord.0 * point_horizon_eqn.2) - (coord.2 * point_horizon_eqn.0);
        if det1 != 0.0 {
            let point_coordinate = Coordinates::new(detx / det1, dety / det1);
            let point1 = &points[_pos];
            let point2 = &(points[((_pos + 1) % points_len)]);
            let check_inbound: bool = check_inbounds(&point_coordinate, point1, point2);
            if point_coordinate.lat < point.lat {
                if !vec_contains(&point_coordinate, &intersection_left) && check_inbound {
                    intersection_left.push(point_coordinate);
                }
            } else if !vec_contains(&point_coordinate, &intersection_right) && check_inbound {
                intersection_right.push(point_coordinate);
            }
        }
    }
    if (!intersection_left.is_empty() && !intersection_right.is_empty())
        && (intersection_left.len() % 2 == 1 && intersection_right.len() % 2 == 1)
    {
        retval = true;
    }
    retval
}
fn contains ( point : & Coordinates , points : & [ Coordinates ] ) -> bool { // Find the horizontal line equation that passes through the point. // Use the Ax + By = C format and depict as a tuple of (A, B, C). let point_horizon_eqn : ( f64 , f64 , f64 ) = ( 0.0 , 1.0 , point . lon ) ; let points_len = points . len ( ) ; let mut retval = false ; if points . len ( ) < 3 { panic ! ( " " ) ; } let line_eq : Vec < ( f64 , f64 , f64 ) > = get_lineequation ( & points , points_len ) ; let mut intersection_left : Vec < Coordinates > = Vec :: new ( ) ; let mut intersection_right : Vec < Coordinates > = Vec :: new ( ) ; for ( _pos , coord ) in line_eq . iter ( ) . enumerate ( ) { // find_intersect() function uses Cramers rule to verify if the line intersects or not. let det1 = ( coord . 0 * point_horizon_eqn . 1 ) - ( coord . 1 * point_horizon_eqn . 0 ) ; let detx = ( coord . 2 * point_horizon_eqn . 1 ) - ( coord . 1 * point_horizon_eqn . 2 ) ; let dety = ( coord . 0 * point_horizon_eqn . 2 ) - ( coord . 2 * point_horizon_eqn . 0 ) ; if det1 != 0.0 { let point_coordinate = Coordinates :: new ( detx / det1 , dety / det1 ) ; let point1 = & points [ _pos ] ; let point2 = & ( points [ ( ( _pos + 1 ) % points_len ) ] ) ; let check_inbound : bool = check_inbounds ( & point_coordinate , point1 , point2 ) ; if point_coordinate . lat < point . lat { if ! vec_contains ( & point_coordinate , & intersection_left ) && check_inbound { intersection_left . push ( point_coordinate ) ; } } else if ! vec_contains ( & point_coordinate , & intersection_right ) && check_inbound { intersection_right . push ( point_coordinate ) ; } } } if ( ! intersection_left . is_empty ( ) && ! intersection_right . is_empty ( ) ) && ( intersection_left . len ( ) % 2 == 1 && intersection_right . len ( ) % 2 == 1 ) { retval = true ; } retval }
This method checks if a particular coordinate is within the polygon fence.
This method checks if a particular coordinate is within the polygon fence .
point
&Coordinates
points
&[Coordinates]
point
&Coordinates
points
&[Coordinates]