congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TurfJoins.inside
Code IndexAdd Tabnine to your IDE (free)

How to use
inside
method
in
com.mapbox.turf.TurfJoins

Best Java code snippets using com.mapbox.turf.TurfJoins.inside (Showing top 6 results out of 315)

origin: mapbox/mapbox-java

/**
 * Takes a {@link Point} and a {@link Polygon} and determines if the point resides inside the
 * polygon. The polygon can be convex or concave. The function accounts for holes.
 *
 * @param point   which you'd like to check if inside the polygon
 * @param polygon which you'd like to check if the points inside
 * @return true if the Point is inside the Polygon; false if the Point is not inside the Polygon
 * @see <a href="http://turfjs.org/docs/#inside">Turf Inside documentation</a>
 * @since 1.3.0
 */
public static boolean inside(Point point, Polygon polygon) {
 // This API needs to get better
 List<List<Point>> coordinates = polygon.coordinates();
 List<List<List<Point>>> multiCoordinates = new ArrayList<>();
 multiCoordinates.add(coordinates);
 return inside(point, MultiPolygon.fromLngLats(multiCoordinates));
}
origin: mapbox/mapbox-java

/**
 * Takes a {@link FeatureCollection} of {@link Point} and a {@link FeatureCollection} of
 * {@link Polygon} and returns the points that fall within the polygons.
 *
 * @param points   input points.
 * @param polygons input polygons.
 * @return points that land within at least one polygon.
 * @since 1.3.0
 */
public static FeatureCollection pointsWithinPolygon(FeatureCollection points,
                          FeatureCollection polygons) {
 ArrayList<Feature> features = new ArrayList<>();
 for (int i = 0; i < polygons.features().size(); i++) {
  for (int j = 0; j < points.features().size(); j++) {
   Point point = (Point) points.features().get(j).geometry();
   boolean isInside
    = TurfJoins.inside(point, (Polygon) polygons.features().get(i).geometry());
   if (isInside) {
    features.add(Feature.fromGeometry(point));
   }
  }
 }
 return FeatureCollection.fromFeatures(features);
}
origin: mapbox/mapbox-java

@Test
public void testPolyWithHole() throws TurfException, IOException {
 Point ptInHole = Point.fromLngLat(-86.69208526611328, 36.20373274711739);
 Point ptInPoly = Point.fromLngLat(-86.72229766845702, 36.20258997094334);
 Point ptOutsidePoly = Point.fromLngLat(-86.75079345703125, 36.18527313913089);
 Feature polyHole = Feature.fromJson(loadJsonFixture(POLY_WITH_HOLE_FIXTURE));
 assertFalse(TurfJoins.inside(ptInHole, (Polygon) polyHole.geometry()));
 assertTrue(TurfJoins.inside(ptInPoly, (Polygon) polyHole.geometry()));
 assertFalse(TurfJoins.inside(ptOutsidePoly, (Polygon) polyHole.geometry()));
}
origin: mapbox/mapbox-java

@Test
public void testMultipolygonWithHole() throws TurfException, IOException {
 Point ptInHole = Point.fromLngLat(-86.69208526611328, 36.20373274711739);
 Point ptInPoly = Point.fromLngLat(-86.72229766845702, 36.20258997094334);
 Point ptInPoly2 = Point.fromLngLat(-86.75079345703125, 36.18527313913089);
 Point ptOutsidePoly = Point.fromLngLat(-86.75302505493164, 36.23015046460186);
 Feature multiPolyHole = Feature.fromJson(loadJsonFixture(MULTIPOLY_WITH_HOLE_FIXTURE));
 assertFalse(TurfJoins.inside(ptInHole, (MultiPolygon) multiPolyHole.geometry()));
 assertTrue(TurfJoins.inside(ptInPoly, (MultiPolygon) multiPolyHole.geometry()));
 assertTrue(TurfJoins.inside(ptInPoly2, (MultiPolygon) multiPolyHole.geometry()));
 assertFalse(TurfJoins.inside(ptOutsidePoly, (MultiPolygon) multiPolyHole.geometry()));
}
origin: mapbox/mapbox-java

Point ptOut = Point.fromLngLat(140, 150);
assertTrue(TurfJoins.inside(ptIn, poly));
assertFalse(TurfJoins.inside(ptOut, poly));
ptOut = Point.fromLngLat(25, 50);
assertTrue(TurfJoins.inside(ptIn, concavePoly));
assertFalse(TurfJoins.inside(ptOut, concavePoly));
origin: mapbox/mapbox-java

@Test
public void testInputPositions() throws IOException, TurfException {
 Point ptInPoly = Point.fromLngLat(-86.72229766845702, 36.20258997094334);
 Point ptOutsidePoly = Point.fromLngLat(-86.75079345703125, 36.18527313913089);
 Feature polyHole = Feature.fromJson(loadJsonFixture(POLY_WITH_HOLE_FIXTURE));
 Polygon polygon = (Polygon) polyHole.geometry();
 assertTrue(TurfJoins.inside(ptInPoly, polygon));
 assertFalse(TurfJoins.inside(ptOutsidePoly, polygon));
}
com.mapbox.turfTurfJoinsinside

Javadoc

Takes a Point and a MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.

Popular methods of TurfJoins

  • inRing
  • pointsWithinPolygon
    Takes a FeatureCollection of Point and a FeatureCollection of Polygon and returns the points that fa

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • putExtra (Intent)
  • setRequestProperty (URLConnection)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • JPanel (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now