Package slash.common.type

Examples of slash.common.type.CompactCalendar


    }

    public void read(BufferedReader reader, CompactCalendar startDate, String encoding, ParserContext<NmeaRoute> context) throws IOException {
        List<NmeaPosition> positions = new ArrayList<NmeaPosition>();

        CompactCalendar originalStartDate = startDate;
        int lineCount = 0;
        NmeaPosition previous = null;
        while (true) {
            String line = reader.readLine();
            if (line == null)
View Full Code Here


    boolean haveDifferentTime(NmeaPosition predecessor, NmeaPosition successor) {
        if(predecessor == null)
            return true;
        if(!predecessor.hasTime() || !successor.hasTime())
            return false;
        CompactCalendar predecessorTime = predecessor.getTime();
        CompactCalendar successorTime = successor.getTime();
        return predecessorTime.hasDateDefined() && successorTime.hasDateDefined() &&
                !predecessorTime.equals(successorTime);
    }
View Full Code Here

            first.setTime(fromCalendar(Calendar.getInstance(UTC)));

        P previous = first;
        for (int i = 1; i < positions.size(); i++) {
            P next = positions.get(i);
            CompactCalendar time = next.getTime();
            if (time == null || time.equals(previous.getTime())) {
                Double distance = next.calculateDistance(previous);
                Long millis = distance != null ? (long) (distance / averageSpeed * 1000) : null;
                if (millis == null || millis < 1000)
                    millis = 1000L;
                next.setTime(fromMillisAndTimeZone(previous.getTime().getTimeInMillis() + millis, previous.getTime().getTimeZoneId()));
View Full Code Here

        int index = positions.indexOf(position);
        return index != -1 && index < positions.size() - 1 ? positions.get(index + 1) : null;
    }

    public long getTime() {
        CompactCalendar minimum = null, maximum = null;
        long totalTimeMilliSeconds = 0;
        List<P> positions = getPositions();
        P previous = null;
        for (P next : positions) {
            if (previous != null) {
                Long time = previous.calculateTime(next);
                if (time != null && time > 0)
                    totalTimeMilliSeconds += time;
            }

            CompactCalendar calendar = next.getTime();
            if (calendar == null)
                continue;
            if (minimum == null || calendar.before(minimum))
                minimum = calendar;
            if (maximum == null || calendar.after(maximum))
                maximum = calendar;

            previous = next;
        }
View Full Code Here

            first.setTime(fromCalendar(Calendar.getInstance(UTC)));

        P previous = first;
        for (int i = 1; i < positions.size(); i++) {
            P next = positions.get(i);
            CompactCalendar time = next.getTime();
            if (time == null || time.equals(previous.getTime())) {
                Double distance = next.calculateDistance(previous);
                Long millis = distance != null ? (long) (distance / averageSpeed * 1000) : null;
                if (millis == null || millis < 1000)
                    millis = 1000L;
                next.setTime(fromMillisAndTimeZone(previous.getTime().getTimeInMillis() + millis, previous.getTime().getTimeZoneId()));
View Full Code Here

        int index = positions.indexOf(position);
        return index != -1 && index < positions.size() - 1 ? positions.get(index + 1) : null;
    }

    public long getTime() {
        CompactCalendar minimum = null, maximum = null;
        long totalTimeMilliSeconds = 0;
        List<P> positions = getPositions();
        P previous = null;
        for (P next : positions) {
            if (previous != null) {
                Long time = previous.calculateTime(next);
                if (time != null && time > 0)
                    totalTimeMilliSeconds += time;
            }

            CompactCalendar calendar = next.getTime();
            if (calendar == null)
                continue;
            if (minimum == null || calendar.before(minimum))
                minimum = calendar;
            if (maximum == null || calendar.after(maximum))
                maximum = calendar;

            previous = next;
        }
View Full Code Here

    }

    private long getTimeInMillis(DownloadExecutor executor) {
        Checksum checksum = executor.getDownload().getFile().getExpectedChecksum();
        if (checksum != null) {
            CompactCalendar lastModified = checksum.getLastModified();
            if (lastModified != null)
                return lastModified.getTimeInMillis();
        }
        return 0;
    }
View Full Code Here

        List<String> whens = trackType.getWhen();
        List<KmlPosition> result = asExtendedKmlPositions(coords);
        for (int i = 0; i < whens.size(); i++) {
            String when = whens.get(i);
            if (when != null) {
                CompactCalendar calendar = parseTime(when);
                if (calendar != null && i < result.size())
                    result.get(i).setTime(calendar);
            }
        }
        return result;
View Full Code Here

        Wgs84Position position = format.parsePosition("1,T,08/12/02,05:40:15,47.91561,N,106.90109,E,1308.4m,97.78,1km/h", null);
        assertDoubleEquals(47.91561, position.getLatitude());
        assertDoubleEquals(106.90109, position.getLongitude());
        assertDoubleEquals(1308.4, position.getElevation());
        String actual = DateFormat.getDateTimeInstance().format(position.getTime().getTime());
        CompactCalendar expectedCal = calendar(2008, 12, 2, 5, 40, 15);
        String expected = DateFormat.getDateTimeInstance().format(expectedCal.getTime());
        assertEquals(expected, actual);
        assertEquals(expectedCal, position.getTime());
        assertNull(position.getDescription());
    }
View Full Code Here

            throw new IllegalArgumentException("'" + line + "' does not match");
        String description = trim(lineMatcher.group(1));
        Double latitude = parseDouble(lineMatcher.group(2));
        Double longitude = parseDouble(lineMatcher.group(3));
        Double elevation = parseDouble(lineMatcher.group(4));
        CompactCalendar time = parseTime(trim(lineMatcher.group(5)), trim(lineMatcher.group(6)));

        Wgs84Position position = new Wgs84Position(longitude, latitude, elevation, null, time, description);
        position.setStartDate(startDate);
        return position;
    }
View Full Code Here

TOP

Related Classes of slash.common.type.CompactCalendar

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.