/** Add the bbox element to the metadata Map */ private void addBBOX( boolean aggregate, Filter filter, SimpleFeature firstFeature, Map<String, Object> metadataMap) throws IOException { ReferencedEnvelope envelope = null; if (aggregate) { BoundsVisitor boundsVisitor = new BoundsVisitor(); Query query = new Query(typeName); query.setFilter(filter); granuleCatalog.computeAggregateFunction(query, boundsVisitor); envelope = boundsVisitor.getBounds(); } else { envelope = new ReferencedEnvelope(firstFeature.getBounds()); } if (envelope != null) { metadataMap.put(Utils.BBOX, envelope); } }
/** * Calculate unique (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the unique * @return An object containing the unique value of the attributes * @throws IllegalFilterException * @throws IOException */ static CalcResult calculateBounds( FeatureCollection<? extends FeatureType, ? extends Feature> collection) throws IllegalFilterException, IOException { BoundsVisitor boundsVisitor = new BoundsVisitor(); collection.accepts(boundsVisitor, null); return boundsVisitor.getResult(); }
BoundsVisitor visitor = new BoundsVisitor(); for (SimpleFeature feature: features) { visitor.visit(feature); Envelope env = visitor.getBounds();
public void testBounds() throws IOException { BoundsVisitor boundsVisitor1 = new BoundsVisitor(); fc.accepts(boundsVisitor1, null); BoundsVisitor boundsVisitor2 = new BoundsVisitor(); fc2.accepts(boundsVisitor2, null); Envelope env1 = new Envelope(1, 5, 0, 4); CalcResult boundsResult1 = boundsVisitor1.getResult(); assertEquals(env1, boundsResult1.toEnvelope()); Envelope env2 = new Envelope(4, 13, 3, 10); CalcResult boundsResult2 = boundsVisitor2.getResult(); assertEquals(env2, boundsResult2.toEnvelope()); CalcResult boundsResult3 = boundsResult2.merge(boundsResult1); Envelope env3 = new Envelope(1, 13, 0, 10); assertEquals(env3, boundsResult3.toEnvelope()); // test empty collection boundsVisitor1.reset(null); empty.accepts(boundsVisitor1, null); assertEquals(CalcResult.NULL_RESULT, boundsVisitor1.getResult()); // test merge assertSame(boundsResult2, boundsVisitor1.getResult().merge(boundsResult2)); assertSame(boundsResult2, boundsResult2.merge(boundsVisitor1.getResult())); }
public void testBoundsNotOptimized() throws Exception { BoundsVisitor boundsVisitor = new BoundsVisitor(); SimpleFeatureCollection retypedCollection = new ReprojectFeatureResults(visitorCollection, utm32n); retypedCollection.accepts(boundsVisitor, null); // not optimized assertNull(lastVisitor); } }
@Override public void writeFeatures(DataStore datastore, SimpleFeatureType sft, List<SimpleFeature> features) throws IOException { BoundsVisitor visitor = new BoundsVisitor(); for (SimpleFeature feature: features) { visitor.visit(feature); Envelope env = visitor.getBounds(); System.out.println("Feature type created - register the layer '" + sft.getTypeName() + "' in geoserver with bounds: MinX[" + env.getMinX() + "] MinY[" +
public void testBoundsNotOptimized() throws IOException, SchemaException { BoundsVisitor boundsVisitor = new BoundsVisitor(); SimpleFeatureCollection retypedCollection = new ForceCoordinateSystemFeatureResults(visitorCollection, utm32n); retypedCollection.accepts(boundsVisitor, null); // not optimized assertNull(lastVisitor); } }
/** * Calculates the bounds of the features without caching. */ @Override public ReferencedEnvelope getBounds() { BoundsVisitor bounds = new BoundsVisitor(); accepts(bounds, new NullProgressListener()); return bounds.getBounds(); }
/** * Calculate unique (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the unique * * @return An object containing the unique value of the attributes * * @throws IllegalFilterException * @throws IOException */ public static CalcResult calculateBounds(FeatureCollection collection) throws IllegalFilterException, IOException { BoundsVisitor boundsVisitor = new BoundsVisitor(); collection.accepts(boundsVisitor, null); return boundsVisitor.getResult(); }
/** * Calculates the bounds of the features without caching. * * TODO Have some pro look at this code. * author by Stefan Krueger */ @Override public ReferencedEnvelope getBounds() { BoundsVisitor bounds = new BoundsVisitor(); accepts( bounds, new NullProgressListener() ); return bounds.getBounds(); }
/** * Calculate unique (using FeatureCalc) - only one parameter is used. * * @param collection collection to calculate the unique * * @return An object containing the unique value of the attributes * * @throws IllegalFilterException * @throws IOException */ static CalcResult calculateBounds( FeatureCollection<? extends FeatureType, ? extends Feature> collection) throws IllegalFilterException, IOException { BoundsVisitor boundsVisitor = new BoundsVisitor(); collection.accepts(boundsVisitor, null); return boundsVisitor.getResult(); }