public static DataStore getDXFDataStore(String dxfFile, String epsgCode) { Map<String, Object> params = new HashMap<String, Object>(); final File file = new File(dxfFile); params.put("url", DataUtilities.fileToURL(file)); params.put("srs", epsgCode); params.put("charset", Charset.forName(DEFAULT_CHARSET)); return getDataStore(Collections.unmodifiableMap(params)); }
public static DataStore getShapefileDataStore(String folder, Boolean createSpatialIndex) { Map<String, Object> params = new HashMap<String, Object>(); final File file = new File(folder); params.put(ShapefileDataStoreFactory.URLP.key, DataUtilities.fileToURL(file)); params.put(ShapefileDataStoreFactory.CREATE_SPATIAL_INDEX.key, createSpatialIndex); params.put(ShapefileDataStoreFactory.DBFCHARSET.key, DEFAULT_CHARSET); params.put(ShapefileDataStoreFactory.MEMORY_MAPPED.key, Boolean.TRUE); return getDataStore(Collections.unmodifiableMap(params)); }
public DataStore getDataStore(File file) throws IOException { final URL url = DataUtilities.fileToURL(file); if(shpFactory.canProcess(url)) { Map params = new HashMap(originalParams); params.put(URLP.key, url); return shpFactory.createDataStore(params); } else { return null; } }
public GranuleDescriptor( final String granuleLocation, final BoundingBox granuleBBox, final ImageReaderSpi suggestedSPI, final Geometry inclusionGeometry, final int maxDecimationFactor, final boolean heterogeneousGranules, final boolean handleArtifactsFiltering) { this.maxDecimationFactor = maxDecimationFactor; final URL rasterFile = DataUtilities.fileToURL(new File(granuleLocation)); if (rasterFile == null) { return; } if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("File found " + granuleLocation); } this.originator = null; init (granuleBBox, rasterFile, suggestedSPI, inclusionGeometry, heterogeneousGranules, handleArtifactsFiltering); }
public DataStore getDataStore(File file) throws IOException { final URL url = DataUtilities.fileToURL(file); if(shpFactory.canProcess(url)) { Map params = new HashMap(originalParams); params.put(URLP.key, url); return shpFactory.createDataStore(params); } else { return null; } }
public PropertiesCollector create( final Object o, final List<String> propertyNames) { URL source=null; if (o instanceof URL){ source = (URL)o; } else if(o instanceof File) { source=DataUtilities.fileToURL((File) o); } else if(o instanceof String) try { source=new URL((String) o); } catch (MalformedURLException e) { return null; } else return null; // it is a url final Properties properties = Utils.loadPropertiesFromURL(source); if(properties.containsKey("regex")){ final String property = properties.getProperty("regex"); if(property!=null){ return createInternal(this,propertyNames,property.trim()); } } return null; }
return DataUtilities.fileToURL(rasterFile);
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName()+".shp"); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put("url", DataUtilities.fileToURL(f)); params.put("filetype", "shapefile"); DataStore ds = null; try { ds = DataStoreFinder.getDataStore(params); if(ds != null) { ds.createSchema(featureType); ds.dispose(); cache.refreshCacheContents(); } } catch(Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } if(ds == null) { throw new IOException("Could not find the shapefile data store in the classpath"); } }
@Override public StyledLayerDescriptor parse(Object input, Version version, @Nullable ResourceLocator resourceLocator, EntityResolver entityResolver) throws IOException { if (resourceLocator == null && input instanceof File) { resourceLocator = new DefaultResourceLocator(); ((DefaultResourceLocator)resourceLocator).setSourceUrl(DataUtilities.fileToURL((File) input)); } return Ysld.parse(toReader(input), Collections.singletonList(zoomFinder), resourceLocator, uomMapper); }
sourceURL = DataUtilities.fileToURL(tempFile); source = tempFile;
URL url = DataUtilities.fileToURL(proj_file); if (url != null) { return url;
throw new IOException("Could not find any file with .shp extension in the zip file"); } else { ShapefileDataStore store = new ShapefileDataStore(DataUtilities.fileToURL(shapeFile)); resources.addResource(new ShapefileResource(store, tempDir)); return store.getFeatureSource().getFeatures();
public DataAccess<FeatureType, Feature> createDataStore(Map params) throws IOException { Set<FeatureTypeMapping> mappings; AppSchemaDataAccess dataStore; URL configFileUrl = (URL) AppSchemaDataAccessFactory.URL.lookUp(params); XMLConfigDigester configReader = new XMLConfigDigester(); AppSchemaDataAccessDTO config = configReader.parse(configFileUrl); // load related types that are mapped separately, and not visible on their own // this is when the related types are not feature types, so they don't appear // on getCapabilities, and getFeature also shouldn't return anything etc. List<String> includes = config.getIncludes(); for (Iterator<String> it = includes.iterator(); it.hasNext();) { String parentLocation; parentLocation = DataUtilities.urlToFile(configFileUrl).getParent(); File includedConfig = new File(parentLocation, it.next()); if (!includedConfig.exists()) { throw new RuntimeException( "Please check that the includedTypes location is correct: \n '" + includedConfig.getPath() + "' doesn't exist!"); } URL relatedConfigURL = DataUtilities.fileToURL(includedConfig); params.put("url", relatedConfigURL); // this will register the related data access, to enable feature chaining createDataStore(params); } mappings = AppSchemaDataAccessConfigurator.buildMappings(config); dataStore = new AppSchemaDataAccess(mappings); return dataStore; }
@Override public CoverageStoreInfo createStore(ImportData data, WorkspaceInfo workspace, Catalog catalog) throws IOException { MosaicIndex index = new MosaicIndex((Mosaic) data); index.write(); CoverageStoreInfo store = super.createStore(data, workspace, catalog); store.setURL(DataUtilities.fileToURL(index.getFile()).toString()); return store; }
if(parentDirectory.isFile()) parentDirectory=parentDirectory.getParentFile(); params.put("ParentLocation", DataUtilities.fileToURL(parentDirectory).toString()); if(parentDirectory.isFile()) parentDirectory=parentDirectory.getParentFile(); params.put("ParentLocation", DataUtilities.fileToURL(parentDirectory).toString());
.fileToURL(indexerProperties));
if(Utils.checkFileReadable(datastoreProperties)){ Properties properties = Utils.loadPropertiesFromURL(DataUtilities.fileToURL(datastoreProperties)); if (properties == null) throw new IOException();
private AppSchemaDataAccess buildDataAccess(String mappingsFileName) throws Exception { // generate the path to a mappings-file in the resources directory String configFilePath = extendFilename(testDir.getPath(), mappingsFileName); URL configFileUrl = DataUtilities.fileToURL(new File(configFilePath)); // parse the mappings-file XMLConfigDigester configReader = new XMLConfigDigester(); AppSchemaDataAccessDTO config = configReader.parse(configFileUrl); // generate the set of mappings needed to build the application-schema datastore Set<FeatureTypeMapping> mappings; mappings = AppSchemaDataAccessConfigurator.buildMappings(config); AppSchemaDataAccess datastore = new AppSchemaDataAccess(mappings); return datastore; }
configuration=Utils.loadMosaicProperties(DataUtilities.fileToURL(propFile), this.locationAttributeName); if(configuration!=null) break;
private Parser createSld11Parser(Object input, ResourceLocator resourceLocator, EntityResolver entityResolver) { if (resourceLocator == null && input instanceof File) { // setup for resolution of relative paths final java.net.URL surl = DataUtilities.fileToURL((File) input); DefaultResourceLocator defResourceLocator = new DefaultResourceLocator(); defResourceLocator.setSourceUrl(surl); resourceLocator = defResourceLocator; } final ResourceLocator locator = resourceLocator; SLDConfiguration sld; if (locator != null) { sld = new SLDConfiguration() { protected void configureContext(org.picocontainer.MutablePicoContainer container) { container.registerComponentInstance(ResourceLocator.class, locator); } ; } ; } else { sld = new SLDConfiguration(); } Parser parser = new Parser(sld); if (entityResolver != null) { parser.setEntityResolver(entityResolver); } return parser; }