private List<File> buildDatasets( List<String> files, ICRS crs ) { List<File> datasets = new ArrayList<File>( files.size() ); for ( String path : files ) { try { File file = metadata.getLocation().resolveToFile( path ).getCanonicalFile(); gdalSettings.getDatasetPool().addDataset( file, crs ); datasets.add( file ); } catch ( IOException e ) { throw new IllegalArgumentException( e.getMessage(), e ); } } return datasets; }
@Override public MetadataStore<? extends MetadataRecord> build() { List<File> recordDirectories = new ArrayList<File>(); File insertDirectory = null; try { List<String> isoRecordDirectories = config.getISORecordDirectory(); for ( String isoRecordDirectory : isoRecordDirectories ) { recordDirectories.add( metadata.getLocation().resolveToFile( isoRecordDirectory ) ); } if ( config.getInsertDirectory() != null ) { insertDirectory = metadata.getLocation().resolveToFile( config.getInsertDirectory() ); } else { insertDirectory = recordDirectories.get( 0 ); } return new ISOMemoryMetadataStore( recordDirectories, insertDirectory, metadata ); } catch ( Exception e ) { String msg = "Error setting up iso memory meatadata store from configuration: " + e.getMessage(); throw new ResourceInitException( msg, e ); } }
public void transform() throws TransformerException, XMLStreamException { OwsManager mgr = workspace.getResourceManager( OwsManager.class ); List<OWS> wmss = mgr.getByOWSClass( WMSController.class ); for ( OWS ows : wmss ) { ResourceMetadata<? extends Resource> md = ows.getMetadata(); ResourceIdentifier<? extends Resource> id = md.getIdentifier(); File loc = md.getLocation().resolveToFile( id.getId() + ".xml" ); ByteArrayOutputStream bos = new ByteArrayOutputStream(); transformer.transform( new StreamSource( loc ), new StreamResult( bos ) ); ThemeXmlStreamEncoder.writeOut( bos ); WorkspaceUtils.activateSynthetic( workspace, ThemeProvider.class, id.getId(), new String( bos.toByteArray(), Charset.forName( "UTF-8" ) ) ); } }
Map<String, TileDataSet> buildTileDataSetMap() throws IOException, UnknownCRSException { Map<String, TileDataSet> map = new HashMap<String, TileDataSet>(); for ( GdalTileStoreJaxb.TileDataSet tds : cfg.getTileDataSet() ) { String id = tds.getIdentifier(); if ( id == null ) { id = new File( tds.getFile() ).getName(); } File file = location.resolveToFile( tds.getFile() ); if ( !file.exists() ) { LOG.warn( "File {} does not exist, skipping.", file ); continue; } Dataset gdalDataset = gdal.OpenShared( file.toString() ); try { // TODO Envelope env = GdalUtils.getEnvelopeAndCrs( gdalDataset, "EPSG:28992" ).getEnvelope(); if ( env == null ) { throw new ResourceInitException( "No envelope information could be read via GDAL." ); } LOG.debug( "Envelope from GDAL was {}.", env ); map.put( id, builder.buildTileDataSet( tds, location, env ) ); } finally { gdalDataset.delete(); } } return map; }
@Override public TileStore build() { try { String cache = cfg.getCacheConfiguration(); File f = new File( cache ); if ( !f.isAbsolute() ) { f = metadata.getLocation().resolveToFile( cache ); } CacheManager cmgr = new CacheManager( f.toURI().toURL() ); TileStore tileStore = workspace.getResource( TileStoreProvider.class, cfg.getTileStoreId() ); return new CachingTileStore( tileStore, cmgr, cfg.getCacheName(), metadata ); } catch ( CacheException e ) { // case needed, as NPE's inside exception can occur otherwise throw new ResourceInitException( "Unable to create tile store: " + e.getMessage() ); } catch ( Exception e ) { throw new ResourceInitException( "Unable to create tile store", e ); } }
File file = location.resolveToFile( tds.getFile() );
@Override public FeatureStore build() { ConnectionProvider conn = workspace.getResource( ConnectionProviderProvider.class, config.getJDBCConnId().getValue() ); checkConnection( conn ); File file = metadata.getLocation().resolveToFile( metadata.getIdentifier().getId() + ".xml" ); SQLFeatureStore fs = null; try { // TODO rewrite needed to properly resolve files using resource location fs = new SQLFeatureStore( config, file.toURI().toURL(), conn.getDialect(), metadata, workspace ); } catch ( MalformedURLException e ) { LOG.trace( "Stack trace:", e ); } return fs; }
String cd = rasterCache.getValue(); if ( cd != null ) { cacheDir = location.resolveToFile( cd );
File base = metadata.getLocation().resolveToFile( "." ); storageDir = new File( storage ); if ( !storageDir.isAbsolute() ) {
File file = metadata.getLocation().resolveToFile( cfg.getFile() );
@Override public TileMatrixSet build() { File file = metadata.getLocation().resolveToFile( cfg.getFile() ); if ( !file.exists() ) { throw new ResourceInitException( "File " + file + " does not exist." );
/** * @param configAdapter */ private void initBackgroundImages( ResourceLocation<?> location ) { SkyImages images = serviceConfiguration.getSkyImages(); if ( images != null ) { List<SkyImage> skyImage = images.getSkyImage(); if ( !skyImage.isEmpty() ) { for ( SkyImage image : skyImage ) { if ( image != null && image.getName() != null && image.getFile() != null ) { String name = image.getName(); String file = image.getFile(); File f = location.resolveToFile( file ); TexturePool.addTexture( name, f ); } } } } }
baseDir = metadata.getLocation().resolveToFile( lay.getLayerDirectory() );
GMLVersionType gmlVersionType = null; for ( GMLSchema jaxbSchemaURL : config.getGMLSchema() ) { schemaURLs[i++] = metadata.getLocation().resolveToFile( jaxbSchemaURL.getValue().trim() ).toURI().toURL().toString(); try { GMLVersion version = GMLVersion.valueOf( datasetFile.getVersion().name() ); URL docURL = metadata.getLocation().resolveToFile( datasetFile.getValue().trim() ).toURI().toURL(); GMLStreamReader gmlStream = GMLInputFactory.createGMLStreamReader( version, docURL ); gmlStream.setApplicationSchema( schema );
String shapeFileName = location.resolveToFile( config.getFile().trim() ).toString();
TileDataSet buildTileDataSet( GeoTIFFTileStoreJAXB.TileDataSet cfg, ResourceLocation<TileStore> location, Envelope envelope ) { String filename = cfg.getFile(); String format = cfg.getImageFormat(); String tmsId = cfg.getTileMatrixSetId(); File file = location.resolveToFile( filename ); TileMatrixSet tms = workspace.getResource( TileMatrixSetProvider.class, tmsId ); List<TileDataLevel> levels = new ArrayList<TileDataLevel>(); double x = envelope.getMin().get0() - tms.getSpatialMetadata().getEnvelope().getMin().get0(); double y = envelope.getMax().get1() - tms.getSpatialMetadata().getEnvelope().getMax().get1(); int idx = 0; for ( TileMatrix tm : tms.getTileMatrices() ) { int xoff = (int) Math.round( x / tm.getTileWidth() ); int yoff = (int) Math.round( y / tm.getTileHeight() ); int numx = (int) Math.ceil( envelope.getSpan0() / tm.getTileWidth() ); int numy = (int) Math.ceil( envelope.getSpan1() / tm.getTileHeight() ); levels.add( new GeoTIFFTileDataLevel( tm, file, idx++, xoff, yoff, numx, numy ) ); } return new DefaultTileDataSet( levels, tms, format ); }
String imageFormat = cfg.getImageFormat(); String tmsId = cfg.getTileMatrixSetId(); File file = location.resolveToFile( filename ); TileMatrixSet tms = workspace.getResource( TileMatrixSetProvider.class, tmsId ); GdalSettings gdalSettings = workspace.getInitializable( GdalSettings.class );
if ( t.getFile() != null ) { featureInfoManager.addOrReplaceFormat( t.getFormat(), metadata.getLocation().resolveToFile( t.getFile() ).toString() ); } else if ( t.getXSLTFile() != null ) { XSLTFile xsltFile = t.getXSLTFile();
static FeatureInfoManager buildFeatureInfoManager( FeatureInfoFormatsType conf, ResourceLocation<?> location, Workspace workspace ) throws ResourceInitException { FeatureInfoManager featureInfoManager = new FeatureInfoManager( true ); try { if ( conf != null ) { for ( GetFeatureInfoFormat t : conf.getGetFeatureInfoFormat() ) { if ( t.getFile() != null ) { featureInfoManager.addOrReplaceFormat( t.getFormat(), location.resolveToFile( t.getFile() ).toString() ); } else { XSLTFile xsltFile = t.getXSLTFile(); GMLVersion version = GMLVersion.valueOf( xsltFile.getGmlVersion().toString() ); featureInfoManager.addOrReplaceXsltFormat( t.getFormat(), location.resolveToUrl( xsltFile.getValue() ), version, workspace ); } } } } catch ( Exception e ) { throw new ResourceInitException( "GetFeatureInfo format handler could not be initialized: " + e.getLocalizedMessage(), e ); } return featureInfoManager; }
ImageInputStream iis = ImageIO.createImageInputStream( metadata.getLocation().resolveToFile( file ) ); reader.setInput( iis ); int num = reader.getNumImages( true ); opts.add( CRS, crs.getAlias() ); AbstractRaster raster = RasterFactory.loadRasterFromFile( metadata.getLocation().resolveToFile( file ), opts, metadata ); setNoDataValue( raster, config.getNodata() );