Package org.traccar.model

Examples of org.traccar.model.Position


                return null;
            }
            sendResponse(channel);

            // Create new position
            Position position = new Position();
            position.setDeviceId(deviceId);
            ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

            Integer index = 1;

            // Time
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));

            // Latitude
            Double latitude = Double.valueOf(parser.group(index++));
            latitude += Double.valueOf(parser.group(index++)) / 60;
            if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
            position.setLatitude(latitude);

            // Longitude
            Double longitude = Double.valueOf(parser.group(index++));
            longitude += Double.valueOf(parser.group(index++)) / 60;
            if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
            position.setLongitude(longitude);
           
            // HDOP
            extendedInfo.set("hdop", parser.group(index++));

            // Altitude
            position.setAltitude(Double.valueOf(parser.group(index++)));
           
            // Validity
            int fix = Integer.valueOf(parser.group(index++));
            extendedInfo.set("fix", fix);
            position.setValid(fix > 0);

            // Course
            position.setCourse(Double.valueOf(parser.group(index++)));

            // Speed
            index += 1; // speed in kph
            position.setSpeed(Double.valueOf(parser.group(index++)));

            // Date
            time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
            time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
            position.setTime(time.getTime());

            // Satellites
            extendedInfo.set("satellites", parser.group(index++));

            // Extended info
            position.setExtendedInfo(extendedInfo.toString());

            return position;
        }
       
        return null;
View Full Code Here


        buf.readUnsignedByte(); // header
        int length = (buf.readUnsignedShort() & 0x7fff) + 3;
       
        List<Position> positions = new LinkedList<Position>();
        Set<Integer> tags = new HashSet<Integer>();
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
       
        while (buf.readerIndex() < length) {

            // Check if new message started
            int tag = buf.readUnsignedByte();
            if (tags.contains(tag)) {
                position.setExtendedInfo(extendedInfo.toString());
                positions.add(position);
                tags.clear();
                position = new Position();
                extendedInfo = new ExtendedInfoFormatter(getProtocol());
            }
            tags.add(tag);
           
            switch (tag) {

                case TAG_IMEI:
                    String imei = buf.toString(buf.readerIndex(), 15, Charset.defaultCharset());
                    buf.skipBytes(imei.length());
                    try {
                        deviceId = getDataManager().getDeviceByImei(imei).getId();
                    } catch(Exception error) {
                        Log.warning("Unknown device - " + imei);
                    }
                    break;

                case TAG_DATE:
                    position.setTime(new Date(buf.readUnsignedInt() * 1000));
                    break;
                   
                case TAG_COORDINATES:
                    position.setValid((buf.readUnsignedByte() & 0xf0) == 0x00);
                    position.setLatitude(buf.readInt() / 1000000.0);
                    position.setLongitude(buf.readInt() / 1000000.0);
                    break;
                   
                case TAG_SPEED_COURSE:
                    position.setSpeed(buf.readUnsignedShort() * 0.0539957);
                    position.setCourse(buf.readUnsignedShort() * 0.1);
                    break;
                   
                case TAG_ALTITUDE:
                    position.setAltitude((double) buf.readShort());
                    break;
                   
                case TAG_STATUS:
                    extendedInfo.set("status", buf.readUnsignedShort());
                    break;
                   
                case TAG_POWER:
                    extendedInfo.set("power", buf.readUnsignedShort());
                    break;
                   
                case TAG_BATTERY:
                    extendedInfo.set("battery", buf.readUnsignedShort());
                    break;
                   
                case TAG_MILAGE:
                    extendedInfo.set("milage", buf.readUnsignedInt());
                    break;
                   
                default:
                    buf.skipBytes(getTagLength(tag));
                    break;
                   
            }
        }

        position.setExtendedInfo(extendedInfo.toString());
        positions.add(position);
       
        if (deviceId == null) {
            Log.warning("Unknown device");
            return null;
View Full Code Here

            return position;
        }
    }

    private ParseResult parsePosition(ChannelBuffer buf) {
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        position.setDeviceId(databaseDeviceId);
        position.setAltitude(0.0);

        // Format type
        int format;
        if (buf.getUnsignedByte(buf.readerIndex()) == 0) {
            format = buf.readUnsignedShort();
        } else {
            format = buf.readUnsignedByte();
        }
        extendedInfo.set("format", format);

        long index = buf.readUnsignedInt();
        extendedInfo.set("index", index);

        // Event type
        extendedInfo.set("event", buf.readUnsignedShort());

        // Event time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
        time.set(Calendar.MINUTE, buf.readUnsignedByte());
        time.set(Calendar.SECOND, buf.readUnsignedByte());
        time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
        time.set(Calendar.MONTH, buf.readUnsignedByte());
        time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte());
        extendedInfo.set("time", time.getTimeInMillis());

        // Alarm status
        extendedInfo.set("alarm", buf.readUnsignedByte());

        // Modules status
        extendedInfo.set("status", buf.readUnsignedByte());

        // GSM signal
        extendedInfo.set("gsm", buf.readUnsignedByte());

        // Output
        if (isFormat(format, F10, F20, F30)) {
            extendedInfo.set("output", buf.readUnsignedShort());
        } else if (isFormat(format, F40, F50, F51, F52)) {
            extendedInfo.set("output", buf.readUnsignedByte());
        }

        // Input
        if (isFormat(format, F10, F20, F30, F40)) {
            extendedInfo.set("input", buf.readUnsignedShort());
        } else if (isFormat(format, F50, F51, F52)) {
            extendedInfo.set("input", buf.readUnsignedByte());
        }

        extendedInfo.set("power", buf.readUnsignedShort() / 1000.0);

        // Battery power
        extendedInfo.set("battery", buf.readUnsignedShort());

        // Temperature
        if (isFormat(format, F10, F20, F30)) {
            extendedInfo.set("temperature", buf.readShort());
        }

        if (isFormat(format, F10, F20, F50, F52)) {
            extendedInfo.set("adc1", buf.readUnsignedShort());
            extendedInfo.set("adc2", buf.readUnsignedShort());
        }

        if (isFormat(format, F20, F50, F51, F52)) {
            // Impulse counters
            buf.readUnsignedInt();
            buf.readUnsignedInt();
        }

        if (isFormat(format, F20, F50, F51, F52)) {
            // Validity
            int locationStatus = buf.readUnsignedByte();
            position.setValid((locationStatus & 0x02) == 0x02);

            // Location time
            time.clear();
            time.set(Calendar.HOUR_OF_DAY, buf.readUnsignedByte());
            time.set(Calendar.MINUTE, buf.readUnsignedByte());
            time.set(Calendar.SECOND, buf.readUnsignedByte());
            time.set(Calendar.DAY_OF_MONTH, buf.readUnsignedByte());
            time.set(Calendar.MONTH, buf.readUnsignedByte());
            time.set(Calendar.YEAR, 2000 + buf.readUnsignedByte());
            position.setTime(time.getTime());

            // Location data
            position.setLatitude(buf.readFloat() / Math.PI * 180);
            position.setLongitude(buf.readFloat() / Math.PI * 180);
            position.setSpeed((double) buf.readFloat());
            position.setCourse((double) buf.readUnsignedShort());

            // Milage
            extendedInfo.set("milage", buf.readFloat());

            // Last segment
            extendedInfo.set("segment", buf.readFloat());

            // Segment times
            buf.readUnsignedShort();
            buf.readUnsignedShort();
        }

        if (isFormat(format, F51, F52)) {
            // Other stuff
            buf.readUnsignedShort();
            buf.readByte();
            buf.readUnsignedShort();
            buf.readUnsignedShort();
            buf.readByte();
            buf.readUnsignedShort();
            buf.readUnsignedShort();
            buf.readByte();
            buf.readUnsignedShort();
        }

        if (isFormat(format, F40, F52)) {
            // Four temperature sensors
            buf.readByte();
            buf.readByte();
            buf.readByte();
            buf.readByte();
        }

        // Extended info
        position.setExtendedInfo(extendedInfo.toString());

        return new ParseResult(index, position);
    }
View Full Code Here

    private Object processArray(Channel channel, ChannelBuffer buf) {
        List<Position> positions = new LinkedList<Position>();
        int count = buf.readUnsignedByte();

        for (int i = 0; i < count; i++) {
            Position position = parsePosition(buf).getPosition();
            if (position.getValid() != null) {
                positions.add(position);
            }
        }

        ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 8);
View Full Code Here

            channel.write(ChannelBuffers.copiedBuffer(header, data));
        }
    }
   
    private Position parseUnitReport(ChannelBuffer buf, long deviceId, int sequenceNumber) {
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        position.setValid(true);
        extendedInfo.set("index", sequenceNumber);
        position.setDeviceId(deviceId);
       
        buf.readUnsignedShort(); // report trigger
        buf.readUnsignedShort(); // flags
       
        position.setLatitude(buf.readInt() * 0.0000001);
        position.setLongitude(buf.readInt() * 0.0000001);
        position.setAltitude((double) buf.readUnsignedShort());
       
        buf.readUnsignedShort(); // satellites in fix
        buf.readUnsignedShort(); // satellites in track
        buf.readUnsignedShort(); // GPS antenna state
       
        position.setSpeed(buf.readUnsignedShort() * 0.194384);
        position.setCourse((double) buf.readUnsignedShort());
       
        buf.readUnsignedInt(); // distance
        buf.readUnsignedInt(); // delta distance

        extendedInfo.set("battery", buf.readUnsignedShort() * 0.001);
       
        buf.readUnsignedShort(); // battery charger status
       
        position.setTime(convertTimestamp(buf.readUnsignedInt()));
       
        // TODO: a lot of other stuff

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
   
    private Position parseTg2Report(ChannelBuffer buf, long deviceId, int sequenceNumber) {
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        position.setValid(true);
        extendedInfo.set("index", sequenceNumber);
        position.setDeviceId(deviceId);
       
        buf.readUnsignedShort(); // report trigger
        buf.readUnsignedByte(); // reserved
        buf.readUnsignedByte(); // assisted GPS age
       
        position.setTime(convertTimestamp(buf.readUnsignedInt()));
       
        position.setLatitude(buf.readInt() * 0.0000001);
        position.setLongitude(buf.readInt() * 0.0000001);
        position.setAltitude((double) buf.readUnsignedShort());
       
        buf.readUnsignedByte(); // satellites in fix
        buf.readUnsignedByte(); // satellites in track
       
        position.setSpeed(buf.readUnsignedShort() * 0.194384);
        position.setCourse((double) buf.readUnsignedShort());
       
        buf.readUnsignedInt(); // distance
        buf.readUnsignedShort(); // maximum speed
        buf.readUnsignedShort(); // minimum speed

        buf.readUnsignedShort(); // VSAUT1 voltage
        buf.readUnsignedShort(); // VSAUT2 voltage
        buf.readUnsignedShort(); // solar voltage
        extendedInfo.set("battery", buf.readUnsignedShort() * 0.001);
       
        // TODO: a lot of other stuff

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

            if (!parser.matches()) {
                return null;
            }

            // Create new position
            Position position = new Position();
            position.setDeviceId(deviceId);
            ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

            Integer index = 1;

            // Time
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
            time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
            position.setTime(time.getTime());

            // Location
            position.setLatitude(Double.valueOf(parser.group(index++)));
            position.setLongitude(Double.valueOf(parser.group(index++)));
            position.setSpeed(Double.valueOf(parser.group(index++)));
            position.setCourse(Double.valueOf(parser.group(index++)));
            position.setAltitude(0.0);
           
            // Distance
            extendedInfo.set("milage", parser.group(index++));
           
            // Event
            extendedInfo.set("event", parser.group(index++));
           
            // Status
            int status = Integer.valueOf(parser.group(index++));
            position.setValid((status & 0x04) == 0);
            extendedInfo.set("status", status);

            position.setExtendedInfo(extendedInfo.toString());
            return position;
        }
       
        return null;
    }
View Full Code Here

        if (!parser.matches()) {
            return null;
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        Integer index = 1;

        // Get device by IMEI
        String id = parser.group(index++);
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + id);
            return null;
        }

        // Time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MILLISECOND, Integer.valueOf(parser.group(index++)));

        // Validity
        position.setValid(parser.group(index++).compareTo("A") == 0);

        // Latitude
        Double latitude = Double.valueOf(parser.group(index++));
        latitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("S") == 0) {
            latitude = -latitude;
        }
        position.setLatitude(latitude);

        // Longitude
        Double longitude = Double.valueOf(parser.group(index++));
        longitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("W") == 0) {
            longitude = -longitude;
        }
        position.setLongitude(longitude);

        // Altitude
        position.setAltitude(0.0);

        // Speed
        String speed = parser.group(index++);
        if (speed != null) {
            position.setSpeed(Double.valueOf(speed));
        } else {
            position.setSpeed(0.0);
        }

        // Course
        String course = parser.group(index++);
        if (course != null) {
            position.setCourse(Double.valueOf(course));
        } else {
            position.setCourse(0.0);
        }

        // Date
        time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
        time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
        position.setTime(time.getTime());

        // Extended info
        position.setExtendedInfo(extendedInfo.toString());

        return position;
    }
View Full Code Here

        if (!parser.matches()) {
            return null;
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());
        Integer index = 1;

        // Identification
        String id = parser.group(index++);
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(id).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + id);
        }

        // Time
        Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
        time.clear();
        time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));

        // Validity
        String status = parser.group(index++);
        position.setValid(status.compareToIgnoreCase("A") == 0);

        // Latitude
        Double latitude = Double.valueOf(parser.group(index++));
        latitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
        position.setLatitude(latitude);

        // Longitude
        Double longitude = Double.valueOf(parser.group(index++));
        longitude += Double.valueOf(parser.group(index++)) / 60;
        if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
        position.setLongitude(longitude);

        // Speed
        position.setSpeed(Double.valueOf(parser.group(index++)));

        // Course
        position.setCourse(Double.valueOf(parser.group(index++)));

        // Date
        time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
        time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
        time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
        position.setTime(time.getTime());

        // Altitude
        position.setAltitude(0.0);

        // Response
        String type = parser.group(index++);
        String checksum = parser.group(index++);
        String response = null;

        if (type.equals("0") && Character.isLowerCase(status.charAt(0))) {
            response = "$EAVACK,0," + checksum;
            response += Crc.nmeaChecksum(response);
        } else if (type.equals("S") || type.equals("T")) {
            response = "$AVCFG,00000000,t*21";
        } else if (type.equals("3")) {
            response = "$AVCFG,00000000,d*31";
        } else if (type.equals("X") || type.equals("4")) {
            response = "$AVCFG,00000000,x*2D";
        }
       
        if (response != null && channel != null) {
            channel.write(response + "\r\n");
        }

        position.setExtendedInfo(extendedInfo.toString());
        return position;
    }
View Full Code Here

        if (parser == null || !parser.matches()) {
            return null;
        }

        // Create new position
        Position position = new Position();
        ExtendedInfoFormatter extendedInfo = new ExtendedInfoFormatter(getProtocol());

        Integer index = 1;

        // Get device by IMEI
        String imei = parser.group(index++);
        try {
            position.setDeviceId(getDataManager().getDeviceByImei(imei).getId());
        } catch(Exception error) {
            Log.warning("Unknown device - " + imei);
            return null;
        }
       
        // Alarm type
        extendedInfo.set("alarm", parser.group(index++));
       
        if (format == MessageFormat.first || format == MessageFormat.second) {

            // Time
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            int year = 0;
            if (format == MessageFormat.second) {
                time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
                time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
                year = Integer.valueOf(parser.group(index++));
                time.set(Calendar.YEAR, 2000 + year);
            }
            time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));

            // Validity
            position.setValid(parser.group(index++).compareTo("A") == 0);

            // Latitude
            Double latitude = Double.valueOf(parser.group(index++));
            latitude += Double.valueOf(parser.group(index++)) / 60;
            if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
            position.setLatitude(latitude);

            // Longitude
            Double longitude = Double.valueOf(parser.group(index++));
            longitude += Double.valueOf(parser.group(index++)) / 60;
            if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
            position.setLongitude(longitude);

            // Speed
            String speed = parser.group(index++);
            if (speed != null) {
                position.setSpeed(Double.valueOf(speed));
            } else {
                position.setSpeed(0.0);
            }

            // Course
            String course = parser.group(index++);
            if (course != null) {
                position.setCourse(Double.valueOf(course));
            } else {
                position.setCourse(0.0);
            }

            // Date
            if (format == MessageFormat.first) {
                time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
                time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
                year = Integer.valueOf(parser.group(index++));
                time.set(Calendar.YEAR, 2000 + year);
            }
            if (year == 0) {
                return null; // ignore invalid data
            }
            position.setTime(time.getTime());

            // Altitude
            position.setAltitude(0.0);

            // Accuracy
            extendedInfo.set("hdop", parser.group(index++));

            // IO Status
            extendedInfo.set("io", parser.group(index++));

            // Power
            extendedInfo.set("battery", parser.group(index++));
            extendedInfo.set("power", Double.valueOf(parser.group(index++)));

            // ADC
            extendedInfo.set("adc", parser.group(index++));

            // Location Code
            extendedInfo.set("lac", parser.group(index++));

            // Temperature
            extendedInfo.set("temperature", parser.group(index++));

            // Milage
            extendedInfo.set("milage", parser.group(index++));
       
        } else if (format == MessageFormat.third) {

            // Time
            Calendar time = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            time.clear();
            time.set(Calendar.YEAR, 2000 + Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MONTH, Integer.valueOf(parser.group(index++)) - 1);
            time.set(Calendar.DAY_OF_MONTH, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.HOUR_OF_DAY, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.MINUTE, Integer.valueOf(parser.group(index++)));
            time.set(Calendar.SECOND, Integer.valueOf(parser.group(index++)));
            position.setTime(time.getTime());
           
            // IO Status
            extendedInfo.set("io", parser.group(index++));

            // Power
            extendedInfo.set("battery", Double.valueOf(parser.group(index++)) / 10);
            extendedInfo.set("power", Double.valueOf(parser.group(index++)));

            // ADC
            extendedInfo.set("adc1", parser.group(index++));
            extendedInfo.set("adc2", parser.group(index++));

            // Temperature
            extendedInfo.set("temperature1", parser.group(index++));
            extendedInfo.set("temperature2", parser.group(index++));

            // Location Code
            extendedInfo.set("lac", parser.group(index++));

            // Validity
            position.setValid(parser.group(index++).compareTo("A") == 0);

            // Satellites
            extendedInfo.set("satellites", parser.group(index++));

            // Course
            position.setCourse(Double.valueOf(parser.group(index++)));

            // Speed
            position.setSpeed(Double.valueOf(parser.group(index++)));

            // Altitude
            position.setAltitude(0.0);

            // PDOP
            extendedInfo.set("pdop", parser.group(index++));

            // Milage
            extendedInfo.set("milage", parser.group(index++));

            // Latitude
            Double latitude = Double.valueOf(parser.group(index++));
            latitude += Double.valueOf(parser.group(index++)) / 60;
            if (parser.group(index++).compareTo("S") == 0) latitude = -latitude;
            position.setLatitude(latitude);

            // Longitude
            Double longitude = Double.valueOf(parser.group(index++));
            longitude += Double.valueOf(parser.group(index++)) / 60;
            if (parser.group(index++).compareTo("W") == 0) longitude = -longitude;
            position.setLongitude(longitude);
       
        }

        // Extended info
        position.setExtendedInfo(extendedInfo.toString());

        return position;
    }
View Full Code Here

TOP

Related Classes of org.traccar.model.Position

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.