public void testCreate() throws Exception { dataStore.createSchema(zipCodeSchema); assertFeatureTypesEqual(zipCodeSchema, dataStore.getSchema(tname(ZIPCODE))); }
dataStore.createSchema(schema);
public void testCreateSchema() throws IOException { SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.init(lobSchema); tb.setName(tname("testLobCreate")); SimpleFeatureType ft = tb.buildFeatureType(); if (Arrays.asList(dataStore.getTypeNames()).contains(ft.getTypeName())) { dataStore.removeSchema(ft.getTypeName()); } dataStore.createSchema(ft); SimpleFeatureType ft2 = dataStore.getSchema(ft.getTypeName()); assertFeatureTypesEqual(ft, ft2); } }
dataStore.createSchema(featureType);
public void testCreateSchema() throws Exception { String featureTypeName = tname("building"); // create a featureType and write it to PostGIS CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", forceLongitudeFirst); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName(featureTypeName); ftb.add(aname("id"), Integer.class); ftb.add(aname("name"), String.class); ftb.add(aname("the_geom"), Point.class, crs); SimpleFeatureType newFT = ftb.buildFeatureType(); dataStore.createSchema(newFT); SimpleFeatureType newSchema = dataStore.getSchema(featureTypeName); assertNotNull(newSchema); assertEquals(3, newSchema.getAttributeCount()); }
protected Class checkGeometryType(Class geomClass) throws Exception { // we just prefix the table name with "t" otherwise we go beyond // the Oracle identifier max length limit (oh my my...) String featureTypeName = tname("t" + geomClass.getSimpleName()); // create a featureType and write it to PostGIS CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName(featureTypeName); ftb.add(aname("id"), Integer.class); ftb.add(aname("name"), String.class); ftb.add(aname("geom"), geomClass, crs); SimpleFeatureType newFT = ftb.buildFeatureType(); dataStore.createSchema(newFT); SimpleFeatureType newSchema = dataStore.getSchema(featureTypeName); assertNotNull(newSchema); assertEquals(3, newSchema.getAttributeCount()); return newSchema.getGeometryDescriptor().getType().getBinding(); } }
dataStore.createSchema(featureType);
public void testCreateSchemaFidColumn() throws Exception { // test a case where the feature type we are creating contains a column named "fid" SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(tname("ft2")); builder.setNamespaceURI(dataStore.getNamespaceURI()); builder.setCRS(getUTMCRS()); builder.add(aname("geometry"), Point.class); builder.add(aname("intProperty"), Integer.class); builder.add(aname("stringProperty"), String.class); builder.add(aname("fid"), String.class); SimpleFeatureType featureType = builder.buildFeatureType(); dataStore.createSchema(featureType); SimpleFeatureType ft2 = dataStore.getSchema(tname("ft2")); assertNotNull(ft2.getDescriptor(aname("fid"))); }
dataStore.createSchema(poly3DType); SimpleFeatureType actualSchema = dataStore.getSchema(tname(getPoly3d())); assertFeatureTypesEqual(poly3DType, actualSchema);
public void testCreateSchemaUTMCRS() throws Exception { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(tname("ft2")); builder.setNamespaceURI(dataStore.getNamespaceURI()); builder.setCRS(getUTMCRS()); builder.add(aname("geometry"), Point.class); builder.add(aname("intProperty"), Integer.class); builder.add(aname("stringProperty"), String.class); SimpleFeatureType featureType = builder.buildFeatureType(); dataStore.createSchema(featureType); SimpleFeatureType ft2 = dataStore.getSchema(tname("ft2")); assertNotNull(ft2); try (FeatureWriter w = dataStore.getFeatureWriter(tname("ft2"), Transaction.AUTO_COMMIT)) { w.hasNext(); // write out a feature with a geomety in teh srs, basically accomodate databases that // have // to query the first feature in order to get the srs for the feature type SimpleFeature f = (SimpleFeature) w.next(); Geometry g = new WKTReader().read("POINT(593493 4914730)"); g.setSRID(26713); f.setAttribute(0, g); f.setAttribute(1, Integer.valueOf(0)); f.setAttribute(2, "hello"); w.write(); } // clear out the feature type cache dataStore.getEntry(new NameImpl(dataStore.getNamespaceURI(), tname("ft2"))).dispose(); ft2 = dataStore.getSchema(tname("ft2")); assertTrue(CRS.equalsIgnoreMetadata(getUTMCRS(), ft2.getCoordinateReferenceSystem())); }
private void initialize(Map<String, Object> manualParameters) throws DaoException { try { PostGISVersionChecker versionChecker = new PostGISVersionChecker(); versionChecker.verifyVersion(manualParameters); store = (JDBCDataStore)DataStoreFinder.getDataStore(manualParameters); if (needsToBeInitialized()){ // needs to be initialized LOG.info("Initializing spatial database tables"); try { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(SPATIAL_DB_NAME); builder.add(ITEM_ID_FIELD_NAME, Integer.class); builder.add(LAYER_FIELD_NAME, String.class); builder.add(REF_SYS_FIELD_NAME, String.class); builder.add(GEOM_FIELD_NAME, Geometry.class); SimpleFeatureType featureType = builder.buildFeatureType(); store.createSchema(featureType); // note: gist index is created automatically above Index regIndex = new Index(SPATIAL_DB_NAME, "rs_layer_type", true, ITEM_ID_FIELD_NAME,LAYER_FIELD_NAME,REF_SYS_FIELD_NAME); Index itemIdIndex = new Index(SPATIAL_DB_NAME, "geometries_item_id", false, ITEM_ID_FIELD_NAME); store.createIndex(itemIdIndex); }catch(Exception e){ throw new DaoException(e); } }else{ LOG.info("Spatial database tables have already been initialized"); } }catch(Exception e){ throw new DaoException(e); } }
dataStore.createSchema(schema);
private void initialize(Map<String, Object> manualParameters) throws DaoException { try { PostGISVersionChecker versionChecker = new PostGISVersionChecker(); versionChecker.verifyVersion(manualParameters); store = (JDBCDataStore)DataStoreFinder.getDataStore(manualParameters); if (needsToBeInitialized()){ // needs to be initialized LOG.info("Initializing spatial database tables"); try { SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(SPATIAL_DB_NAME); builder.add(ITEM_ID_FIELD_NAME, Integer.class); builder.add(LAYER_FIELD_NAME, String.class); builder.add(REF_SYS_FIELD_NAME, String.class); builder.add(GEOM_FIELD_NAME, Geometry.class); SimpleFeatureType featureType = builder.buildFeatureType(); store.createSchema(featureType); // note: gist index is created automatically above Index regIndex = new Index(SPATIAL_DB_NAME, "rs_layer_type", true, ITEM_ID_FIELD_NAME,LAYER_FIELD_NAME,REF_SYS_FIELD_NAME); Index itemIdIndex = new Index(SPATIAL_DB_NAME, "geometries_item_id", false, ITEM_ID_FIELD_NAME); store.createIndex(itemIdIndex); }catch(Exception e){ throw new DaoException(e); } }else{ LOG.info("Spatial database tables have already been initialized"); } }catch(Exception e){ throw new DaoException(e); } }