/** * Configures the dimension of a vector layer * * @param featureTypeName The feature type name * @param dimensionName The dimension name (key in the resource metadata map) * @param presentation The chosen presentation * @param resolution The resolution * @param units The units * @param unitSymbol The unit symbol */ protected void setupRasterDimension( QName layer, String dimensionName, DimensionPresentation presentation, Double resolution, String units, String unitSymbol) { CoverageInfo info = getCatalog().getCoverageByName(layer.getLocalPart()); DimensionInfo di = new DimensionInfoImpl(); di.setEnabled(true); di.setPresentation(presentation); if (resolution != null) { di.setResolution(new BigDecimal(resolution)); } di.setUnits(units); di.setUnitSymbol(unitSymbol); info.getMetadata().put(dimensionName, di); getCatalog().save(info); }
/** * 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(); }
protected void setupRasterDimension(String metadata, DimensionPresentation presentation, Double resolution) { CoverageInfo info = getCatalog().getCoverageByName(WATTEMP.getLocalPart()); DimensionInfo di = new DimensionInfoImpl(); di.setEnabled(true); di.setPresentation(presentation); if(resolution != null) { di.setResolution(new BigDecimal(resolution)); } info.getMetadata().put(metadata, di); getCatalog().save(info); } }
Set<String> getEnabledDimensionNames(LayerInfo layer) { Set<String> dimensionNames = new HashSet<String>(); for (Map.Entry<String, Serializable> entry : layer.getResource().getMetadata().entrySet()) { String key = entry.getKey(); Serializable md = entry.getValue(); if (md instanceof DimensionInfo) { // skip disabled dimensions DimensionInfo di = (DimensionInfo) md; if (!di.isEnabled()) { continue; } // get the dimension name String dimensionName; if (key.startsWith(ResourceInfo.CUSTOM_DIMENSION_PREFIX)) { dimensionName = key.substring(ResourceInfo.CUSTOM_DIMENSION_PREFIX.length()); } else { dimensionName = key; } dimensionNames.add(dimensionName); } } return dimensionNames; }
protected void setupCoverageElevationDimension( QName name, DimensionDefaultValueSetting defaultValue) { CoverageInfo info = getCatalog().getCoverageByName(name.getLocalPart()); DimensionInfo di = new DimensionInfoImpl(); di.setEnabled(true); di.setPresentation(DimensionPresentation.LIST); di.setDefaultValue(defaultValue); info.getMetadata().put(ResourceInfo.ELEVATION, di); getCatalog().save(info); } }
private void setupRasterDimension(String metadata, DimensionPresentation presentation) { CoverageInfo info = getCatalog().getCoverageByName(CUST_WATTEMP.getLocalPart()); DimensionInfo di = new DimensionInfoImpl(); di.setEnabled(true); di.setPresentation(presentation); info.getMetadata().put(ResourceInfo.CUSTOM_DIMENSION_PREFIX + metadata, di); getCatalog().save(info); } }
final WebMarkupContainer configs = new WebMarkupContainer("configs"); configs.setOutputMarkupId(true); configs.setVisible(getModelObject().isEnabled()); configsContainer.add(configs); final WebMarkupContainer resolutions = new WebMarkupContainer("resolutions"); resolutions.setVisible( model.getObject().getPresentation() == DimensionPresentation.DISCRETE_INTERVAL); resolutions.setOutputMarkupId(true); resContainer.add(resolutions); DimensionDefaultValueSetting defValueSetting = model.getObject().getDefaultValue(); if (defValueSetting == null) { defValueSetting = new DimensionDefaultValueSetting(); model.getObject().setDefaultValue(defValueSetting); IModel<DimensionDefaultValueSetting.Strategy> strategyModel = new PropertyModel<DimensionDefaultValueSetting.Strategy>( model.getObject().getDefaultValue(), "strategy"); defaultValueStrategy = new DropDownChoice<DimensionDefaultValueSetting.Strategy>( new PropertyModel<String>(model.getObject().getDefaultValue(), "referenceValue"); referenceValue = new TextField<>("referenceValue", refValueModel); referenceValue.add( WebMarkupContainer acceptableIntervalEditor = new WebMarkupContainer("acceptableIntervalEditor"); acceptableIntervalEditor.setVisible(model.getObject().isNearestMatchEnabled());
if (elevation == null || !elevation.isEnabled()) { throw new ServiceException( "Layer " if (elevation.getPresentation() == DimensionPresentation.LIST || (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());
/** * Builds the proper presentation given the specified value domain * * @param dimension * @param values */ String getCustomDomainRepresentation(DimensionInfo dimension, List<String> values) { String metadata = null; final StringBuilder buff = new StringBuilder(); if (DimensionPresentation.LIST == dimension.getPresentation()) { for (String value : values) { buff.append(value.trim()); buff.append(","); } metadata = buff.substring(0, buff.length() - 1); } else if (DimensionPresentation.DISCRETE_INTERVAL == dimension.getPresentation()) { buff.append(values.get(0)); buff.append("/"); buff.append(values.get(0)); buff.append("/"); final BigDecimal resolution = dimension.getResolution(); if (resolution != null) { buff.append(resolution); } metadata = buff.toString(); } return metadata; }
DimensionInfo elevInfo = typeInfo.getMetadata().get(ResourceInfo.ELEVATION, DimensionInfo.class); boolean hasTime = timeInfo != null && timeInfo.isEnabled(); boolean hasElevation = elevInfo != null && elevInfo.isEnabled(); String elevUnits = hasElevation ? elevInfo.getUnits() : ""; String elevUnitSymbol = hasElevation ? elevInfo.getUnitSymbol() : ""; declareWMS11Dimensions(hasTime, hasElevation, elevUnits, elevUnitSymbol, null);
if (time == null || !time.isEnabled()) { throw new ServiceException( "Layer " + typeInfo.prefixedName() + " does not have time support enabled"); if (time.getPresentation() == DimensionPresentation.LIST) { 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());
if (timeInfo != null && timeInfo.isEnabled() && times != null) { List<Object> defaultedTimes = new ArrayList<>(times.size()); for (Object datetime : times) { if (timeInfo.isNearestMatchEnabled()) { List<Object> nearestMatchedTimes = getNearestMatches(typeInfo, timeInfo, defaultedTimes, ResourceInfo.TIME); builder.appendFilters( timeInfo.getAttribute(), timeInfo.getEndAttribute(), nearestMatchedTimes); } else { builder.appendFilters( timeInfo.getAttribute(), timeInfo.getEndAttribute(), defaultedTimes); if (elevationInfo != null && elevationInfo.isEnabled() && elevations != null) { List<Object> defaultedElevations = new ArrayList<Object>(elevations.size()); for (Object elevation : elevations) { elevationInfo.getAttribute(), elevationInfo.getEndAttribute(), defaultedElevations);
@Test public void testGetCustomDomainRepresentation() { final String[] vals = new String[] {"value with spaces", "value", " other values "}; final List<String> values = new ArrayList<String>(); for (String val : vals) values.add(val); DimensionInfo dimensionInfo = new DimensionInfoImpl(); dimensionInfo.setPresentation(DimensionPresentation.LIST); dimensionInfo.setResolution(new BigDecimal(1)); String customDimRepr = dimensionHelper.getCustomDomainRepresentation(dimensionInfo, values); // value with spaces,value Assert.equals(customDimRepr, vals[0] + "," + vals[1] + "," + vals[2].trim()); // System.out.print(vals.toString()); }
final WebMarkupContainer configs = new WebMarkupContainer("configs"); configs.setOutputMarkupId(true); configs.setVisible(getModelObject().isEnabled()); configsContainer.add(configs); final WebMarkupContainer resolutions = new WebMarkupContainer("resolutions"); resolutions .setVisible(model.getObject().getPresentation() == DimensionPresentation.DISCRETE_INTERVAL); resolutions.setOutputMarkupId(true); resContainer.add(resolutions);
/** Returns the type of presentation for the time dimension */ public DimensionPresentation getPresentation() { return timeDimension.getPresentation(); }
TreeSet<Object> elevations = null; try { if (elevInfo.getPresentation() != DimensionPresentation.LIST) { Double minValue = dimensions.getMinElevation(); if (minValue != null) { elevations, elevationMetadata, elevInfo.getUnits(), elevInfo.getUnitSymbol(), defaultValue);
if (di == null || !di.isEnabled()) { throw new ServiceException( "Layer " query.setPropertyNames(Arrays.asList(di.getAttribute())); final PropertyName attribute = ff.property(di.getAttribute()); final PropertyIsBetween rangeFilter = ff.between(
Set<ParameterDescriptor<List>> dynamicParameters = reader.getDynamicParameters(); parameterDescriptors.addAll(dynamicParameters); if (timeInfo != null && timeInfo.isEnabled()) { if (timeInfo.isNearestMatchEnabled()) { fixedTimes = getNearestMatches(coverage, timeInfo, fixedTimes, ResourceInfo.TIME); if (elevationInfo != null && elevationInfo.isEnabled()) { metadata.get( ResourceInfo.CUSTOM_DIMENSION_PREFIX + name, DimensionInfo.class); if (customInfo != null && customInfo.isEnabled()) { Object val = dimensions.convertDimensionValue(
@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); } } }
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; }