]> git.argeo.org Git - gpl/argeo-slc.git/blob - runtime/org.argeo.slc.support.gis/src/main/java/org/argeo/slc/gpx/TrackSpeed.java
Improve GPX importer
[gpl/argeo-slc.git] / runtime / org.argeo.slc.support.gis / src / main / java / org / argeo / slc / gpx / TrackSpeed.java
1 package org.argeo.slc.gpx;
2
3 import java.util.Date;
4
5 import org.geotools.referencing.GeodeticCalculator;
6
7 import com.vividsolutions.jts.geom.LineString;
8 import com.vividsolutions.jts.geom.Point;
9
10 public class TrackSpeed {
11 private Integer tid;
12 private String segmentUuid;
13 private String sensor;
14 private Date utcTimestamp;
15 private Point position;
16 private LineString line;
17 /** Orthodromic distance */
18 private Double distance;
19 private Double azimuth;
20 private Long duration;
21 // orthodromicDistance(line) in km/(duration in h)
22 private Double speed;
23 // can be null
24 private Double acceleration;
25 // can be null
26 private Double azimuthVariation;
27
28 public TrackSpeed() {
29 }
30
31 public TrackSpeed(TrackPoint ref, LineString line, Long duration,
32 GeodeticCalculator geodeticCalculator) {
33 segmentUuid = ref.getSegmentUuid();
34 sensor = ref.getSensor();
35 utcTimestamp = ref.getUtcTimestamp();
36 position = ref.getLocation();
37 this.line = line;
38 this.duration = duration;
39
40 Point startPoint = line.getStartPoint();
41 Point endPoint = line.getEndPoint();
42 geodeticCalculator.setStartingGeographicPoint(startPoint.getX(),
43 startPoint.getY());
44 geodeticCalculator.setDestinationGeographicPoint(endPoint.getX(),
45 endPoint.getY());
46 this.distance = geodeticCalculator.getOrthodromicDistance();
47 this.azimuth = geodeticCalculator.getAzimuth();
48 // in km/h
49 this.speed = (this.distance * 60 * 60) / this.duration;
50 }
51
52 public Integer getTid() {
53 return tid;
54 }
55
56 public void setTid(Integer tid) {
57 this.tid = tid;
58 }
59
60 public String getSegmentUuid() {
61 return segmentUuid;
62 }
63
64 public void setSegmentUuid(String segmentUuid) {
65 this.segmentUuid = segmentUuid;
66 }
67
68 public String getSensor() {
69 return sensor;
70 }
71
72 public void setSensor(String sensor) {
73 this.sensor = sensor;
74 }
75
76 public Date getUtcTimestamp() {
77 return utcTimestamp;
78 }
79
80 public void setUtcTimestamp(Date ts) {
81 this.utcTimestamp = ts;
82 }
83
84 public Point getPosition() {
85 return position;
86 }
87
88 public void setPosition(Point location) {
89 this.position = location;
90 }
91
92 public LineString getLine() {
93 return line;
94 }
95
96 public void setLine(LineString line) {
97 this.line = line;
98 }
99
100 public Long getDuration() {
101 return duration;
102 }
103
104 public void setDuration(Long duration) {
105 this.duration = duration;
106 }
107
108 public Double getSpeed() {
109 return speed;
110 }
111
112 public void setSpeed(Double speed) {
113 this.speed = speed;
114 }
115
116 public Double getDistance() {
117 return distance;
118 }
119
120 public void setDistance(Double length) {
121 this.distance = length;
122 }
123
124 public Double getAcceleration() {
125 return acceleration;
126 }
127
128 public void setAcceleration(Double acceleration) {
129 this.acceleration = acceleration;
130 }
131
132 public Double getAzimuth() {
133 return azimuth;
134 }
135
136 public void setAzimuth(Double azimut) {
137 this.azimuth = azimut;
138 }
139
140 public Double getAzimuthVariation() {
141 return azimuthVariation;
142 }
143
144 public void setAzimuthVariation(Double azimuthVariation) {
145 this.azimuthVariation = azimuthVariation;
146 }
147
148 }