Package com.mapbox.turf
Class TurfMisc
java.lang.Object
com.mapbox.turf.TurfMisc
Class contains all the miscellaneous methods that Turf can perform.
- Since:
- 1.2.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.mapbox.geojson.LineStringlineSlice(com.mapbox.geojson.Point startPt, com.mapbox.geojson.Point stopPt, com.mapbox.geojson.Feature line) Takes a line, a startPoint, and a stop point and returns the line in between those points.static com.mapbox.geojson.LineStringlineSlice(com.mapbox.geojson.Point startPt, com.mapbox.geojson.Point stopPt, com.mapbox.geojson.LineString line) Takes a line, a startPoint, and a stop point and returns the line in between those points.static com.mapbox.geojson.LineStringlineSliceAlong(com.mapbox.geojson.Feature line, double startDist, double stopDist, String units) Takes aLineString, a specified distance along the line to a startPoint, 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.LineStringlineSliceAlong(com.mapbox.geojson.LineString line, double startDist, double stopDist, String units) Takes aLineString, a specified distance along the line to a startPoint, 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.FeaturenearestPointOnLine(com.mapbox.geojson.Point pt, List<com.mapbox.geojson.Point> coords) Takes aPointand aLineStringand calculates the closest Point on the LineString.static com.mapbox.geojson.FeaturenearestPointOnLine(com.mapbox.geojson.Point pt, List<com.mapbox.geojson.Point> coords, String units) Takes aPointand aLineStringand calculates the closest Point on the LineString.
-
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 startPoint, 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 startPoint, and a stop point and returns the line in between those points.- Parameters:
startPt- used for calculating the lineSlicestopPt- used for calculating the lineSliceline- 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 aLineString, a specified distance along the line to a startPoint, 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 linestartDist- distance along the line to starting pointstopDist- distance along the line to ending pointunits- one of the units found insideTurfConstants.TurfUnitCriteriacan 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 startPoint, 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 linestartDist- distance along the line to starting pointstopDist- distance along the line to ending pointunits- one of the units found insideTurfConstants.TurfUnitCriteriacan 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 aPointand aLineStringand calculates the closest Point on the LineString.- Parameters:
pt- point to snap fromcoords- 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 aPointand aLineStringand calculates the closest Point on the LineString.- Parameters:
pt- point to snap fromcoords- line to snap tounits- one of the units found insideTurfConstants.TurfUnitCriteriacan be degrees, radians, miles, or kilometers- Returns:
- closest point on the line to point
- Since:
- 4.9.0
-