public final class TurfConversion
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static com.mapbox.geojson.FeatureCollection |
combine(com.mapbox.geojson.FeatureCollection originalFeatureCollection)
Combines a FeatureCollection of geometries and returns
a
FeatureCollection with "Multi-" geometries in it. |
static double |
convertLength(double distance,
java.lang.String originalUnit)
Converts a distance to the default units.
|
static double |
convertLength(double distance,
java.lang.String originalUnit,
java.lang.String finalUnit)
Converts a distance to a different unit specified.
|
static double |
degreesToRadians(double degrees)
Converts an angle in degrees to radians.
|
static com.mapbox.geojson.FeatureCollection |
explode(com.mapbox.geojson.Feature feature)
Takes a
Feature and
returns its position as a Point objects. |
static com.mapbox.geojson.FeatureCollection |
explode(com.mapbox.geojson.FeatureCollection featureCollection)
Takes a
FeatureCollection and
returns all positions as Point objects. |
static double |
lengthToDegrees(double distance,
java.lang.String units)
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres,
feet.
|
static double |
lengthToRadians(double distance)
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into
radians.
|
static double |
lengthToRadians(double distance,
java.lang.String units)
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into
radians.
|
static com.mapbox.geojson.FeatureCollection |
multiPolygonToLine(com.mapbox.geojson.Feature feature)
Takes a
Feature that contains MultiPolygon and
covert it to a FeatureCollection that contains list of Feature
of LineString or MultiLineString . |
static com.mapbox.geojson.FeatureCollection |
multiPolygonToLine(com.mapbox.geojson.Feature feature,
com.google.gson.JsonObject properties)
Takes a
Feature that contains MultiPolygon and a
properties JsonObject and
covert it to a FeatureCollection that contains
list of Feature of LineString or MultiLineString . |
static com.mapbox.geojson.Feature |
polygonToLine(com.mapbox.geojson.Feature feature)
Takes a
Feature that contains Polygon and
covert it to a Feature that contains LineString or MultiLineString . |
static com.mapbox.geojson.Feature |
polygonToLine(com.mapbox.geojson.Feature feature,
com.google.gson.JsonObject properties)
Takes a
Feature that contains Polygon and a properties JsonObject and
covert it to a Feature that contains LineString or MultiLineString . |
static com.mapbox.geojson.FeatureCollection |
polygonToLine(com.mapbox.geojson.MultiPolygon multiPolygon)
Takes a
MultiPolygon and
covert it to a FeatureCollection that contains list
of Feature of LineString or MultiLineString . |
static com.mapbox.geojson.FeatureCollection |
polygonToLine(com.mapbox.geojson.MultiPolygon multiPolygon,
com.google.gson.JsonObject properties)
Takes a
MultiPolygon and a properties JsonObject and
covert it to a FeatureCollection that contains list
of Feature of LineString or MultiLineString . |
static com.mapbox.geojson.Feature |
polygonToLine(com.mapbox.geojson.Polygon polygon)
Takes a
Polygon and
covert it to a Feature that contains LineString or MultiLineString . |
static com.mapbox.geojson.Feature |
polygonToLine(com.mapbox.geojson.Polygon polygon,
com.google.gson.JsonObject properties)
Takes a
Polygon and a properties JsonObject and
covert it to a Feature that contains LineString or MultiLineString . |
static double |
radiansToDegrees(double radians)
Converts an angle in radians to degrees.
|
static double |
radiansToLength(double radians)
Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly
unit.
|
static double |
radiansToLength(double radians,
java.lang.String units)
Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly
unit.
|
public static double lengthToDegrees(double distance, java.lang.String units)
distance
- in real unitsunits
- can be degrees, radians, miles, or kilometers inches, yards, metres, meters,
kilometres, kilometers.public static double degreesToRadians(double degrees)
degrees
- angle between 0 and 360 degreespublic static double radiansToDegrees(double radians)
radians
- angle in radianspublic static double radiansToLength(double radians)
radians
- a double using unit radianpublic static double radiansToLength(double radians, @NonNull java.lang.String units)
radians
- a double using unit radianunits
- pass in one of the units defined in TurfConstants.TurfUnitCriteria
public static double lengthToRadians(double distance)
distance
- double representing a distance value assuming the distance units is in
kilometerspublic static double lengthToRadians(double distance, @NonNull java.lang.String units)
distance
- double representing a distance valueunits
- pass in one of the units defined in TurfConstants.TurfUnitCriteria
public static double convertLength(double distance, @NonNull java.lang.String originalUnit)
convertLength(double, String, String)
to specify a unit to convert to.distance
- double representing a distance valueoriginalUnit
- of the distance, must be one of the units defined in
TurfConstants.TurfUnitCriteria
public static double convertLength(double distance, @NonNull java.lang.String originalUnit, @Nullable java.lang.String finalUnit)
distance
- the distance to be convertedoriginalUnit
- of the distance, must be one of the units defined in
TurfConstants.TurfUnitCriteria
finalUnit
- returned unit, TurfConstants.UNIT_DEFAULT
if not specifiedpublic static com.mapbox.geojson.FeatureCollection explode(@NonNull com.mapbox.geojson.FeatureCollection featureCollection)
FeatureCollection
and
returns all positions as Point
objects.featureCollection
- a FeatureCollection
objectFeatureCollection
object with Point
objectspublic static com.mapbox.geojson.FeatureCollection explode(@NonNull com.mapbox.geojson.Feature feature)
Feature
and
returns its position as a Point
objects.feature
- a Feature
objectFeatureCollection
object with Point
objectspublic static com.mapbox.geojson.Feature polygonToLine(@NonNull com.mapbox.geojson.Feature feature)
Feature
that contains Polygon
and
covert it to a Feature
that contains LineString
or MultiLineString
.feature
- a Feature
object that contains Polygon
Feature
object that contains LineString
or MultiLineString
public static com.mapbox.geojson.Feature polygonToLine(@NonNull com.mapbox.geojson.Feature feature, @Nullable com.google.gson.JsonObject properties)
Feature
that contains Polygon
and a properties JsonObject
and
covert it to a Feature
that contains LineString
or MultiLineString
.feature
- a Feature
object that contains Polygon
properties
- a JsonObject
that represents a feature's propertiesFeature
object that contains LineString
or MultiLineString
public static com.mapbox.geojson.Feature polygonToLine(@NonNull com.mapbox.geojson.Polygon polygon)
Polygon
and
covert it to a Feature
that contains LineString
or MultiLineString
.polygon
- a Polygon
objectFeature
object that contains LineString
or MultiLineString
public static com.mapbox.geojson.FeatureCollection polygonToLine(@NonNull com.mapbox.geojson.MultiPolygon multiPolygon)
MultiPolygon
and
covert it to a FeatureCollection
that contains list
of Feature
of LineString
or MultiLineString
.multiPolygon
- a MultiPolygon
objectFeatureCollection
object that contains
list of Feature
of LineString
or MultiLineString
public static com.mapbox.geojson.Feature polygonToLine(@NonNull com.mapbox.geojson.Polygon polygon, @Nullable com.google.gson.JsonObject properties)
Polygon
and a properties JsonObject
and
covert it to a Feature
that contains LineString
or MultiLineString
.polygon
- a Polygon
objectproperties
- a JsonObject
that represents a feature's propertiesFeature
object that contains LineString
or MultiLineString
public static com.mapbox.geojson.FeatureCollection polygonToLine(@NonNull com.mapbox.geojson.MultiPolygon multiPolygon, @Nullable com.google.gson.JsonObject properties)
MultiPolygon
and a properties JsonObject
and
covert it to a FeatureCollection
that contains list
of Feature
of LineString
or MultiLineString
.multiPolygon
- a MultiPolygon
objectproperties
- a JsonObject
that represents a feature's propertiesFeatureCollection
object that contains
list of Feature
of LineString
or MultiLineString
public static com.mapbox.geojson.FeatureCollection multiPolygonToLine(@NonNull com.mapbox.geojson.Feature feature)
Feature
that contains MultiPolygon
and
covert it to a FeatureCollection
that contains list of Feature
of LineString
or MultiLineString
.feature
- a Feature
object that contains Polygon
FeatureCollection
object that contains list of Feature
of LineString
or MultiLineString
public static com.mapbox.geojson.FeatureCollection multiPolygonToLine(@NonNull com.mapbox.geojson.Feature feature, @Nullable com.google.gson.JsonObject properties)
Feature
that contains MultiPolygon
and a
properties JsonObject
and
covert it to a FeatureCollection
that contains
list of Feature
of LineString
or MultiLineString
.feature
- a Feature
object that contains MultiPolygon
properties
- a JsonObject
that represents a feature's propertiesFeatureCollection
object that contains
list of Feature
of LineString
or MultiLineString
public static com.mapbox.geojson.FeatureCollection combine(@NonNull com.mapbox.geojson.FeatureCollection originalFeatureCollection)
FeatureCollection
with "Multi-" geometries in it.
If the original FeatureCollection parameter has Point
(s)
and/or MultiPoint
s), the returned
FeatureCollection will include a MultiPoint
object.
If the original FeatureCollection parameter has
LineString
(s) and/or MultiLineString
s), the returned
FeatureCollection will include a MultiLineString
object.
If the original FeatureCollection parameter has
Polygon
(s) and/or MultiPolygon
s), the returned
FeatureCollection will include a MultiPolygon
object.originalFeatureCollection
- a FeatureCollection
FeatureCollection
with a "Multi-" geometry
or "Multi-" geometries.