public static byte[] encode(JtsMvt mvt, MvtLayerParams mvtLayerParams, IUserDataConverter userDataConverter) {

        // Build MVT
        final VectorTile.Tile.Builder tileBuilder = VectorTile.Tile.newBuilder();

        for(JtsLayer layer : mvt.getLayers()) {
            final Collection<Geometry> layerGeoms = layer.getGeometries();

            // Create MVT layer
            final VectorTile.Tile.Layer.Builder layerBuilder =
                    MvtLayerBuild.newLayerBuilder(layer.getName(), mvtLayerParams);
            final MvtLayerProps layerProps = new MvtLayerProps();

            // MVT tile geometry to MVT features
            final List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(
                    layerGeoms, layerProps, userDataConverter);
            layerBuilder.addAllFeatures(features);
            MvtLayerBuild.writeProps(layerBuilder, layerProps);

            // Build MVT layer
            final VectorTile.Tile.Layer vtl = layerBuilder.build();
            tileBuilder.addLayers(vtl);
        }

        // Build MVT
        return tileBuilder.build().toByteArray();
    }
public static byte [ ] encode ( JtsMvt mvt , MvtLayerParams mvtLayerParams , IUserDataConverter userDataConverter ) { final VectorTile . Tile . Builder tileBuilder = VectorTile . Tile . newBuilder ( ) ; for ( JtsLayer layer : mvt . getLayers ( ) ) { final Collection < Geometry > layerGeoms = layer . getGeometries ( ) ; final VectorTile . Tile . Layer . Builder layerBuilder = MvtLayerBuild . newLayerBuilder ( layer . getName ( ) , mvtLayerParams ) ; final MvtLayerProps layerProps = new MvtLayerProps ( ) ; final List < VectorTile . Tile . Feature > features = JtsAdapter . toFeatures ( layerGeoms , layerProps , userDataConverter ) ; layerBuilder . addAllFeatures ( features ) ; MvtLayerBuild . writeProps ( layerBuilder , layerProps ) ; final VectorTile . Tile . Layer vtl = layerBuilder . build ( ) ; tileBuilder . addLayers ( vtl ) ; } return tileBuilder . build ( ) . toByteArray ( ) ; }
Encode a {@link JtsMvt} to byte[] ready for writing to a file.

@param mvt input to encode to bytes
@param mvtLayerParams tile creation parameters
@param userDataConverter converts {@link Geometry#userData} to MVT feature tags
@return bytes ready for writing to a .mvt