@Test public void testFeatureCollection() throws TurfException { ArrayList<Point> pointList = new ArrayList<>(); pointList.add(Point.fromLngLat(0, 0)); pointList.add(Point.fromLngLat(0, 100)); pointList.add(Point.fromLngLat(100, 100)); pointList.add(Point.fromLngLat(100, 0)); pointList.add(Point.fromLngLat(0, 0)); List<List<Point>> coordinates = new ArrayList<>(); coordinates.add(pointList); Polygon poly = Polygon.fromLngLats(coordinates); Point ptIn = Point.fromLngLat(50, 50); Point ptOut = Point.fromLngLat(140, 150); assertTrue(TurfJoins.inside(ptIn, poly)); assertFalse(TurfJoins.inside(ptOut, poly)); pointList = new ArrayList<>(); pointList.add(Point.fromLngLat(0, 0)); pointList.add(Point.fromLngLat(50, 50)); pointList.add(Point.fromLngLat(0, 100)); pointList.add(Point.fromLngLat(100, 100)); pointList.add(Point.fromLngLat(100, 0)); pointList.add(Point.fromLngLat(0, 0)); coordinates = new ArrayList<>(); coordinates.add(pointList); Polygon concavePoly = Polygon.fromLngLats(coordinates); ptIn = Point.fromLngLat(75, 75); ptOut = Point.fromLngLat(25, 50); assertTrue(TurfJoins.inside(ptIn, concavePoly)); assertFalse(TurfJoins.inside(ptOut, concavePoly)); }
public static boolean inside(Point point, Polygon polygon) { List<List<Point>> coordinates = polygon.coordinates(); List<List<List<Point>>> multiCoordinates = new ArrayList<>(); multiCoordinates.add(coordinates); return inside(point, MultiPolygon.fromLngLats(multiCoordinates)); }
TurfJoins { public static boolean inside(Point point, Polygon polygon) { List<List<Point>> coordinates = polygon.coordinates(); List<List<List<Point>>> multiCoordinates = new ArrayList<>(); multiCoordinates.add(coordinates); return inside(point, MultiPolygon.fromLngLats(multiCoordinates)); } }
TurfJoins { public static boolean inside(Point point, Polygon polygon) { List<List<Point>> coordinates = polygon.coordinates(); List<List<List<Point>>> multiCoordinates = new ArrayList<>(); multiCoordinates.add(coordinates); return inside(point, MultiPolygon.fromLngLats(multiCoordinates)); } private  TurfJoins(); }
TurfJoins { public static boolean inside(Point point, Polygon polygon) { List<List<Point>> coordinates = polygon.coordinates(); List<List<List<Point>>> multiCoordinates = new ArrayList<>(); multiCoordinates.add(coordinates); return inside(point, MultiPolygon.fromLngLats(multiCoordinates)); } private  TurfJoins(); static boolean inside(Point point, Polygon polygon); static boolean inside(Point point, MultiPolygon multiPolygon); static FeatureCollection pointsWithinPolygon(FeatureCollection points,
                                                      FeatureCollection polygons); }
TurfJoins { public static boolean inside(Point point, Polygon polygon) { List<List<Point>> coordinates = polygon.coordinates(); List<List<List<Point>>> multiCoordinates = new ArrayList<>(); multiCoordinates.add(coordinates); return inside(point, MultiPolygon.fromLngLats(multiCoordinates)); } private  TurfJoins(); static boolean inside(Point point, Polygon polygon); static boolean inside(Point point, MultiPolygon multiPolygon); static FeatureCollection pointsWithinPolygon(FeatureCollection points,
                                                      FeatureCollection polygons);  }