All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mapfish.print.map.geotools.AbstractGridCoverageLayerPlugin Maven / Gradle / Ivy

There is a newer version: 3.22.0
Show newest version
package org.mapfish.print.map.geotools;

import org.geotools.styling.Style;
import org.mapfish.print.config.Template;
import org.mapfish.print.http.MfClientHttpRequestFactory;
import org.mapfish.print.map.style.StyleParser;
import org.springframework.beans.factory.annotation.Autowired;

import static org.mapfish.print.Constants.Style.Raster.NAME;

/**
 * Abstract class for {@link org.mapfish.print.map.MapLayerFactoryPlugin} that created layers based on grid
 * coverages.
 */
public abstract class AbstractGridCoverageLayerPlugin {
    @Autowired
    private StyleParser styleParser;

    /**
     * Common method for creating styles.
     *
     * @param template the template that the map is part of
     * @param styleRef the style ref identifying the style
     * @param  the source type
     */
    protected final  StyleSupplier createStyleSupplier(
            final Template template,
            final String styleRef) {
        return new StyleSupplier() {
            @Override
            public Style load(
                    final MfClientHttpRequestFactory requestFactory,
                    final T featureSource) {
                final StyleParser parser = AbstractGridCoverageLayerPlugin.this.styleParser;
                return template.getStyle(styleRef)
                        .or(parser.loadStyle(template.getConfiguration(), requestFactory, styleRef))
                        .or(template.getConfiguration().getDefaultStyle(NAME));
            }
        };
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy