public CoverageDimensionImpl(CoverageDimensionInfo other) { this.id = other.getId(); this.name = other.getName(); this.description = other.getDescription(); this.range = other.getRange(); this.nullValues = other.getNullValues(); this.unit = other.getUnit(); this.dimensionType = other.getDimensionType(); }
GridSampleDimension sd = sampleDimensions[i]; String name = sd.getDescription().toString(Locale.getDefault()); dim.setName(name); formatUOM(label, uom); label.append(")".intern()); dim.setUnit(GeoToolsUnitFormat.getInstance().format(uom)); } else if (uName.startsWith("RED") || uName.startsWith("GREEN") || uName.startsWith("BLUE")) { dim.setUnit("W.m-2.Sr-1"); dim.setDimensionType(sd.getSampleDimensionType()); label.append("]".intern()); dim.setDescription(label.toString()); dim.setRange(NumberRange.create(sdMin, sdMax)); double max = cat.getRange().getMaximum(); dim.getNullValues().add(min); if (min != max) { dim.getNullValues().add(max);
private CoverageDimensionInfo buildAlphaChannelDimnsionInfo(CoverageDimensionInfo sample) { CoverageDimensionInfo result = new CoverageDimensionImpl(sample); result.setName("ALPHA_BAND"); result.setDescription("Alpha"); return result; }
public static WrappedSampleDimension build( GridSampleDimension sampleDim, CoverageDimensionInfo info) { String name = info.getName(); final InternationalString sampleDimDescription = sampleDim.getDescription(); InternationalString configuredDescription = : sampleDimDescription; final List<Category> categories = sampleDim.getCategories(); NumberRange configuredRange = info.getRange(); final String uom = info.getUnit(); Unit defaultUnit = sampleDim.getUnits(); Unit unit = defaultUnit; final List<Double> nullValues = info.getNullValues(); double[] configuredNoDataValues; if (nullValues != null && nullValues.size() > 0) {
List<CoverageDimensionInfo> dimensions = c.getDimensions(); CoverageDimensionInfo dimension = dimensions.get(0); assertEquals("RED_BAND", dimension.getName()); NumberRange range = dimension.getRange(); assertEquals(Double.NEGATIVE_INFINITY, range.getMinimum(), DELTA); assertEquals(Double.POSITIVE_INFINITY, range.getMaximum(), DELTA); assertEquals("GridSampleDimension[-Infinity,Infinity]", dimension.getDescription()); List<Double> nullValues = dimension.getNullValues(); assertEquals(0, nullValues.size()); assertEquals("W.m-2.Sr-1", dimension.getUnit()); dimensionInfo.getNullValues().add(-999d); dimensionInfo.setDescription("GridSampleDimension[-100.0,1000.0]"); dimensionInfo.setUnit("m"); dimensionInfo.setRange(NumberRange.create(-100, 1000)); dimensionInfo.setName("Band" + (i++));
List<CoverageDimensionInfo> dimensions = c.getDimensions(); CoverageDimensionInfo dimension = dimensions.get(0); assertEquals("GRAY_INDEX", dimension.getName()); NumberRange range = dimension.getRange(); assertEquals(Double.NEGATIVE_INFINITY, range.getMinimum(), DELTA); assertEquals(Double.POSITIVE_INFINITY, range.getMaximum(), DELTA); assertEquals("GridSampleDimension[-Infinity,Infinity]", dimension.getDescription()); List<Double> nullValues = dimension.getNullValues(); assertEquals(-9999.0, nullValues.get(0), DELTA); dimensions = c.getDimensions(); dimension = dimensions.get(0); assertEquals("Elevation", dimension.getName()); range = dimension.getRange(); assertEquals(-100.0, range.getMinimum(), DELTA); assertEquals(1000.0, range.getMaximum(), DELTA); assertEquals("GridSampleDimension[-100.0,1000.0]", dimension.getDescription()); nullValues = dimension.getNullValues(); assertEquals(-999.0, nullValues.get(0), DELTA);
fieldAttr.addAttribute("", "name", "name", "", sd.getName()); start("swe:field", fieldAttr); chars(sd.getName()); // TODO can we make up something better?? end("swe:description"); List<Double> nullValues = sd.getNullValues(); if (nullValues != null && !nullValues.isEmpty()) { final int size = nullValues.size(); final String unit = sd.getUnit(); uomAttr.addAttribute("", "code", "code", "", unit == null ? "W.m-2.Sr-1" : unit); start("swe:uom", uomAttr);
@Test public void testPreserveCoverageBandNames() throws Exception { final Catalog cat = getCatalog(); final CoverageStoreInfo storeInfo = cat.getCoverageStoreByName("ir-rgb"); final CoverageView coverageView = buildRgbIRView(); final CatalogBuilder builder = new CatalogBuilder(cat); builder.setStore(storeInfo); final CoverageInfo coverageInfo = coverageView.createCoverageInfo(RGB_IR_VIEW, storeInfo, builder); List<CoverageDimensionInfo> dimensions = coverageInfo.getDimensions(); assertEquals("rband", dimensions.get(0).getName()); assertEquals("gband", dimensions.get(1).getName()); assertEquals("bband", dimensions.get(2).getName()); assertEquals("irband", dimensions.get(3).getName()); }
ci.setTitle("my title ë"); ci.setAbstract("my abstract ë"); ci.getDimensions().get(0).setName("CUSTOM_DIMENSION"); ci.getKeywords().add(new Keyword("demmiedem")); geoServer.getCatalog().save(ci); assertEquals(ci.getAbstract(), cov.getAbstract()); assertEquals( ci.getDimensions().get(0).getName(), cov.getEncodedDimensionsInfoList().get(0).getName()); assertTrue(cov.getKeywords().contains("demmiedem"));
dimension.setUnit(originalUnit); List<Double> nullValues = dimension.getNullValues(); if (nullValues != null) { nullValues.clear();
private CoverageInfo resolve(CoverageInfo r) { CoverageInfoImpl c = (CoverageInfoImpl) r; if (c.getDimensions() != null) { for (CoverageDimensionInfo dim : c.getDimensions()) { if (dim.getNullValues() == null) { ((CoverageDimensionImpl) dim).setNullValues(new ArrayList<Double>()); } } } resolveCollections(r); return r; }
if (meta.getDimensions() != null) { for (CoverageDimensionInfo dimension : meta.getDimensions()) { int size = guessSizeFromRange(dimension.getRange()); if (size == 0) { LOGGER.log( Level.INFO, "Failed to guess the size of dimension " + dimension.getName() + ", skipping the pre-read check"); pixelSize = -1;
if (infos != null && infos.size() > 0) { CoverageDimensionInfo info = infos.get(0); uom.setModelObject(info.getUnit());
Map map = (Map) x.next(); CoverageDimensionInfo cd = factory.createCoverageDimension(); cd.setName((String) map.get("name")); cd.setDescription((String) map.get("description")); cd.setRange(NumberRange.create((Double) map.get("min"), (Double) map.get("max"))); coverage.getDimensions().add(cd);
/** * Tries to encode a meaningful range for a {@link SampleDimension}. * * @param sd the {@link CoverageDimensionInfo} to encode a meaningful range for. */ public void handleSampleDimensionRange(CoverageDimensionInfo sd) { if (!setRange(sd.getRange())) { SampleDimensionType sdType = sd.getDimensionType(); handleSampleDimensionType(sdType); } }
private void configureIROnCatalog(Catalog cat) throws Exception { final CoverageStoreInfo storeInfo = cat.getCoverageStoreByName("ir-rgb"); final CoverageView coverageView = buildRgbIRView(); final CatalogBuilder builder = new CatalogBuilder(cat); builder.setStore(storeInfo); final CoverageInfo coverageInfo = coverageView.createCoverageInfo(RGB_IR_VIEW, storeInfo, builder); coverageInfo.getParameters().put("USE_JAI_IMAGEREAD", "false"); coverageInfo.getDimensions().get(0).setName("Red"); coverageInfo.getDimensions().get(1).setName("Green"); coverageInfo.getDimensions().get(2).setName("Blue"); coverageInfo.getDimensions().get(3).setName("Infrared"); cat.add(coverageInfo); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); Catalog catalog = getCatalog(); Map<String, String> namespaces = new HashMap<String, String>(); namespaces.put("html", "http://www.w3.org/1999/xhtml"); namespaces.put("sld", "http://www.opengis.net/sld"); namespaces.put("ogc", "http://www.opengis.net/ogc"); namespaces.put("atom", "http://www.w3.org/2005/Atom"); XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces)); xp = XMLUnit.newXpathEngine(); testData.addStyle( "style_rgb", "test-data/style_rgb.sld", DynamicColorMapTest.class, catalog); Map<LayerProperty, Object> properties = new HashMap<>(); properties.put(LayerProperty.STYLE, "style_rgb"); testData.addRasterLayer( new QName(MockData.DEFAULT_URI, "watertemp_dynamic", MockData.DEFAULT_PREFIX), "test-data/watertemp_dynamic.zip", null, properties, DynamicColorMapTest.class, catalog); // setup manual statistics CoverageInfo coverage = getCatalog().getCoverageByName("watertemp_dynamic"); CoverageDimensionInfo di = coverage.getDimensions().get(0); di.setRange(new NumberRange<Double>(Double.class, 0., 0.5)); getCatalog().save(coverage); }
@Override public Object getPropertyValue(CoverageDimensionInfo item) { SampleDimensionType type = item.getDimensionType(); if (type == null) { return "-"; } else { String name = type.name(); try { String key = BandsPanel.class.getSimpleName() + "." + name; ParamResourceModel rm = new ParamResourceModel(key, null); return rm.getString(); } catch (Exception e) { return name; } } } });
/** * Given a set of sample dimensions, this will return a valid range only if all sample * dimensions have one, otherwise null * * @param dimensions */ protected NumberRange getCoverageRange(List<CoverageDimensionInfo> dimensions) { NumberRange range = null; for (CoverageDimensionInfo dimension : dimensions) { if (dimension.getRange() == null) return null; else if (range == null) range = dimension.getRange(); else range.union(dimension.getRange()); } return range; }
@Test public void testCustomUnit() throws Exception { CoverageInfo ciRain = getCatalog().getCoverageByName(getLayerId(RAIN)); ciRain.getDimensions().get(0).setUnit("mm"); getCatalog().save(ciRain); Document dom = getAsDOM(DESCRIBE_URL + "&coverageId=sf__rain"); assertNotNull(dom); // print(dom, System.out); checkValidationErrors(dom, getWcs20Schema()); assertXpathEvaluatesTo( "1", "count(//wcs:CoverageDescription/gmlcov:rangeType/swe:DataRecord/swe:field)", dom); assertXpathEvaluatesTo( "rain", "//wcs:CoverageDescription/gmlcov:rangeType//swe:DataRecord/swe:field/@name", dom); assertXpathEvaluatesTo( "mm", "//wcs:CoverageDescription/gmlcov:rangeType/swe:DataRecord/swe:field/swe:Quantity/swe:uom/@code", dom); assertXpathEvaluatesTo( "text/plain", "//wcs:CoverageDescriptions//wcs:CoverageDescription[1]//wcs:ServiceParameters//wcs:nativeFormat", dom); }