lib/turf/boolean_point_on_line.rb
# Takes a Point and a LineString and determines if the point resides one the lineString.
Takes a Point and a LineString and determines if the point resides one the lineString.
Takes a Point and a LineString and determines if the point resides one the lineString .
def is_point_on_line_segment(line_segment_start, line_segment_end, point, exclude_boundary)
    x = point[0];
    y = point[1];
    x1 = line_segment_start[0];
    y1 = line_segment_start[1];
    x2 = line_segment_end[0];
    y2 = line_segment_end[1];
    dxc = point[0] - x1;
    dyc = point[1] - y1;
    dxl = x2 - x1;
    dyl = y2 - y1;
    cross = dxc * dyl - dyc * dxl;
    return false if cross != 0
    if !exclude_boundary
      if dxl.abs >= dyl.abs
        return dxl > 0 ? x1 <= x && x <= x2 : x2 <= x && x <= x1;
      end
      return dyl > 0 ? y1 <= y && y <= y2 : y2 <= y && y <= y1;
    end
    return false;
  end
def is_point_on_line_segment ( line_segment_start , line_segment_end , point , exclude_boundary ) x = point [ 0 ] ; y = point [ 1 ] ; x1 = line_segment_start [ 0 ] ; y1 = line_segment_start [ 1 ] ; x2 = line_segment_end [ 0 ] ; y2 = line_segment_end [ 1 ] ; dxc = point [ 0 ] - x1 ; dyc = point [ 1 ] - y1 ; dxl = x2 - x1 ; dyl = y2 - y1 ; cross = dxc * dyl - dyc * dxl ; return false if cross != 0 if ! exclude_boundary if dxl . abs >= dyl . abs return dxl > 0 ? x1 <= x && x <= x2 : x2 <= x && x <= x1 ; end return dyl > 0 ? y1 <= y && y <= y2 : y2 <= y && y <= y1 ; end return false ; end
Takes a Point and a LineString and determines if the point resides one the lineString.
Takes a Point and a LineString and determines if the point resides one the lineString .
line_segment_start
line_segment_end
point
exclude_boundary