/* * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2012-2015, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ package org.geotoolkit.coverage.xmlstore; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Collections; import org.apache.sis.parameter.ParameterBuilder; import org.apache.sis.storage.DataStoreException; import org.geotoolkit.storage.coverage.AbstractCoverageStoreFactory; import org.apache.sis.metadata.iso.DefaultIdentifier; import org.apache.sis.metadata.iso.citation.DefaultCitation; import org.apache.sis.metadata.iso.identification.DefaultServiceIdentification; import org.geotoolkit.storage.DataType; import org.geotoolkit.storage.DefaultFactoryMetadata; import org.geotoolkit.storage.FactoryMetadata; import org.opengis.metadata.Identifier; import org.opengis.metadata.identification.Identification; import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterValueGroup; /** * Coverage store relying on an xml file. * * @author Johann Sorel (Geomatys) * @module */ public class XMLCoverageStoreFactory extends AbstractCoverageStoreFactory { /** factory identification **/ public static final String NAME = "coverage-xml-pyramid"; public static final DefaultServiceIdentification IDENTIFICATION; static { IDENTIFICATION = new DefaultServiceIdentification(); final Identifier id = new DefaultIdentifier(NAME); final DefaultCitation citation = new DefaultCitation(NAME); citation.setIdentifiers(Collections.singleton(id)); IDENTIFICATION.setCitation(citation); } public static final ParameterDescriptor<String> IDENTIFIER = createFixedIdentifier(NAME); /** * Mandatory - the folder path */ public static final ParameterDescriptor<URI> PATH = new ParameterBuilder() .addName("path") .addName(Bundle.formatInternational(Bundle.Keys.coverageXMLPath)) .setRemarks(Bundle.formatInternational(Bundle.Keys.coverageXMLPathRemarks)) .setRequired(true) .create(URI.class, null); /** * A parameter to specify if tile states will be checked using descriptor file (default) or not. */ public static final ParameterDescriptor<Boolean> CACHE_TILE_STATE = new ParameterBuilder() .addName("cacheTileState") .addName(Bundle.formatInternational(Bundle.Keys.coverageXMLTileState)) .setRemarks(Bundle.formatInternational(Bundle.Keys.coverageXMLTileStateRemarks)) .setRequired(false) .create(Boolean.class, Boolean.FALSE); public static final ParameterDescriptorGroup PARAMETERS_DESCRIPTOR = new ParameterBuilder().addName("XMLCoverageStoreParameters").createGroup( IDENTIFIER, PATH, NAMESPACE, CACHE_TILE_STATE); @Override public Identification getIdentification() { return IDENTIFICATION; } @Override public CharSequence getDescription() { return Bundle.formatInternational(Bundle.Keys.coverageXMLDescription); } @Override public CharSequence getDisplayName() { return Bundle.formatInternational(Bundle.Keys.coverageXMLTitle); } @Override public ParameterDescriptorGroup getParametersDescriptor() { return PARAMETERS_DESCRIPTOR; } @Override public XMLCoverageStore open(ParameterValueGroup params) throws DataStoreException { if(!canProcess(params)){ throw new DataStoreException("Can not process parameters."); } try { return new XMLCoverageStore(params); } catch (IOException | URISyntaxException ex) { throw new DataStoreException(ex); } } @Override public XMLCoverageStore create(ParameterValueGroup params) throws DataStoreException { return open(params); } @Override public FactoryMetadata getMetadata() { return new DefaultFactoryMetadata(DataType.PYRAMID, true, true, true); } }