public List polygonToCells()

in src/main/java/com/uber/h3core/H3Core.java [598:631]


  public List<Long> polygonToCells(List<LatLng> points, List<List<LatLng>> holes, int res) {
    checkResolution(res);

    // pack the data for use by the polyfill JNI call
    double[] verts = new double[points.size() * 2];
    packGeofenceVertices(verts, points, 0);
    int[] holeSizes = new int[0];
    double[] holeVerts = new double[0];
    if (holes != null) {
      int holesSize = holes.size();
      holeSizes = new int[holesSize];
      int totalSize = 0;
      for (int i = 0; i < holesSize; i++) {
        int holeSize = holes.get(i).size() * 2;
        totalSize += holeSize;
        // Note we are storing the number of doubles
        holeSizes[i] = holeSize;
      }
      holeVerts = new double[totalSize];
      int offset = 0;
      for (int i = 0; i < holesSize; i++) {
        offset = packGeofenceVertices(holeVerts, holes.get(i), offset);
      }
    }

    int flags = 0;
    int sz = longToIntSize(h3Api.maxPolygonToCellsSize(verts, holeSizes, holeVerts, res, flags));

    long[] results = new long[sz];

    h3Api.polygonToCells(verts, holeSizes, holeVerts, res, flags, results);

    return nonZeroLongArrayToList(results);
  }