Class TurfMisc

java.lang.Object
com.mapbox.turf.TurfMisc

public final class TurfMisc extends Object
Class contains all the miscellaneous methods that Turf can perform.
Since:
1.2.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.mapbox.geojson.LineString
    lineSlice(com.mapbox.geojson.Point startPt, com.mapbox.geojson.Point stopPt, com.mapbox.geojson.Feature line)
    Takes a line, a start Point, and a stop point and returns the line in between those points.
    static com.mapbox.geojson.LineString
    lineSlice(com.mapbox.geojson.Point startPt, com.mapbox.geojson.Point stopPt, com.mapbox.geojson.LineString line)
    Takes a line, a start Point, and a stop point and returns the line in between those points.
    static com.mapbox.geojson.LineString
    lineSliceAlong(com.mapbox.geojson.Feature line, double startDist, double stopDist, String units)
    Takes a LineString, a specified distance along the line to a start Point, and a specified distance along the line to a stop point and returns a subsection of the line in-between those points.
    static com.mapbox.geojson.LineString
    lineSliceAlong(com.mapbox.geojson.LineString line, double startDist, double stopDist, String units)
    Takes a LineString, a specified distance along the line to a start Point, and a specified distance along the line to a stop point, returns a subsection of the line in-between those points.
    static com.mapbox.geojson.Feature
    nearestPointOnLine(com.mapbox.geojson.Point pt, List<com.mapbox.geojson.Point> coords)
    Takes a Point and a LineString and calculates the closest Point on the LineString.
    static com.mapbox.geojson.Feature
    nearestPointOnLine(com.mapbox.geojson.Point pt, List<com.mapbox.geojson.Point> coords, String units)
    Takes a Point and a LineString and calculates the closest Point on the LineString.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • lineSlice

      @NonNull public static com.mapbox.geojson.LineString lineSlice(@NonNull com.mapbox.geojson.Point startPt, @NonNull com.mapbox.geojson.Point stopPt, @NonNull com.mapbox.geojson.Feature line)
      Takes a line, a start Point, and a stop point and returns the line in between those points.
      Parameters:
      startPt - Starting point.
      stopPt - Stopping point.
      line - Line to slice.
      Returns:
      Sliced line.
      Throws:
      TurfException - signals that a Turf exception of some sort has occurred.
      Since:
      1.2.0
      See Also:
    • lineSlice

      @NonNull public static com.mapbox.geojson.LineString lineSlice(@NonNull com.mapbox.geojson.Point startPt, @NonNull com.mapbox.geojson.Point stopPt, @NonNull com.mapbox.geojson.LineString line)
      Takes a line, a start Point, and a stop point and returns the line in between those points.
      Parameters:
      startPt - used for calculating the lineSlice
      stopPt - used for calculating the lineSlice
      line - geometry that should be sliced
      Returns:
      a sliced LineString
      Since:
      1.2.0
      See Also:
    • lineSliceAlong

      @NonNull public static com.mapbox.geojson.LineString lineSliceAlong(@NonNull com.mapbox.geojson.Feature line, double startDist, double stopDist, @NonNull String units)
      Takes a LineString, a specified distance along the line to a start Point, and a specified distance along the line to a stop point and returns a subsection of the line in-between those points.

      This can be useful for extracting only the part of a route between two distances.

      Parameters:
      line - input line
      startDist - distance along the line to starting point
      stopDist - distance along the line to ending point
      units - one of the units found inside TurfConstants.TurfUnitCriteria can be degrees, radians, miles, or kilometers
      Returns:
      sliced line
      Throws:
      TurfException - signals that a Turf exception of some sort has occurred.
      Since:
      3.1.0
      See Also:
    • lineSliceAlong

      @NonNull public static com.mapbox.geojson.LineString lineSliceAlong(@NonNull com.mapbox.geojson.LineString line, double startDist, double stopDist, @NonNull String units)

      Takes a LineString, a specified distance along the line to a start Point, and a specified distance along the line to a stop point, returns a subsection of the line in-between those points.

      This can be useful for extracting only the part of a route between two distances.

      Parameters:
      line - input line
      startDist - distance along the line to starting point
      stopDist - distance along the line to ending point
      units - one of the units found inside TurfConstants.TurfUnitCriteria can be degrees, radians, miles, or kilometers
      Returns:
      sliced line
      Throws:
      TurfException - signals that a Turf exception of some sort has occurred.
      Since:
      3.1.0
      See Also:
    • nearestPointOnLine

      @NonNull public static com.mapbox.geojson.Feature nearestPointOnLine(@NonNull com.mapbox.geojson.Point pt, @NonNull List<com.mapbox.geojson.Point> coords)
      Takes a Point and a LineString and calculates the closest Point on the LineString.
      Parameters:
      pt - point to snap from
      coords - line to snap to
      Returns:
      closest point on the line to point
      Since:
      1.3.0
    • nearestPointOnLine

      @NonNull public static com.mapbox.geojson.Feature nearestPointOnLine(@NonNull com.mapbox.geojson.Point pt, @NonNull List<com.mapbox.geojson.Point> coords, @Nullable String units)
      Takes a Point and a LineString and calculates the closest Point on the LineString.
      Parameters:
      pt - point to snap from
      coords - line to snap to
      units - one of the units found inside TurfConstants.TurfUnitCriteria can be degrees, radians, miles, or kilometers
      Returns:
      closest point on the line to point
      Since:
      4.9.0