SimpleFeature f = SimpleFeatureBuilder.build(schema, attributes, feature.getID());
/** * Constructs an empty feature to use as a Template for new content. * * <p>We may move this functionality to FeatureType.create( null )? * * @param featureType Type of feature we wish to create * @return A new Feature of type featureType */ public static SimpleFeature template(SimpleFeatureType featureType) throws IllegalAttributeException { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType), null); }
/** * Use the provided featureType to create an empty feature. * * <p>The {@link #defaultValues(SimpleFeatureType)} method is used to generate the intial values * (making use of {@link AttributeDescriptor#getDefaultValue()} as required. * * @param featureType * @param featureID * @return Craeted feature */ public static SimpleFeature template(SimpleFeatureType featureType, String featureID) { return SimpleFeatureBuilder.build(featureType, defaultValues(featureType), featureID); }
protected SimpleFeature readFeature(AttributeReader atts) throws IllegalAttributeException, IOException { for (int i = 0, ii = atts.getAttributeCount(); i < ii; i++) { attributes[i] = atts.read(i); } return SimpleFeatureBuilder.build(schema, attributes, null); }
@Override protected void setUp() throws Exception { super.setUp(); schema = DataUtilities.createType( "buildings", "the_geom:Geometry,name:String,ADDRESS:String"); feature = SimpleFeatureBuilder.build( schema, new Object[] {null, "ABC", "Random Road, 12"}, "building.1"); wkt = new WKTReader(); }
private SimpleFeature createPoint(double x, double y) { Coordinate coord = new Coordinate(x, y); return SimpleFeatureBuilder.build( testPointFeatureType, new Object[] {gf.createPoint(coord)}, null); }
public void testGetBoundsSupportsEmptyBounds() throws Exception { SimpleFeatureType type = DataUtilities.createType(getName() + ".test", "id:0,geom:LineString,name:String"); SimpleFeature[] features = new SimpleFeature[3]; features[0] = SimpleFeatureBuilder.build(type, new Object[] {1, null, "r1"}, "test.f1"); features[1] = SimpleFeatureBuilder.build(type, new Object[] {2, null, "r2"}, "test.f2"); features[2] = SimpleFeatureBuilder.build(type, new Object[] {3, null, "r3"}, "test.f3"); data.addFeatures(features); SimpleFeatureSource featureSource = data.getFeatureSource("test"); assertTrue(featureSource.getBounds(Query.ALL).isEmpty()); } }
public static SimpleFeature createFeature() { try { SimpleFeatureType testType = createTestType(); Object[] attributes = createAttributes(); return SimpleFeatureBuilder.build(testType, attributes, null); } catch (Exception e) { Error ae = new AssertionError("Sample Feature for tests has been misscoded"); ae.initCause(e); throw ae; } }
private SimpleFeature createFeatures(SimpleFeatureType ft, int i) throws IllegalAttributeException { GeometryFactory fac = new GeometryFactory(); return SimpleFeatureBuilder.build( ft, new Object[] { fac.createPoint(new Coordinate(i, i)), "name" + i, Integer.valueOf(i) }, null); }
private SimpleFeature createLine(double x1, double y1, double x2, double y2) { Coordinate[] coords = new Coordinate[] {new Coordinate(x1, y1), new Coordinate(x2, y2)}; return SimpleFeatureBuilder.build( testLineFeatureType, new Object[] {gf.createLineString(coords)}, null); }
private SimpleFeature createLine(double x1, double y1, double x2, double y2) throws IllegalAttributeException { Coordinate[] coords = new Coordinate[] {new Coordinate(x1, y1), new Coordinate(x2, y2)}; return SimpleFeatureBuilder.build( pointFeautureType, new Object[] {gf.createLineString(coords)}, null); }
public void testClone2() throws Exception { SimpleFeatureType type = SampleFeatureFixtures.createTestType(); Object[] attributes = SampleFeatureFixtures.createAttributes(); SimpleFeature feature = SimpleFeatureBuilder.build(type, attributes, "fid"); SimpleFeature clone = SimpleFeatureBuilder.deep(feature); assertTrue("Clone was not equal", feature.equals(clone)); }
protected void setUp() throws Exception { super.setUp(); type = DataUtilities.createType("default", "name:String,*geom:Geometry"); GeometryFactory fac = new GeometryFactory(); geom = fac.createPoint(new Coordinate(10, 10)); SimpleFeature f1 = SimpleFeatureBuilder.build(type, new Object[] {"original", geom}, null); ds = new MemoryDataStore(new SimpleFeature[] {f1}); }
public void testEquals() throws Exception { SimpleFeature f1 = SampleFeatureFixtures.createFeature(); SimpleFeature f2 = SampleFeatureFixtures.createFeature(); assertTrue(f1.equals(f1)); assertTrue(f2.equals(f2)); assertTrue(!f1.equals(f2)); assertTrue(!f1.equals(null)); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("different"); tb.add("name", String.class); SimpleFeatureType type = tb.buildFeatureType(); assertTrue(!f1.equals(SimpleFeatureBuilder.build(type, new Object[1], null))); }
public void testAddFeature() throws Exception { SimpleFeature f1 = SimpleFeatureBuilder.build(type, new Object[] {"one", geom}, null); SimpleFeature f2 = SimpleFeatureBuilder.build(type, new Object[] {"two", geom}, null); SimpleFeatureStore store = (SimpleFeatureStore) ds.getFeatureSource("default"); store.setTransaction(new DefaultTransaction()); store.addFeatures(DataUtilities.collection(f1)); store.addFeatures(DataUtilities.collection(f2)); count(store, 3); // assertEquals("Number of known feature as obtained from getCount",3, // store.getCount(Query.ALL)); }
public void testSetValue() { SimpleFeature myFeature = SimpleFeatureBuilder.build(schema, new Object[] {null, null, null}, "building.2"); myFeature.setValue(feature.getProperties()); for (int i = 0; i < feature.getAttributeCount(); i++) { assertEquals(feature.getAttribute(i), myFeature.getAttribute(i)); } }
public void testWithoutRestriction() { // used to prevent warning FilterFactory fac = CommonFactoryFinder.getFilterFactory(null); String attributeName = "string"; SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); // $NON-NLS-1$ builder.setName("test"); builder.add(attributeName, String.class); SimpleFeatureType featureType = builder.buildFeatureType(); SimpleFeature feature = SimpleFeatureBuilder.build(featureType, new Object[] {"Value"}, null); assertNotNull(feature); } /** This utility class is used by Types to prevent attribute modification. */
public void testRenderEmptyCollection() throws SchemaException, IllegalAttributeException { GeometryFactory gf = new GeometryFactory(); StyleBuilder sb = new StyleBuilder(); SimpleFeatureType pointType = DataUtilities.createType("emptyPolygon", "geom:MultiPolygon,name:String"); SimpleFeature f = SimpleFeatureBuilder.build( pointType, new Object[] {gf.createMultiPolygon((Polygon[]) null), "name"}, null); Style style = sb.createStyle(sb.createPolygonSymbolizer()); renderEmptyGeometry(f, style); }
public void testMixedEmptyMultiLine() throws SchemaException, IllegalAttributeException { GeometryFactory gf = new GeometryFactory(); StyleBuilder sb = new StyleBuilder(); SimpleFeatureType pointType = DataUtilities.createType("emptyRings", "geom:MultiLineString,name:String"); LineString emptyLine = gf.createLineString((Coordinate[]) null); LineString realLine = gf.createLineString(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 1)}); MultiLineString mls = gf.createMultiLineString(new LineString[] {emptyLine, realLine}); SimpleFeature f = SimpleFeatureBuilder.build(pointType, new Object[] {mls, "name"}, null); Style style = sb.createStyle(sb.createPolygonSymbolizer()); renderEmptyGeometry(f, style); }