public String[] getTypeNames() throws IOException { // here we transform the names, and also refresh the type maps so that // they don't contain stale elements String[] names = wrapped.getTypeNames(); List<String> transformedNames = new ArrayList<String>(); Map<String, FeatureTypeMap> backup = new HashMap<String, FeatureTypeMap>(forwardMap); // Populate local hashmaps with new values. Map<String, FeatureTypeMap> forwardMapLocal = new ConcurrentHashMap<String, FeatureTypeMap>(); Map<String, FeatureTypeMap> backwardsMapLocal = new ConcurrentHashMap<String, FeatureTypeMap>(); for (int i = 0; i < names.length; i++) { String original = names[i]; String transformedName = transformFeatureTypeName(original); if (transformedName != null) { transformedNames.add(transformedName); FeatureTypeMap map = backup.get(original); if (map == null) { map = new FeatureTypeMap(original, transformedName); } forwardMapLocal.put(map.getOriginalName(), map); backwardsMapLocal.put(map.getName(), map); } } // Replace the member variables. forwardMap = forwardMapLocal; backwardsMap = backwardsMapLocal; return (String[]) transformedNames.toArray(new String[transformedNames.size()]); }
File file = new File("mayshapefile.shp"); try { Map connect = new HashMap(); connect.put("url", file.toURL()); DataStore dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); String typeName = typeNames[0]; System.out.println("Reading content " + typeName); FeatureSource featureSource = dataStore.getFeatureSource(typeName); FeatureCollection collection = featureSource.getFeatures(); FeatureIterator iterator = collection.features(); try { while (iterator.hasNext()) { Feature feature = iterator.next(); Geometry sourceGeometry = feature.getDefaultGeometry(); } } finally { iterator.close(); } } catch (Throwable e) {}
String[] names = ((DataStore) store).getTypeNames(); for (int i = 0; i < names.length; i++) { if (names[i].indexOf(":") >= 0) return new RetypingDataStore((DataStore) store);
URL url = new URL(service.getOnlineResource()); remoteWFS = connectRemoteWFS(url); remoteTypeNames = new ArrayList(Arrays.asList(remoteWFS.getTypeNames())); Collections.sort(remoteTypeNames);
@Test public void testLookupNotQualified() throws IOException { CatalogRepository repository = getCatalog().getResourcePool().getRepository(); DataStore store = repository.dataStore(new NameImpl(null, SF_PREFIX)); assertNotNull(store); List<String> typeNames = Arrays.asList(store.getTypeNames()); assertTrue(typeNames.contains(PRIMITIVEGEOFEATURE.getLocalPart())); }
@Test public void testLookupExistingStore() throws IOException { CatalogRepository repository = getCatalog().getResourcePool().getRepository(); DataStore store = repository.dataStore(new NameImpl(SF_PREFIX, SF_PREFIX)); assertNotNull(store); List<String> typeNames = Arrays.asList(store.getTypeNames()); assertTrue(typeNames.contains(PRIMITIVEGEOFEATURE.getLocalPart())); }
CoordinateReferenceSystem crs = (fallbackCrs == null) ? DefaultGeographicCRS.WGS84 : fallbackCrs; String typeName = inlineFeatureDatastore.getTypeNames()[0]; MemoryDataStore reTypedDS = new MemoryDataStore(new ForceCoordinateSystemFeatureReader(ilReader, crs)); } else { DataStore inlineFeatureDatastore = ul.getInlineFeatureDatastore(); String typeName = inlineFeatureDatastore.getTypeNames()[0]; featureSource = inlineFeatureDatastore.getFeatureSource(typeName);
@Override public String[] getTypeNames() throws IOException { return delegate.getTypeNames(); }
public String[] getTypeNames() throws IOException { return delegate.getTypeNames(); }
expect(ds.getTypeNames()).andReturn(new String[] {"trees"}).anyTimes(); expect(ds.getSchema("trees")).andReturn(type).anyTimes(); expect(ds.getFeatureSource("trees")).andReturn(fs);
expect(ds.getTypeNames()).andReturn(new String[] {"trees"}).anyTimes(); expect(ds.getSchema("trees")).andReturn(type).anyTimes(); expect(ds.getFeatureSource("trees")).andReturn(fs);
assertEquals(target, retyped.getSchema()); DataStore rs = (DataStore) retyped.getDataStore(); assertEquals(1, rs.getTypeNames().length); assertEquals(BRIDGES.getLocalPart(), rs.getTypeNames()[0]);
@Override public String getTypeName(URL url) throws IOException { DataStore ds = createDataStore(url); String[] names = ds.getTypeNames(); // should be exactly one ds.dispose(); return ((names == null || names.length == 0) ? null : names[0]); } }
/** * Static convenience method: displays a {@code JSimpleStyleDialog} to prompt the user for style * preferences to use with the first feature type in the {@code dataStore}. * * @param parent parent JFrame (may be null) * @param dataStore data store with the features to be rendered * @param initialStyle an optional Style object to initialize the dialog (may be {@code null}) * @return a new Style instance or null if the user cancels the dialog */ public static Style showDialog(Component parent, DataStore dataStore, Style initialStyle) { SimpleFeatureType type = null; try { String typeName = dataStore.getTypeNames()[0]; type = dataStore.getSchema(typeName); } catch (Exception ex) { throw new IllegalStateException(ex); } return showDialog(parent, type, initialStyle); }
private SimpleFeatureStore getTargetFeatureStore( SimpleFeatureType sourceSchema, DataStore targetStore, String coverage) throws IOException { // do we have to create it? List<String> existingTypeNames = Arrays.asList(targetStore.getTypeNames()); if (!existingTypeNames.contains(coverage)) { synchronized (coverage) { existingTypeNames = Arrays.asList(targetStore.getTypeNames()); if (!existingTypeNames.contains(coverage)) { final SimpleFeatureType schema = buildTargetSchema(sourceSchema); targetStore.createSchema(schema); // create indexes if we can if (targetStore instanceof JDBCDataStore) { ((JDBCDataStore) targetStore) .createIndex( new Index( schema.getTypeName(), schema.getTypeName() + "_loc_idx", true, "location", CoverageSlicesCatalog.IMAGE_INDEX_ATTR)); } } } } // TODO: handle Oracle casing issue? return (SimpleFeatureStore) targetStore.getFeatureSource(coverage); }
private String[] getFilesFromStore(LinkedHashSet<String> filePaths) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException { DataStore sourceStore = H2MigrateConfiguration.getDataStore(configuration.getSourceStoreConfiguration()); final String[] indexTables = configuration.getIndexTables() != null ? configuration.getIndexTables() : getCoverageNames(); try { final List<String> typeNames = Arrays.asList(sourceStore.getTypeNames()); for (String indexTable : indexTables) { if (!typeNames.contains(indexTable)) { throw new MigrationException( "Could not find source index table " + indexTable + ", the available ones are " + typeNames); } final List<String> coverageFiles = collectFilesFromTable(sourceStore, indexTable); filePaths.addAll(coverageFiles); } } finally { if (sourceStore != null) { sourceStore.dispose(); } } return indexTables; }
public void testMemoryDataStore() throws Exception { DataStore store = new MemoryDataStore(); assertNotNull(store); String[] typeNames = store.getTypeNames(); assertNotNull(typeNames); assertEquals(0, typeNames.length); }
protected void generalizeShapeFile( File shapeFile, DataStore shapeDS, File targetDir, Double[] distanceArray) throws IOException { String typeName = shapeDS.getTypeNames()[0]; SimpleFeatureSource fs = shapeDS.getFeatureSource(typeName); SimpleFeatureType ftype = fs.getSchema();
@Before public void setUp() throws Exception { SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName("render-test"); ftb.add("the_geom", Point.class, DefaultGeographicCRS.WGS84); ftb.setDefaultGeometry("the_geom"); ftb.add("name", String.class); featureType = ftb.buildFeatureType(); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(); SimpleFeatureBuilder fb = new SimpleFeatureBuilder(featureType); fb.set("the_geom", gf.createPoint(new Coordinate(10, 10))); fb.set("name", "The name"); feature = fb.buildFeature(null); File shpFile = new File( "./target/screenMapTest/" + feature.getFeatureType().getName().getLocalPart() + ".shp"); shpFile.getParentFile().mkdirs(); ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory(); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(ShapefileDataStoreFactory.URLP.key, shpFile.toURI().toURL()); shapeFileDataStore = dataStoreFactory.createNewDataStore(params); shapeFileDataStore.createSchema(feature.getFeatureType()); SimpleFeatureStore featureStore = (SimpleFeatureStore) shapeFileDataStore.getFeatureSource(shapeFileDataStore.getTypeNames()[0]); featureStore.addFeatures(DataUtilities.collection(feature)); RendererBaseTest.setupVeraFonts(); }
public void testDataStore() throws IOException { SimpleFeatureSource features = DataUtilities.source(roadFeatures); Name name = features.getName(); String typeName = name.getLocalPart(); DataStore store = DataUtilities.dataStore(features); assertSame(features.getSchema(), store.getSchema(name)); assertSame(features.getSchema(), store.getSchema(typeName)); assertSame(features, store.getFeatureSource(name)); assertSame(features, store.getFeatureSource(typeName)); assertEquals(name, store.getNames().get(0)); assertEquals(typeName, store.getTypeNames()[0]); }