/** * Creates a shallow copy of the given Dimension object * * @param info */ public DimensionInfoImpl(DimensionInfo info) { super(); this.enabled = info.isEnabled(); this.attribute = info.getAttribute(); this.endAttribute = info.getEndAttribute(); this.presentation = info.getPresentation(); this.resolution = info.getResolution(); this.units = info.getUnits(); this.unitSymbol = info.getUnitSymbol(); this.defaultValue = info.getDefaultValue(); this.enabled = info.isEnabled(); }
private String[] getAttribute(final MetadataMap metadata, final String attributeName) { if (metadata != null && metadata.containsKey(attributeName)) { DimensionInfo dimension = metadata.get(attributeName, DimensionInfo.class); final String attribute = dimension.getAttribute(); final String endAttribute = dimension.getEndAttribute(); return new String[] {attribute, endAttribute}; } return new String[] {}; }
@Override public Object getDefaultValue( ResourceInfo resource, String dimensionName, DimensionInfo dimension, Class clz) { final MaxVisitor max = new MaxVisitor(dimension.getAttribute()); CalcResult res = getCalculatedResult((FeatureTypeInfo) resource, dimension, max); if (res.equals(CalcResult.NULL_RESULT)) { return null; } else { return Converters.convert(max.getMax(), clz); } } }
@Override public Object getDefaultValue( ResourceInfo resource, String dimensionName, DimensionInfo dimension, Class clz) { final MinVisitor min = new MinVisitor(dimension.getAttribute()); CalcResult res = getCalculatedResult((FeatureTypeInfo) resource, dimension, min); if (res.equals(CalcResult.NULL_RESULT)) { return null; } else { return Converters.convert(min.getMin(), clz); } } }
/** * Return the result of iterating through the dimension collection of the given dimension using * given calculator as the attribute value calculator. * * @param typeInfo * @param dimension * @param calculator */ protected CalcResult getCalculatedResult( FeatureTypeInfo typeInfo, DimensionInfo dimension, FeatureCalc calculator) { CalcResult retval = null; try { FeatureCollection<?, ?> dimensionCollection = getDimensionCollection(typeInfo, dimension); if (dimensionCollection == null) { throw new ServiceException( "No dimension collection given, cannot select default value for dimension based on attribute" + dimension.getAttribute()); } dimensionCollection.accepts(calculator, null); retval = calculator.getResult(); } catch (IOException e) { LOGGER.log(Level.FINER, e.getMessage(), e); } return retval; }
@Override public Object getDefaultValue( ResourceInfo resource, String dimensionName, DimensionInfo dimension, Class clz) { String attrName = dimension.getAttribute(); Class<?> attrType = String.class; if (resource instanceof FeatureTypeInfo) { List<AttributeTypeInfo> attrTypes; try { attrTypes = ((FeatureTypeInfo) resource).attributes(); for (AttributeTypeInfo attr : attrTypes) { if (attr.getName().equals(attrName)) { attrType = attr.getBinding(); break; } } } catch (IOException e) { } } final FeatureCalc nearest = new NearestVisitor(ff.property(dimension.getAttribute()), this.toMatch); CalcResult res = getCalculatedResult((FeatureTypeInfo) resource, dimension, nearest); if (res.equals(CalcResult.NULL_RESULT)) { return null; } else { return Converters.convert(res.getValue(), clz); } }
final UniqueVisitor visitor = new UniqueVisitor(time.getAttribute()); collection.accepts(visitor, null); final MinVisitor min = new MinVisitor(time.getAttribute()); collection.accepts(min, null); CalcResult minResult = min.getResult(); final MaxVisitor max = new MaxVisitor(time.getAttribute()); collection.accepts(max, null); result.add((Date) max.getMax());
|| (elevation.getPresentation() == DimensionPresentation.DISCRETE_INTERVAL && elevation.getResolution() == null)) { final UniqueVisitor visitor = new UniqueVisitor(elevation.getAttribute()); collection.accepts(visitor, null); final MinVisitor min = new MinVisitor(elevation.getAttribute()); collection.accepts(min, null); if (calcResult != CalcResult.NULL_RESULT) { result.add(((Number) min.getMin()).doubleValue()); final MaxVisitor max = new MaxVisitor(elevation.getAttribute()); collection.accepts(max, null); result.add(((Number) max.getMax()).doubleValue());
/** * Returns the collection of all values of the dimension attribute, eventually sorted if the * native capabilities allow for it * * @param typeInfo * @param dimension * @throws IOException */ FeatureCollection getDimensionCollection(FeatureTypeInfo typeInfo, DimensionInfo dimension) throws IOException { FeatureSource source = getFeatureSource(typeInfo); // build query to grab the dimension values final Query dimQuery = new Query(source.getSchema().getName().getLocalPart()); dimQuery.setPropertyNames(Arrays.asList(dimension.getAttribute())); return source.getFeatures(dimQuery); }
getNearestMatches(typeInfo, timeInfo, defaultedTimes, ResourceInfo.TIME); builder.appendFilters( timeInfo.getAttribute(), timeInfo.getEndAttribute(), nearestMatchedTimes); } else { builder.appendFilters( timeInfo.getAttribute(), timeInfo.getEndAttribute(), defaultedTimes); elevationInfo.getAttribute(), elevationInfo.getEndAttribute(), defaultedElevations);
private FeatureCollection<?, ?> getDimensionCollection( FeatureTypeInfo typeInfo, DimensionInfo dimension) throws IOException { // grab the feature source FeatureSource<?, ?> source = null; try { source = typeInfo.getFeatureSource(null, GeoTools.getDefaultHints()); } catch (IOException e) { throw new ServiceException( "Could not get the feauture source to list time info for layer " + typeInfo.prefixedName(), e); } // build query to grab the dimension values final Query dimQuery = new Query(source.getSchema().getName().getLocalPart()); dimQuery.setPropertyNames(Arrays.asList(dimension.getAttribute())); return source.getFeatures(dimQuery); } }
query.setPropertyNames(Arrays.asList(di.getAttribute())); final PropertyName attribute = ff.property(di.getAttribute()); final PropertyIsBetween rangeFilter = ff.between(
private LayerInfo validateBasicLayerStructure( String workspace, String layerName, String[] expectedNames) { // check the configuration elements are there too Catalog catalog = getCatalog(); // ... the store CoverageStoreInfo store = catalog.getCoverageStoreByName(workspace, "test123"); assertNotNull(store); assertThat(store.getFormat(), instanceOf(ImageMosaicFormat.class)); // ... the layer LayerInfo layer = catalog.getLayerByName(layerName); assertNotNull(layer); final CoverageInfo coverageInfo = (CoverageInfo) layer.getResource(); assertThat(coverageInfo.getStore(), equalTo(store)); // ... the resource is time enabled DimensionInfo dimension = coverageInfo.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class); assertThat(dimension.getAttribute(), equalTo("timeStart")); assertThat(dimension.getDefaultValue().getStrategyType(), equalTo(Strategy.MAXIMUM)); // ... has the expected bands String[] names = coverageInfo .getDimensions() .stream() .map(cd -> cd.getName()) .toArray(String[]::new); assertThat(expectedNames, equalTo(names)); return layer; }
return new Vector( featureType, dimensionInfo.getAttribute(), dimensionInfo.getEndAttribute(), acceptableRange,