@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()); }
public TreeSet<Object> getTimeDomain() throws IOException { return accessor.getTimeDomain(); }
public TreeSet<Object> getTimeDomain() throws IOException { return accessor.getTimeDomain(); }
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"); } }
TreeSet<Object> domain = accessor.getTimeDomain(); Date slicePoint = timeSubset.getMinValue(); if (!domainContainsPoint(slicePoint, domain)) {
private Date findNearestTime(ReaderDimensionsAccessor dimAccessor, Date toMatch) throws IOException { Date candidate = null; TreeSet<Object> timeDomain = dimAccessor.getTimeDomain(); long shortestDistance = Long.MAX_VALUE; long currentDistance = 0;
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()); }
start("wcs:temporalDomain"); if (timeInfo.getPresentation() == DimensionPresentation.LIST) { for (Object item : dimensions.getTimeDomain()) { if (item instanceof Date) { element("gml:timePosition", timeFormat.format((Date) item));
&& (presentation == DimensionPresentation.LIST || presentation == DimensionPresentation.CONTINUOUS_INTERVAL)) { TreeSet<Object> timeDomain = accessor.getTimeDomain(); boolean intersectionFound = false; for (Object o : timeDomain) {
/** * Query and returns the times for the given layer, in the given time range * * @throws IOException */ public TreeSet<Object> queryCoverageTimes( CoverageInfo coverage, DateRange queryRange, int maxAnimationSteps) throws IOException { // grab the time metadata DimensionInfo time = coverage.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class); if (time == null || !time.isEnabled()) { throw new ServiceException( "Layer " + coverage.getPrefixedName() + " does not have time support enabled"); } GridCoverage2DReader reader = null; try { reader = (GridCoverage2DReader) coverage.getGridCoverageReader(null, null); } catch (Throwable t) { throw new ServiceException( "Unable to acquire a reader for this coverage " + coverage.prefixedName(), t); } if (reader == null) { throw new ServiceException( "Unable to acquire a reader for this coverage " + coverage.prefixedName()); } ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader); return dimensions.getTimeDomain(queryRange, maxAnimationSteps); }