diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-02-16 16:55:44 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-02-16 16:55:44 +1300 |
commit | 6d48729efb4bd1ac34bba003a8a4313a70a02cce (patch) | |
tree | b834c03b8aeb3302bedb949a63f6b6d0ed4f2600 /src/org/traccar/web/client/model/StateReader.java | |
parent | 11b7037755c08654fba3b3781f83445244582d59 (diff) | |
download | trackermap-web-6d48729efb4bd1ac34bba003a8a4313a70a02cce.tar.gz trackermap-web-6d48729efb4bd1ac34bba003a8a4313a70a02cce.tar.bz2 trackermap-web-6d48729efb4bd1ac34bba003a8a4313a70a02cce.zip |
Handle clicks on markers (fix #8)
Diffstat (limited to 'src/org/traccar/web/client/model/StateReader.java')
-rw-r--r-- | src/org/traccar/web/client/model/StateReader.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/org/traccar/web/client/model/StateReader.java b/src/org/traccar/web/client/model/StateReader.java new file mode 100644 index 00000000..a3549179 --- /dev/null +++ b/src/org/traccar/web/client/model/StateReader.java @@ -0,0 +1,43 @@ +package org.traccar.web.client.model; + +import java.util.LinkedList; +import java.util.List; + +import org.traccar.web.shared.model.Position; +import org.traccar.web.shared.model.XmlParser; + +import com.google.gwt.i18n.client.DateTimeFormat; + +public class StateReader { + + private static String toString(Object object) { + if (object != null) { + return object.toString(); + } + return null; + } + + public static List<StateItem> getState(Position position) { + List<StateItem> state = new LinkedList<StateItem>(); + + state.add(new StateItem("valid", toString(position.getValid()))); + state.add(new StateItem("time", DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(position.getTime()))); + state.add(new StateItem("latitude", toString(position.getLatitude()))); + state.add(new StateItem("longitude", toString(position.getLongitude()))); + state.add(new StateItem("altitude", toString(position.getAltitude()))); + state.add(new StateItem("speed", toString(position.getSpeed()))); + state.add(new StateItem("course", toString(position.getCourse()))); + state.add(new StateItem("power", toString(position.getPower()))); + state.add(new StateItem("address", position.getAddress())); + + String other = position.getOther(); + if (other != null) { + for (String key : XmlParser.enumerateElements(other)) { + state.add(new StateItem(key, XmlParser.getElement(other, key))); + } + } + + return state; + } + +} |