public void createSchema(SimpleFeatureType featureType) throws IOException { delegate.createSchema(featureType); }
DataStore[] createDataStores( File shapeFile, File targetDir, SimpleFeatureType ft, Double[] distanceArray) throws IOException { FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory(); String shapeFileName = shapeFile.getAbsolutePath(); String newShapeFileRelativeName = null; int index = shapeFileName.lastIndexOf(File.separator); if (index == -1) newShapeFileRelativeName = shapeFileName; else newShapeFileRelativeName = shapeFileName.substring(index + 1); DataStore[] result = new DataStore[distanceArray.length]; for (int i = 0; i < distanceArray.length; i++) { String newShapeFileDirName = targetDir.getAbsolutePath(); if (newShapeFileDirName.endsWith(File.separator) == false) newShapeFileDirName += File.separator; newShapeFileDirName += distanceArray[i] + File.separator; File dir = new File(newShapeFileDirName); if (dir.exists() == false) dir.mkdir(); File file = new File(newShapeFileDirName + newShapeFileRelativeName); Map<String, Serializable> params = new HashMap<String, Serializable>(); params.put(ShapefileDataStoreFactory.URLP.key, file.toURI().toURL()); result[i] = factory.createNewDataStore(params); result[i].createSchema(ft); ((ShapefileDataStore) result[i]).forceSchemaCRS(ft.getCoordinateReferenceSystem()); } return result; }
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", URLs.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"); } }
tb.setName("pgeo"); SimpleFeatureType schema = tb.buildFeatureType(); store.createSchema(schema); SimpleFeatureStore featureStore = (SimpleFeatureStore) store.getFeatureSource("pgeo"); featureStore.addFeatures(fsp.getFeatures());
slicesIndexStore.createSchema(featureType); } else {
datastore.createSchema(mappedFeatureType);
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); }
public void createType(SimpleFeatureType featureType) throws IOException { Utilities.ensureNonNull("featureType", featureType); checkMosaicSchema(featureType); checkStore(); getTileIndexStore().createSchema(featureType); String typeName = featureType.getTypeName(); if (typeName != null) { addTypeName(typeName, true); } extractBasicProperties(typeName); }
public void createType(String namespace, String typeName, String typeSpec) throws IOException, SchemaException { Utilities.ensureNonNull("typeName", typeName); Utilities.ensureNonNull("typeSpec", typeSpec); checkStore(); final SimpleFeatureType featureType = DataUtilities.createType(namespace, typeName, typeSpec); checkMosaicSchema(featureType); getTileIndexStore().createSchema(featureType); String type = featureType.getTypeName(); if (typeName != null) { addTypeName(typeName, true); } extractBasicProperties(type); }
public void createType(String identification, String typeSpec) throws SchemaException, IOException { Utilities.ensureNonNull("typeSpec", typeSpec); Utilities.ensureNonNull("identification", identification); String typeName = null; checkStore(); final SimpleFeatureType featureType = DataUtilities.createType(identification, typeSpec); checkMosaicSchema(featureType); getTileIndexStore().createSchema(featureType); typeName = featureType.getTypeName(); if (typeName != null) { addTypeName(typeName, true); } extractBasicProperties(typeName); }
@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 createSchema(DataStore datastore, SimpleFeatureType sft) throws IOException { System.out.println("Creating schema: " + DataUtilities.encodeType(sft)); // we only need to do the once - however, calling it repeatedly is a no-op datastore.createSchema(sft); System.out.println(); }
public void createSchema(SimpleFeatureType featureType) throws IOException { File f = new File(cache.directory, featureType.getTypeName()+".shp"); String shpDataStoreClassName = "org.geotools.data.shapefile.ShapefileDataStore"; DataStore ds = null; try { ds = (DataStore) Class.forName(shpDataStoreClassName).getConstructor(URL.class) .newInstance(f.toURL()); ds.createSchema(featureType); cache.refreshCacheContents(); } catch(Exception e) { throw (IOException) new IOException("Error creating new data store").initCause(e); } }
public void createType(SimpleFeatureType featureType) throws IOException { Utilities.ensureNonNull("featureType",featureType); final Lock lock=rwLock.writeLock(); try{ lock.lock(); checkStore(); tileIndexStore.createSchema(featureType); extractBasicProperties(featureType.getTypeName()); }finally{ lock.unlock(); } }
public void testCreateSchema() throws Exception { String typename = "NewType"; SimpleFeatureType t = DataUtilities.createType(typename, "*geom:Geometry"); data.createSchema(t); String[] names = data.getTypeNames(); boolean foundNewType = false; for (int i = 0; i < names.length; i++) { if (names[i].equalsIgnoreCase(typename)) { foundNewType = true; } } assertTrue(foundNewType); } }
public FeatureInserter(DataStore dataStore, SimpleFeatureType featureType) { try { this.fieldMaps.clear(); this.dataStore = dataStore; this.dataStore.createSchema(featureType); this.typeName = featureType.getTypeName(); // call once dataStore.getFeatureSource(typeName); this.transaction = new DefaultTransaction(typeName); // Transaction.AUTO_COMMIT this.writer = dataStore.getFeatureWriterAppend(typeName, transaction); this.writeMode = Boolean.TRUE; } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e); } }
public void testCreateSchema() throws Exception { String typename = "NewType"; FeatureType t = DataUtilities.createType(typename, "*geom:Geometry"); data.createSchema(t); String[] names = data.getTypeNames(); boolean foundNewType = false; for (int i = 0; i < names.length; i++) { if (names[i].equalsIgnoreCase(typename)) { foundNewType = true; } } assertTrue(foundNewType); } }
protected FeatureWriter createWriter(final FeatureType _type) throws IOException { if (store_ != null) { store_.createSchema(_type); return store_.getFeatureWriter(_type.getTypeName(), Transaction.AUTO_COMMIT); } return new GMLFeatureWriter(_type, out_); }
public void createType(String namespace, String typeName, String typeSpec) throws IOException, SchemaException { Utilities.ensureNonNull("typeName",typeName); Utilities.ensureNonNull("typeSpec",typeSpec); final Lock lock=rwLock.writeLock(); try{ lock.lock(); checkStore(); final SimpleFeatureType featureType= DataUtilities.createType(namespace, typeName, typeSpec); tileIndexStore.createSchema(featureType); extractBasicProperties(featureType.getTypeName()); }finally{ lock.unlock(); } }
public void createType(String identification, String typeSpec) throws SchemaException, IOException { Utilities.ensureNonNull("typeSpec",typeSpec); Utilities.ensureNonNull("identification",identification); final Lock lock=rwLock.writeLock(); try{ lock.lock(); checkStore(); final SimpleFeatureType featureType= DataUtilities.createType(identification, typeSpec); tileIndexStore.createSchema(featureType); extractBasicProperties(featureType.getTypeName()); } finally{ lock.unlock(); } }