@Test public void testCustomCloudCoverDimensionConvertion() throws IOException, ParseException { MockDimensionReader reader = new MockDimensionReader(); reader.metadata.put("HAS_MYDIM_DOMAIN", "true"); reader.metadata.put("MYDIM_DOMAIN_DATATYPE", "java.lang.Integer"); ReaderDimensionsAccessor accessor = new ReaderDimensionsAccessor(reader); List<Object> converted = accessor.convertDimensionValue("MYDIM", Arrays.asList("75/100")); assertEquals(1, converted.size()); NumberRange<Double> expected = new NumberRange<Double>(Double.class, 75d, 100d); assertEquals(expected, converted.get(0)); } }
@Test public void testMixedElevationExtraction() throws IOException { MockDimensionReader reader = new MockDimensionReader(); reader.metadata.put(GridCoverage2DReader.HAS_ELEVATION_DOMAIN, "true"); reader.metadata.put(GridCoverage2DReader.ELEVATION_DOMAIN, "0/0/0,10,15/20/1"); ReaderDimensionsAccessor accessor = new ReaderDimensionsAccessor(reader); TreeSet<Object> domain = accessor.getElevationDomain(); assertEquals(3, domain.size()); Iterator<Object> it = domain.iterator(); Number firstEntry = (Number) it.next(); assertEquals(0, firstEntry.doubleValue(), 0d); Number secondEntry = (Number) it.next(); assertEquals(10, secondEntry.doubleValue(), 0d); NumberRange thirdEntry = (NumberRange) it.next(); assertEquals(15, thirdEntry.getMinimum(), 0d); assertEquals(20, thirdEntry.getMaximum(), 0d); }
@Test public void testMixedTimeExtraction() throws IOException, ParseException { MockDimensionReader reader = new MockDimensionReader(); reader.metadata.put(GridCoverage2DReader.HAS_TIME_DOMAIN, "true"); reader.metadata.put( GridCoverage2DReader.TIME_DOMAIN, "2016-02-23T03:00:00.000Z/2016-02-23T03:00:00.000Z/PT1S,2016-02-23T06:00:00.000Z,2016-02-23T09:00:00.000Z/2016-02-23T12:00:00.000Z/PT1S"); ReaderDimensionsAccessor accessor = new ReaderDimensionsAccessor(reader); TreeSet<Object> domain = accessor.getTimeDomain(); assertEquals(3, domain.size()); Iterator<Object> it = domain.iterator(); Date firstEntry = (Date) it.next(); assertEquals(accessor.getTimeFormat().parse("2016-02-23T03:00:00.000Z"), firstEntry); Date secondEntry = (Date) it.next(); assertEquals(accessor.getTimeFormat().parse("2016-02-23T06:00:00.000Z"), secondEntry); DateRange thirdEntry = (DateRange) it.next(); assertEquals( accessor.getTimeFormat().parse("2016-02-23T09:00:00.000Z"), thirdEntry.getMinValue()); assertEquals( accessor.getTimeFormat().parse("2016-02-23T12:00:00.000Z"), thirdEntry.getMaxValue()); }
/** * Returns the max value for the time, either as a single {@link Date} or {@link DateRange} * according to what the underlying reader provides * * @throws IOException */ public Date getMaxTime() throws IOException { if (!hasTime()) { return null; } final String currentTime = reader.getMetadataValue(AbstractGridCoverage2DReader.TIME_DOMAIN_MAXIMUM); if (currentTime == null) { return null; } try { return getTimeFormat().parse(currentTime); } catch (ParseException e) { throw new RuntimeException("Failed to get CURRENT time from coverage reader", e); } }
/** * Returns the full set of time values supported by the raster, sorted by time. They are either * {@link Date} objects, or {@link DateRange} objects, according to what the underlying reader * provides. * * @throws IOException */ public TreeSet<Object> getTimeDomain() throws IOException { if (!hasTime()) { Collections.emptySet(); } final SimpleDateFormat df = getTimeFormat(); String domain = reader.getMetadataValue(TIME_DOMAIN); String[] timeInstants = domain.split("\\s*,\\s*"); TreeSet<Object> values = new TreeSet<Object>(TEMPORAL_COMPARATOR); for (String tp : timeInstants) { try { values.add(parseTimeOrRange(df, tp)); } catch (ParseException e) { LOGGER.log(Level.WARNING, e.getMessage(), e); } } return values; }
if (!hasTime()) { Collections.emptySet(); if (reader instanceof StructuredGridCoverage2DReader) { StructuredGridCoverage2DReader sr = (StructuredGridCoverage2DReader) reader; result = getDimensionValuesInRange("time", range, maxEntries, sr); TreeSet<Object> fullDomain = getElevationDomain();
ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader); DimensionInfo timeDimension = meta.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class); if (timeDimension != null && timeDimension.isEnabled() && dimensions.hasTime()) { final List<Object> timeValues = new ArrayList<Object>(); if (temporalSubset != null && temporalSubset.getTimePosition() != null) { Date date = (Date) tp.getValue(); if (date == null) { date = dimensions.getMaxTime(); Date date = dimensions.getMaxTime(); timeValues.add(date); if (elevationDimension != null && elevationDimension.isEnabled() && dimensions.hasElevation()) { List<Double> elevations = new ArrayList<Double>(); elevations.add(dimensions.getMinElevation()); if (dimInfo instanceof DimensionInfo && dimensions.hasDomain(axisName)) { int valueCount = axis.getSingleValue().size(); if (valueCount > 0) { for (int s = 0; s < valueCount; s++) { dimValues.addAll( dimensions.convertDimensionValue( axisName,
public WCSDefaultValuesHelper( GridCoverage2DReader reader, ReaderDimensionsAccessor accessor, GetCoverageType request, String coverageName) throws IOException { super(); this.accessor = accessor == null ? new ReaderDimensionsAccessor(reader) : accessor; // Force the creation of an accessor this.reader = reader; this.request = request; this.coverageName = coverageName; }
private void handleTimeDimensionRaster( CoverageInfo cvInfo, DimensionInfo timeInfo, ReaderDimensionsAccessor dimension) throws IOException { TreeSet<Object> temporalDomain = null; try { if (timeInfo.getPresentation() != DimensionPresentation.LIST) { Date minValue = dimension.getMinTime(); if (minValue != null) { temporalDomain = new TreeSet<>(); temporalDomain.add(minValue); temporalDomain.add(dimension.getMaxTime()); } } if (temporalDomain == null) { throw new Exception( "The \"List\" presentation of the temporal dimension has been selected"); } } catch (Exception ex) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Dimension has not been extracted. The reason: ", ex); } temporalDomain = dimension.getTimeDomain(); } String timeMetadata = getTemporalDomainRepresentation(timeInfo, temporalDomain); String defaultValue = getDefaultValueRepresentation( cvInfo, ResourceInfo.TIME, DimensionDefaultValueSetting.TIME_CURRENT); writeTimeDimension(timeMetadata, defaultValue, timeInfo.isNearestMatchEnabled()); }
try { if (elevInfo.getPresentation() != DimensionPresentation.LIST) { Double minValue = dimensions.getMinElevation(); if (minValue != null) { elevations = new TreeSet<>(); elevations.add(minValue); elevations.add(dimensions.getMaxElevation()); LOGGER.log(Level.FINE, "Dimension has not been extracted. The reason: ", ex); elevations = dimensions.getElevationDomain();
(GridCoverage2DReader) ((CoverageInfo) resource).getGridCoverageReader(null, null); ReaderDimensionsAccessor dimAccessor = new ReaderDimensionsAccessor(reader); retval = dimAccessor.getMinTime(); } else if (dimensionName.equals(ResourceInfo.ELEVATION)) { retval = dimAccessor.getMinElevation(); } else if (dimensionName.startsWith(ResourceInfo.CUSTOM_DIMENSION_PREFIX)) { String custDimName = List<String> domain = dimAccessor.getDomain(custDimName);
ci.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class); if (timeInfo != null && timeInfo.isEnabled()) { ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader); SimpleDateFormat format = dimensions.getTimeFormat(); element("gml:timePosition", format.format(dimensions.getMinTime())); element("gml:timePosition", format.format(dimensions.getMaxTime()));
(GridCoverage2DReader) ((CoverageInfo) resource).getGridCoverageReader(null, null); ReaderDimensionsAccessor dimAccessor = new ReaderDimensionsAccessor(reader); retval = dimAccessor.getMaxTime(); } else if (dimensionName.equals(ResourceInfo.ELEVATION)) { retval = dimAccessor.getMaxElevation(); } else if (dimensionName.startsWith(ResourceInfo.CUSTOM_DIMENSION_PREFIX)) { String custDimName = } else { List<String> domain = dimAccessor.getDomain(custDimName);
CoverageInfo ci, DimensionInfo timeInfo, ReaderDimensionsAccessor dimensions) throws IOException { SimpleDateFormat timeFormat = dimensions.getTimeFormat(); start("wcs:temporalDomain"); if (timeInfo.getPresentation() == DimensionPresentation.LIST) { for (Object item : dimensions.getTimeDomain()) { if (item instanceof Date) { element("gml:timePosition", timeFormat.format((Date) item)); String minTime = timeFormat.format(dimensions.getMinTime()); String maxTime = timeFormat.format(dimensions.getMaxTime()); start("wcs:timePeriod"); element("wcs:beginPosition", minTime); resolution = new BigDecimal( dimensions.getMaxTime().getTime() - dimensions.getMinTime().getTime());
+ csinfo.getFormat().getName()); ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader); if (!dimensions.hasDomain(key)) customDimensions.remove(key); if (hasTime && dimensions.hasTime()) { handleTimeDimensionRaster(cvInfo, timeInfo, dimensions); if (hasElevation && dimensions.hasElevation()) { handleElevationDimensionRaster(cvInfo, elevInfo, dimensions);
ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader); if (dimensions.hasElevation()) { start("wcs:values"); TreeSet<Object> rawElevations = dimensions.getElevationDomain();
private TreeSet<Object> getDimensionDomain() throws IOException { ReaderDimensionsAccessor accessor = new ReaderDimensionsAccessor(reader); if (ResourceInfo.TIME.equals(dimensionName)) { return accessor.getTimeDomain(); } else { throw new IllegalArgumentException( "Nearest match support on simple grid readers is supported only " + "for time at the moment"); } }
SimpleDateFormat timeFormat = dimensions.getTimeFormat(); element("gml:timePosition", timeFormat.format(dimensions.getMinTime())); element("gml:timePosition", timeFormat.format(dimensions.getMaxTime()));
CoverageUtils.getParameters( readParametersDescriptor, coverage.getParameters(), readGeom); ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader); List<String> customDomains = new ArrayList(dimensions.getCustomDomains()); for (String domain : new ArrayList<>(customDomains)) { List<String> values = request.getCustomDimension(domain); parameterDescriptors, readParameters, dimensions.convertDimensionValue(domain, values), domain); customDomains.remove(domain); if (customInfo != null && customInfo.isEnabled()) { Object val = dimensions.convertDimensionValue( name, getDefaultCustomDimensionValue(name, coverage, String.class));
if (!hasElevation()) { Collections.emptySet(); if (reader instanceof StructuredGridCoverage2DReader) { StructuredGridCoverage2DReader sr = (StructuredGridCoverage2DReader) reader; result = getDimensionValuesInRange("elevation", range, maxEntries, sr); TreeSet<Object> fullDomain = getElevationDomain();