TurfConversion { public static FeatureCollection explode(@NonNull FeatureCollection featureCollection) { List<Feature> finalFeatureList = new ArrayList<>(); for (Point singlePoint : TurfMeta.coordAll(featureCollection, true)) { finalFeatureList.add(Feature.fromGeometry(singlePoint)); } return FeatureCollection.fromFeatures(finalFeatureList); } private  TurfConversion(); static double lengthToDegrees(double distance, @TurfUnitCriteria String units); static double degreesToRadians(double degrees); static double radiansToDegrees(double radians); static double radiansToLength(double radians); static double radiansToLength(double radians, @NonNull @TurfUnitCriteria String units); static double lengthToRadians(double distance); static double lengthToRadians(double distance, @NonNull @TurfUnitCriteria String units); static double convertLength(@FloatRange(from = 0) double distance,
                                     @NonNull @TurfUnitCriteria String originalUnit); static double convertLength(@FloatRange(from = 0) double distance,
                                     @NonNull @TurfUnitCriteria String originalUnit,
                                     @Nullable @TurfUnitCriteria String finalUnit); static FeatureCollection explode(@NonNull FeatureCollection featureCollection); static FeatureCollection explode(@NonNull Feature feature); static Feature polygonToLine(@NonNull Feature feature); static Feature polygonToLine(@NonNull Feature feature, @Nullable JsonObject properties); static Feature polygonToLine(@NonNull Polygon polygon); static FeatureCollection polygonToLine(@NonNull MultiPolygon multiPolygon); static Feature polygonToLine(@NonNull Polygon polygon, @Nullable JsonObject properties); static FeatureCollection polygonToLine(@NonNull MultiPolygon multiPolygon,
                                                @Nullable JsonObject properties); static FeatureCollection multiPolygonToLine(@NonNull Feature feature); static FeatureCollection multiPolygonToLine(@NonNull Feature feature,
                                                     @Nullable JsonObject properties); static FeatureCollection combine(@NonNull FeatureCollection originalFeatureCollection);  }
@Test public void explodePointSingleFeature() throws NullPointerException { Point point = Point.fromLngLat(102, 0.5); assertEquals(1, TurfConversion.explode(Feature.fromGeometry(point)).features().size()); }
@Test public void explodeMultiPointSingleFeature() throws NullPointerException { MultiPoint multiPoint = MultiPoint.fromJson(loadJsonFixture(TURF_EXPLODE_MULTI_POINT)); assertEquals(4, TurfConversion.explode(Feature.fromGeometry(multiPoint)).features().size()); }
@Test public void explodeLineStringSingleFeature() throws NullPointerException { LineString lineString = LineString.fromJson(loadJsonFixture(TURF_EXPLODE_LINESTRING)); assertEquals(4, TurfConversion.explode(Feature.fromGeometry(lineString)).features().size()); }
@Test public void explodePolygonSingleFeature() throws NullPointerException { Polygon polygon = Polygon.fromLngLats(Arrays.asList( Arrays.asList( Point.fromLngLat(0, 101), Point.fromLngLat(1, 101), Point.fromLngLat(1, 100), Point.fromLngLat(0, 100)))); assertEquals(3, TurfConversion.explode(Feature.fromGeometry(polygon)).features().size()); }
@Test public void explodeMultiLineStringSingleFeature() throws NullPointerException { MultiLineString multiLineString = MultiLineString.fromJson(loadJsonFixture(TURF_EXPLODE_MULTILINESTRING)); assertEquals(4, TurfConversion.explode(Feature.fromGeometry(multiLineString)).features().size()); }
@Test public void explodeMultiPolygonSingleFeature() throws NullPointerException { MultiPolygon multiPolygon = MultiPolygon.fromJson(loadJsonFixture(TURF_EXPLODE_MULTIPOLYGON)); assertEquals(12, TurfConversion.explode(Feature.fromGeometry(multiPolygon)).features().size()); }
@Test public void explodeGeometryCollectionSingleFeature() throws NullPointerException { GeometryCollection geometryCollection = GeometryCollection.fromJson(loadJsonFixture(TURF_EXPLODE_GEOMETRY_COLLECTION)); assertEquals(3, TurfConversion.explode(Feature.fromGeometry(geometryCollection)).features().size()); }
@Test public void explodeFeatureCollection() throws NullPointerException { FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] { Feature.fromGeometry(MultiLineString.fromJson(loadJsonFixture(TURF_EXPLODE_MULTILINESTRING))), Feature.fromGeometry(MultiPolygon.fromJson(loadJsonFixture(TURF_EXPLODE_MULTIPOLYGON))) }); assertEquals(16, TurfConversion.explode(featureCollection).features().size()); }