public Set<RPackage> resolveImports(Collection<String> packageNames) {
    Iterable<RPackage> packages =
        packageNames
            .stream()
            .map(this::getByName)
            .filter(Objects::nonNull)
            .collect(Collectors.toList());

    List<RPackage> dependencies =
        Lists.newArrayList(packages)
            .stream()
            .flatMap(f -> resolveImports(f.getImports()).stream())
            .collect(Collectors.toList());

    return Sets.newHashSet(Iterables.concat(packages, dependencies));
  }
Example #2
0
  public Geobuf.Data makeFeatureCollection(Collection<GeobufFeature> featureCollection) {
    Geobuf.Data.Builder data =
        Geobuf.Data.newBuilder()
            .setPrecision(this.precision)
            // TODO don't hardwire
            .setDimensions(2);

    Geobuf.Data.FeatureCollection.Builder fc = Geobuf.Data.FeatureCollection.newBuilder();

    // deduplicate keys
    List<String> keys = new ArrayList<>();

    featureCollection.stream().map(f -> this.makeFeature(f, keys)).forEach(fc::addFeatures);

    fc.addAllValues(Collections.emptyList());
    fc.addAllCustomProperties(Collections.emptyList());

    data.setFeatureCollection(fc);
    data.addAllKeys(keys);

    return data.build();
  }