Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions services-turf/src/main/java/com/mapbox/turf/TurfAssertions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.geojson.GeoJson;
import com.mapbox.geojson.Point;
import com.mapbox.core.utils.TextUtils;

/**
Expand All @@ -19,21 +18,6 @@ private TurfAssertions() {
// Private constructor preventing initialization of this class
}

/**
* Unwrap a coordinate {@link Point} from a Feature with a Point geometry.
*
* @param obj any value
* @return a coordinate
* @see <a href="http://turfjs.org/docs/#getcoord">Turf getCoord documentation</a>
* @since 1.2.0
*/
public static Point getCoord(Feature obj) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a semver change, you need to deprecate and point to using the other method instead of deleting it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cammace this exactly what I was not sure about.
This issue indeed said: deprecate but then
#738
contained name changes and you reviewed it.
Some of those name changes were for API's since 1.2

Should I deprecate those as well instead of changename

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those need to be fixed also. Sorry for missing that in #738

if (obj.geometry() instanceof Point) {
return (Point) obj.geometry();
}
throw new TurfException("A feature with a Point geometry is required.");
}

/**
* Enforce expectations about types of GeoJson objects for Turf.
*
Expand Down
16 changes: 16 additions & 0 deletions services-turf/src/main/java/com/mapbox/turf/TurfMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.support.annotation.NonNull;

import com.mapbox.geojson.Feature;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.MultiLineString;
import com.mapbox.geojson.MultiPoint;
Expand Down Expand Up @@ -140,4 +141,19 @@ public static List<Point> coordAll(@NonNull MultiPolygon multiPolygon, boolean e
}
return coords;
}

/**
* Unwrap a coordinate {@link Point} from a Feature with a Point geometry.
*
* @param obj any value
* @return a coordinate
* @see <a href="http://turfjs.org/docs/#getcoord">Turf getCoord documentation</a>
* @since 3.2.0
*/
public static Point getCoord(Feature obj) {
if (obj.geometry() instanceof Point) {
return (Point) obj.geometry();
}
throw new TurfException("A Feature with a Point geometry is required.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,4 @@ public void testInvariantCollectionOf4() {
+ "type: 'Point', coordinates: [0, 0]}, properties: {}}]}";
TurfAssertions.collectionOf(FeatureCollection.fromJson(json), "Point", "myfn");
}


@Test
public void testInvariantGetCoord() {
String jsonFeature = "{type: 'Feature', geometry: {type: 'Point', coordinates: [1, 2]}}";
assertEquals(TurfAssertions.getCoord(Feature.fromJson(jsonFeature)),
Point.fromLngLat(1, 2));
}
}
8 changes: 8 additions & 0 deletions services-turf/src/test/java/com/mapbox/turf/TurfMetaTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mapbox.turf;

import com.mapbox.geojson.Feature;
import com.mapbox.geojson.LineString;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.Polygon;
Expand Down Expand Up @@ -77,4 +78,11 @@ public void coordAllMultiPolygon() throws TurfException {
assertEquals(resultList.get(2), Point.fromLngLat(0, 1));
assertEquals(resultList.get(3), Point.fromLngLat(0, 0));
}

@Test
public void testInvariantGetCoord() {
String jsonFeature = "{type: 'Feature', geometry: {type: 'Point', coordinates: [1, 2]}}";
assertEquals(TurfMeta.getCoord(Feature.fromJson(jsonFeature)),
Point.fromLngLat(1, 2));
}
}