From e4f167f17b60448d6bee6680c7d88cb6beaefb63 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 12 Aug 2015 19:52:49 +1200 Subject: [PATCH] Create position model class --- .../java/org/traccar/client/Position.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 app/src/main/java/org/traccar/client/Position.java diff --git a/app/src/main/java/org/traccar/client/Position.java b/app/src/main/java/org/traccar/client/Position.java new file mode 100644 index 0000000..fd81196 --- /dev/null +++ b/app/src/main/java/org/traccar/client/Position.java @@ -0,0 +1,71 @@ +/* + * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.client; + +import android.location.Location; + +import java.util.Date; + +public class Position { + + public Location location; // DELME + + public Position(String id, Location location, double battery) { + this.location = location; // DELME + + this.id = id; + time = new Date(location.getTime()); + latitude = location.getLatitude(); + longitude = location.getLongitude(); + altitude = location.getAltitude(); + speed = location.getSpeed() * 1.943844; // speed in knots + course = location.getBearing(); + this.battery = battery; + } + + private String id; + public String getId() { return id; } + public void setId(String id) { this.id = id; } + + private Date time; + public Date getTime() { return time; } + public void setTime(Date time) { this.time = time; } + + private double latitude; + public double getLatitude() { return latitude; } + public void setLatitude(double latitude) { this.latitude = latitude; } + + private double longitude; + public double getLongitude() { return longitude; } + public void setLongitude(double longitude) { this.longitude = longitude; } + + private double altitude; + public double getAltitude() { return altitude; } + public void setAltitude(double altitude) { this.altitude = altitude; } + + private double speed; + public double getSpeed() { return speed; } + public void setSpeed(double speed) { this.speed = speed; } + + private double course; + public double getCourse() { return course; } + public void setCourse(double course) { this.course = course; } + + private double battery; + public double getBattery() { return battery; } + public void setBattery(double battery) { this.battery = battery; } + +}