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

nl.pdok.workspacebuilder.model.layer.Coverage Maven / Gradle / Ivy

The newest version!
package nl.pdok.workspacebuilder.model.layer;

import it.geosolutions.geoserver.rest.decoder.RESTCoverageList;
import it.geosolutions.geoserver.rest.decoder.utils.NameLinkElem;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder;
import it.geosolutions.geoserver.rest.encoder.coverage.GSCoverageEncoder;
import it.geosolutions.geoserver.rest.encoder.coverage.GSImageMosaicEncoder;
import it.geosolutions.geoserver.rest.encoder.metadatalink.GSMetadataLinkInfoEncoder;
import nl.pdok.catalogus.Catalogus;
import nl.pdok.workspacebuilder.GeoserverRestProxy;
import nl.pdok.workspacebuilder.PdokBuilder;
import nl.pdok.workspacebuilder.model.Service;

import java.util.List;

public class Coverage extends SingleLayer {
    private List responseSrsList;
    private List requestSrsList;
    private List interpolationMethods;
    private String defaultInterpolationMethod;

    private Boolean accurateResolutionComputation; // default false
    private Boolean allowMultithreading; // default false
    private String backgroundValues; // double[], default null
    private String filter; // org.opengis.filter.Filter, default null
    private String footprintBehavior; // default "None"
    private String inputTransparentColor; // java.awt.Color, default null
    private Integer maxAllowedTiles; // default -1
    private String mergeBehavior; // default "FLAT"
    private String outputTransparentColor; // java.awt.Color, default null
    private String sorting; // default null
    private String suggestedTileSize; // default "512,512"
    private Boolean useJaiImageRead; // default true
    
    public Coverage(Catalogus catalogus){
        super(Type.MOSAIC, catalogus);
    }
    
	@Override
	protected GSResourceEncoder createResourceEncoder() {
		GSImageMosaicEncoder coverageEncoder = new GSImageMosaicEncoder();
		coverageEncoder.setNativeName(getName());
		coverageEncoder.setTitle(getTitle());
		coverageEncoder.setAbstract(getAbstractText());
		coverageEncoder.setDescription(getAbstractText());
		coverageEncoder.addMetadataLinkInfo(new GSMetadataLinkInfoEncoder(PdokBuilder.METADATACODETYPE,
				PdokBuilder.METADATATYPE, PdokBuilder.METADATABASEURL + getMetadataId()));
		coverageEncoder.setSRS("EPSG:28992");
		coverageEncoder.setProjectionPolicy(GSResourceEncoder.ProjectionPolicy.FORCE_DECLARED);
		coverageEncoder.setNativeCRS("EPSG:28992");
		coverageEncoder.setNativeFormat("ImageMosaic");
		coverageEncoder.addSupportedFormats("GEOTIFF", "TIFF");
		coverageEncoder.addRequestSRS(listToArray(this.requestSrsList));
		coverageEncoder.addResponseSRS(listToArray(this.responseSrsList));
		coverageEncoder.addInterpolationMethods(listToArray(this.interpolationMethods));
		coverageEncoder.setDefaultInterpolationMethod(this.defaultInterpolationMethod);
		coverageEncoder.setNativeCoverageName(getDatastoreName());

		if (this.accurateResolutionComputation != null) {
			coverageEncoder.setAccurateResolutionComputation(this.accurateResolutionComputation);
		}
		if (this.allowMultithreading != null) {
			coverageEncoder.setAllowMultithreading(this.allowMultithreading);
		}
		if (this.backgroundValues != null) {
			coverageEncoder.setBackgroundValues(this.backgroundValues);
		}
		if (this.filter != null) {
			coverageEncoder.setFilter(this.filter);
		}
		if (this.footprintBehavior != null) {
			coverageEncoder.setFootprintBehavior(this.footprintBehavior);
		}
		if (this.inputTransparentColor != null) {
			coverageEncoder.setInputTransparentColor(this.inputTransparentColor);
		}
		if (this.maxAllowedTiles != null) {
			coverageEncoder.setMaxAllowedTiles(this.maxAllowedTiles);
		}
		if (this.mergeBehavior != null) {
			coverageEncoder.setMergeBehavior(this.mergeBehavior);
		}
		if (this.outputTransparentColor != null) {
			coverageEncoder.setOutputTransparentColor(this.outputTransparentColor);
		}
		if (this.sorting != null) {
			coverageEncoder.setSORTING(this.sorting);
		}
		if (this.suggestedTileSize != null) {
			coverageEncoder.setSUGGESTED_TILE_SIZE(this.suggestedTileSize);
		}
		if (this.useJaiImageRead != null) {
			coverageEncoder.setUSE_JAI_IMAGEREAD(this.useJaiImageRead);
		}

		return coverageEncoder;
	}
	
    @Override
    protected boolean publish(String workspaceName, GSResourceEncoder resourceEncoder, GSLayerEncoder layerEncoder, GeoserverRestProxy geoserverRestProxy) {
    	return geoserverRestProxy.getPublisher().publishMosaicLayer(workspaceName, getDatastoreName(), (GSCoverageEncoder) resourceEncoder, layerEncoder );
    }

    public boolean featureExistsForCoverage(Service service, RESTCoverageList availableCoverages,
                                            GeoserverRestProxy geoserverRestProxy) {
        // first check
        if (availableCoverages != null) {
            for (NameLinkElem feature : availableCoverages) {
                String value = feature.getValue();
                if (this.getDatastoreName().equalsIgnoreCase(value)) {
                    return true;
                }
            }
        }

        //second check
        return geoserverRestProxy.getReader().existsFeatureType(service.getWorkspaceName(), getDatastoreName(), this.getName());
    }

    private String[] listToArray(List list) {
        return list != null ? list.toArray(new String[list.size()]) : new String[0];
    }

    public List getResponseSrsList() {
        return responseSrsList;
    }

    public void setResponseSrsList(List responseSrsList) {
        this.responseSrsList = responseSrsList;
    }

    public List getRequestSrsList() {
        return requestSrsList;
    }

    public void setRequestSrsList(List requestSrsList) {
        this.requestSrsList = requestSrsList;
    }

    public List getInterpolationMethods() {
        return interpolationMethods;
    }

    public void setInterpolationMethods(List interpolationMethods) {
        this.interpolationMethods = interpolationMethods;
    }

    public String getDefaultInterpolationMethod() {
        return defaultInterpolationMethod;
    }

    public void setDefaultInterpolationMethod(String defaultInterpolationMethod) {
        this.defaultInterpolationMethod = defaultInterpolationMethod;
    }

    public Boolean getAccurateResolutionComputation() {
        return accurateResolutionComputation;
    }

    public void setAccurateResolutionComputation(Boolean accurateResolutionComputation) {
        this.accurateResolutionComputation = accurateResolutionComputation;
    }

    public Boolean getAllowMultithreading() {
        return allowMultithreading;
    }

    public void setAllowMultithreading(Boolean allowMultithreading) {
        this.allowMultithreading = allowMultithreading;
    }

    public String getBackgroundValues() {
        return backgroundValues;
    }

    public void setBackgroundValues(String backgroundValues) {
        this.backgroundValues = backgroundValues;
    }

    public String getFilter() {
        return filter;
    }

    public void setFilter(String filter) {
        this.filter = filter;
    }

    public String getFootprintBehavior() {
        return footprintBehavior;
    }

    public void setFootprintBehavior(String footprintBehavior) {
        this.footprintBehavior = footprintBehavior;
    }

    public String getInputTransparentColor() {
        return inputTransparentColor;
    }

    public void setInputTransparentColor(String inputTransparentColor) {
        this.inputTransparentColor = inputTransparentColor;
    }

    public Integer getMaxAllowedTiles() {
        return maxAllowedTiles;
    }

    public void setMaxAllowedTiles(Integer maxAllowedTiles) {
        this.maxAllowedTiles = maxAllowedTiles;
    }

    public String getMergeBehavior() {
        return mergeBehavior;
    }

    public void setMergeBehavior(String mergeBehavior) {
        this.mergeBehavior = mergeBehavior;
    }

    public String getOutputTransparentColor() {
        return outputTransparentColor;
    }

    public void setOutputTransparentColor(String outputTransparentColor) {
        this.outputTransparentColor = outputTransparentColor;
    }

    public String getSorting() {
        return sorting;
    }

    public void setSorting(String sorting) {
        this.sorting = sorting;
    }

    public String getSuggestedTileSize() {
        return suggestedTileSize;
    }

    public void setSuggestedTileSize(String suggestedTileSize) {
        this.suggestedTileSize = suggestedTileSize;
    }

    public Boolean getUseJaiImageRead() {
        return useJaiImageRead;
    }

    public void setUseJaiImageRead(Boolean useJaiImageRead) {
        this.useJaiImageRead = useJaiImageRead;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy