public void testCompositeEmpty() { CompositeFeatureCollection fc = new CompositeFeatureCollection(new ArrayList<>()); assertEquals(0, fc.size()); assertEquals(null, fc.getBounds()); assertEquals(null, DataUtilities.first(fc)); }
public void testComposeOne() { CompositeFeatureCollection fc = new CompositeFeatureCollection( Arrays.asList(DataUtilities.collection(riverFeatures[0]))); assertEquals(1, fc.size()); assertEquals( new ReferencedEnvelope(5, 13, 3, 7, riverType.getCoordinateReferenceSystem()), fc.getBounds()); assertEquals(riverFeatures[0], DataUtilities.first(fc)); }
public void testComposeMany() { SimpleFeatureCollection roads = DataUtilities.collection(roadFeatures); SimpleFeatureCollection rivers = DataUtilities.collection(riverFeatures); SimpleFeatureCollection lakes = DataUtilities.collection(lakeFeatures); CompositeFeatureCollection fc = new CompositeFeatureCollection(Arrays.asList(roads, rivers, lakes)); // 3 roads, 2 rivers, 1 lake assertEquals(6, fc.size()); assertEquals( new ReferencedEnvelope(1, 16, 0, 10, riverType.getCoordinateReferenceSystem()), fc.getBounds()); assertEquals(roadFeatures[0], DataUtilities.first(fc)); } }
@Test public void testCoverageViewGranuleSource() throws Exception { final String VIEW_NAME = "view"; CoverageInfo info = buildHeterogeneousResolutionView( VIEW_NAME, cv -> { cv.setSelectedResolution(SelectedResolution.BEST); }, "B02", "B03", "B04"); StructuredGridCoverage2DReader reader = (StructuredGridCoverage2DReader) info.getGridCoverageReader(null, null); GranuleSource source = reader.getGranules(VIEW_NAME, true); Query query = new Query(VIEW_NAME); // used to throw exception here SimpleFeatureCollection granules = source.getGranules(query); // just check we can pull data from it DataUtilities.first(granules); // there are three bands, so three granules making up the coverage assertEquals(3, granules.size()); }
valueSource = ValueSource.EXPRESSION; SimpleFeature feature = DataUtilities.first(features); Object value = ((Expression) attribute).evaluate(feature);
public void testFirst() { SimpleFeatureCollection collection = DataUtilities.collection(roadFeatures); SimpleFeature first = DataUtilities.first(collection); assertNotNull(first); assertEquals("road.rd1", first.getID()); }
ContentFeatureCollection features = featureStore.getFeatures(filter); assertEquals(1, features.size()); SimpleFeature found = DataUtilities.first(features); assertEquals(theValue, found.getAttribute(theProperty)); return null;
public void testGeometryFactoryHint() throws Exception { FilterFactory ff = dataStore.getFilterFactory(); PropertyIsEqualTo filter = ff.equals(ff.property(aname("stringProperty")), ff.literal("one")); Query query = new Query(); query.setFilter(filter); // check we're respecting the geometry factory hint GeometryFactory gf1 = new GeometryFactory(); query.setHints(new Hints(Hints.JTS_GEOMETRY_FACTORY, gf1)); SimpleFeature f1 = DataUtilities.first(featureSource.getFeatures(query)); assertSame(gf1, ((Geometry) f1.getDefaultGeometry()).getFactory()); // check we're respecting the geometry factory when changing it GeometryFactory gf2 = new GeometryFactory(); query.setHints(new Hints(Hints.JTS_GEOMETRY_FACTORY, gf2)); SimpleFeature f2 = DataUtilities.first(featureSource.getFeatures(query)); assertSame(gf2, ((Geometry) f2.getDefaultGeometry()).getFactory()); }
private Object getPropertyFromFirstFeature( FeatureCollection<FeatureType, Feature> features, Name propertyName) { Feature feature = DataUtilities.first(features); Property property; Object value; if (feature == null || // ((property = feature.getProperty(propertyName)) == null) || // ((value = property.getValue()) == null)) { return null; } return value; }
@Override public SimpleFeatureIterator features() { openIterators.incrementAndGet(); final SimpleFeature f = DataUtilities.first(delegate); return new SimpleFeatureIterator() { @Override public SimpleFeature next() throws NoSuchElementException { return f; } @Override public boolean hasNext() { return true; } @Override public void close() { openIterators.decrementAndGet(); } }; } };
public void testBetweenNegation() throws Exception { Not filter = ff.not( ff.between( ff.property(aname(B)), ff.property(aname(A)), ff.property(aname(C)))); ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC)); Query q = new Query(tname(ABC), filter); int count = fs.getCount(q); assertEquals(1, count); SimpleFeature f = DataUtilities.first(fs.getFeatures(q)); assertEquals("n_n_n", f.getAttribute(aname(NAME))); }
public void test() throws Exception { Not filter = ff.not( ff.between( ff.property(aname(B)), ff.property(aname(A)), ff.property(aname(C)))); ContentFeatureSource fs = dataStore.getFeatureSource(tname(ABC)); Query q = new Query(tname(ABC), filter); int count = fs.getCount(q); assertEquals(1, count); SimpleFeature f = DataUtilities.first(fs.getFeatures(q)); assertEquals("n_n_n", f.getAttribute(aname(NAME))); } }
Feature gridWrapper = DataUtilities.first(sample);
private SimpleFeature getCollectionFeature( String collectionName, JDBCDataStore delegate, String collectionTableName) throws IOException { final PropertyIsEqualTo collectionNameFilter = FF.equal(FF.property("name"), FF.literal(collectionName), true); final ContentFeatureCollection collections = delegate.getFeatureSource(collectionTableName).getFeatures(collectionNameFilter); SimpleFeature collectionFeature = DataUtilities.first(collections); return collectionFeature; }
protected Feature queryCollection(String collectionName, Consumer<Query> queryDecorator) throws IOException { Query query = new Query(); query.setFilter(FF.equal(FF.property("name"), FF.literal(collectionName), true)); queryDecorator.accept(query); FeatureCollection<FeatureType, Feature> fc = queryCollections(query); Feature feature = DataUtilities.first(fc); if (feature == null) { throw new ResourceNotFoundException( "Could not find a collection named '" + collectionName + "'"); } return feature; }
private Feature getLayerPropertyFromCollection( FeatureCollection<FeatureType, Feature> features) { // get the simple feature representing the layer publishing info Feature collection = DataUtilities.first(features); assertNotNull(collection); Property layerProperty = collection.getProperty(LAYER_NAME); assertThat(layerProperty, notNullValue()); final Feature layerValue = (Feature) layerProperty; return layerValue; }
private Feature queryProduct(String collection, String product, Consumer<Query> queryDecorator) throws IOException { // query products Query query = new Query(); Filter filter = getProductFilter(collection, product); query.setFilter(filter); queryDecorator.accept(query); OpenSearchAccess access = accessProvider.getOpenSearchAccess(); FeatureSource<FeatureType, Feature> fs = access.getProductSource(); FeatureCollection<FeatureType, Feature> features = fs.getFeatures(query); Feature feature = DataUtilities.first(features); if (feature == null) { throwProductNotFound(collection, product, "Product"); } return feature; }
private SimpleFeature getFeatureFromStore(String fid) throws IOException { FeatureTypeInfo ftInfo = getCatalog().getFeatureTypeByName(getLayerId(FULL3D)); SimpleFeatureSource featureSource = (SimpleFeatureSource) ftInfo.getFeatureSource(null, null); SimpleFeatureCollection fc = featureSource.getFeatures(FF.id(FF.featureId(fid))); SimpleFeature first = DataUtilities.first(fc); return first; }
private SimpleFeature getSingleFeature(QName typeName, String featureName) throws IOException, CQLException { FeatureTypeInfo ft = getCatalog().getFeatureTypeByName(getLayerId(typeName)); SimpleFeatureSource fs = (SimpleFeatureSource) ft.getFeatureSource(null, null); SimpleFeature first = DataUtilities.first(fs.getFeatures(ECQL.toFilter("name = '" + featureName + "'"))); assertNotNull(first); return first; }