Package org.geotools.util

Examples of org.geotools.util.DateRange


        Date startTime = (Date) f.getAttribute(start);
        Date endTime = startTime;
        if (end != null) {
            endTime = (Date) f.getAttribute(end);
        }
        return new DateRange(startTime, endTime);
    }
View Full Code Here


     * @param subsettingRequest
     * @return
     * @throws IOException
     */
    private GridCoverageRequest setStandardReaderDefaults(GridCoverageRequest subsettingRequest) throws IOException {
        DateRange temporalSubset = subsettingRequest.getTemporalSubset();
        NumberRange<?> elevationSubset = subsettingRequest.getElevationSubset();
        Map<String, List<Object>> dimensionSubset = subsettingRequest.getDimensionsSubset();

        // Reader is not a StructuredGridCoverage2DReader instance. Set default ones with policy "time = max, elevation = min".

        // Setting default time
        if (temporalSubset == null) {
            // use "max" as the default
            Date maxTime = accessor.getMaxTime();
            if (maxTime != null) {
                temporalSubset = new DateRange(maxTime, maxTime);
            }
        }

        // Setting default elevation
        if (elevationSubset == null) {
View Full Code Here

                    // o2 daterange
                    return dateLeft.compareTo(((DateRange)o2).getMinValue());
                }
               
                // o1 date range
                final DateRange left= (DateRange) o1;
                if(o2Date){
                    // o2 date
                    return left.getMinValue().compareTo(((Date) o2));
                }
                // o2 daterange
                return left.getMinValue().compareTo(((DateRange)o2).getMinValue());
            }
        });
        String[] listDates = value.split(",");
        for(String date: listDates){
            // is it a date or a period?
            if(date.indexOf("/")<=0){
                Object o = getFuzzyDate(date);
                if (o instanceof Date) {
                    addDate(result, (Date)o);
                } else {
                    addPeriod(result, (DateRange)o);
                }
            } else {
                // period
                String[] period = date.split("/");
                //
                // Period like : yyyy-MM-ddTHH:mm:ssZ/yyyy-MM-ddTHH:mm:ssZ/P1D
                //
                if (period.length == 3) {
                    final Date begin = beginning(getFuzzyDate(period[0]));
                    final Date end = end(getFuzzyDate(period[1]));
                   
                    final long millisIncrement = parsePeriod(period[2]);
                    final long startTime = begin.getTime();
                    final long endTime = end.getTime();
                    long time;
                    int j = 0;
                    while ((time = j * millisIncrement + startTime) <= endTime) {
                        final Calendar calendar = new GregorianCalendar(UTC_TZ);
                        calendar.setTimeInMillis(time);
                        addDate(result, calendar.getTime());
                        j++;
                       
                        // limiting number of elements we can create
                        if(j>= MAX_ELEMENTS_TIMES_KVP){
                            if(LOGGER.isLoggable(Level.INFO))
                                LOGGER.info("Lmiting number of elements in this periodo to "+MAX_ELEMENTS_TIMES_KVP);
                            break;                 
                        }
                    }
                } else if (period.length == 2) {
                        // Period like : yyyy-MM-ddTHH:mm:ssZ/yyyy-MM-ddTHH:mm:ssZ, it is an extension
                        // of WMS that works with continuos period [Tb, Te].
                        final Date begin = beginning(getFuzzyDate(period[0]));
                        final Date end   = end(getFuzzyDate(period[1]));
                        addPeriod(result, new DateRange(begin, end));
                } else {
                    throw new ParseException("Invalid time period: " + Arrays.toString(period), 0);
                }
            }
        }
View Full Code Here

                if(newRange.contains(local)){
                    it.remove();
                }
            } else {
                // convert
                final DateRange local= (DateRange) element;
                if(local.contains(newRange))
                    return;
                if(newRange.contains(local))
                    it.remove();
            }
        }
View Full Code Here

        for (FormatAndPrecision f : FormatAndPrecision.values()) {
            ParsePosition pos = new ParsePosition(0);
            Date time = f.getFormat().parse(value, pos);
            if (pos.getIndex() == value.length()) {
                DateRange range  = f.expand(time);
                if (range.getMinValue().equals(range.getMaxValue())) {
                    return range.getMinValue();
                } else {
                    return range;
                }
            }
        }
View Full Code Here

                final Double local = (Double) element;
                if (local.equals(step))
                    return;
            } else {
                // convert
                final DateRange local = (DateRange) element;
                if (local.contains(step))
                    return;
            }
        }
        result.add(step);
View Full Code Here

    private Object parseTimeOrRange(SimpleDateFormat df, String timeOrRange) throws ParseException {
        if(timeOrRange.contains("/")) {
            String[] splitted = timeOrRange.split("/");
            Date start = df.parse(splitted[0]);
            Date end = df.parse(splitted[1]);
            return new DateRange(start, end);
        } else {
            return df.parse(timeOrRange);
        }
    }
View Full Code Here

     * @param timeDimension
     * @return
     * @throws IOException
     */
    private DateRange extractTemporalSubset() throws IOException {
        DateRange timeSubset = null;
        if (timeDimension != null) {
            for (DimensionSubsetType dim : request.getDimensionSubset()) {
                String dimension = WCSDimensionsSubsetHelper.getDimensionName(dim);

                // only care for time dimensions
                if (!TIME_NAMES.contains(dimension.toLowerCase())) {
                    continue;
                }

                // did we parse the range already?
                if(timeSubset != null) {
                    throw new WCS20Exception("Time dimension trimming/slicing specified twice in the request",
                            WCS20Exception.WCS20ExceptionCode.InvalidSubsetting, "subset");
                }

                // now decide what to do
                if (dim instanceof DimensionTrimType) {

                    // TRIMMING
                    final DimensionTrimType trim = (DimensionTrimType) dim;
                    final Date low = PARSER.parseDateTime(trim.getTrimLow());
                    final Date high = PARSER.parseDateTime(trim.getTrimHigh());

                    // low > high???
                    if (low.compareTo(high) > 0) {
                        throw new WCS20Exception("Low greater than High: " + trim.getTrimLow()
                                + ", " + trim.getTrimHigh(),
                                WCS20Exception.WCS20ExceptionCode.InvalidSubsetting, "subset");
                    }

                    timeSubset = new DateRange(low, high);
                } else if (dim instanceof DimensionSliceType) {

                    // SLICING
                    final DimensionSliceType slicing = (DimensionSliceType) dim;
                    final String slicePointS = slicing.getSlicePoint();
                    final Date slicePoint = PARSER.parseDateTime(slicePointS);
                    timeSubset = new DateRange(slicePoint, slicePoint);
                } else {
                    throw new WCS20Exception(
                            "Invalid element found while attempting to parse dimension subsetting request: " + dim.getClass()
                            .toString(), WCS20Exception.WCS20ExceptionCode.InvalidSubsetting, "subset");
                }
            }

            // right now we don't support trimming
            // TODO: revisit when we have some multidimensional output support
            if(!(reader instanceof StructuredGridCoverage2DReader) && timeSubset != null && !timeSubset.getMinValue().equals(timeSubset.getMaxValue())) {
                throw new WCS20Exception("Trimming on time is not supported at the moment on not StructuredGridCoverage2DReaders, only slicing is");
            }

            // apply nearest neighbor matching on time
            if (timeSubset != null && timeSubset.getMinValue().equals(timeSubset.getMaxValue())) {
               timeSubset = interpolateTime(timeSubset, accessor);
            }
        }
        return timeSubset;
    }
View Full Code Here

            }

            if(newSlicePoint == null) {
                newSlicePoint = previous;
            }
            timeSubset = new DateRange(newSlicePoint, newSlicePoint);
        }
        return timeSubset;
    }
View Full Code Here

        for (Object item : domain) {
            if(item instanceof Date) {
                Date date = (Date) item;
                results.add(date);
            } else if(item instanceof DateRange) {
                DateRange range = (DateRange) item;
                results.add(range.getMinValue());
                results.add(range.getMaxValue());
            }
        }
        return results;
    }
View Full Code Here

TOP

Related Classes of org.geotools.util.DateRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.