forked from labexp/osmtracker-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathOverlays.java
More file actions
59 lines (48 loc) · 1.15 KB
/
Copy pathPathOverlays.java
File metadata and controls
59 lines (48 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package net.osmtracker.overlay;
import java.util.ArrayList;
import java.util.List;
import org.osmdroid.views.MapView;
import org.osmdroid.views.overlay.PathOverlay;
import android.content.Context;
/**
* Collection of Overlays, useful to draw interrupted paths
*/
public class PathOverlays {
private int color;
private float width;
private Context ctx;
private MapView osmView;
private boolean havePoint;
private int curIdx=0;
private List<PathOverlay> paths = new ArrayList<PathOverlay>();
private void addPath() {
PathOverlay path = new PathOverlay(color, width, ctx);
paths.add(path);
osmView.getOverlays().add(path);
}
public void clearPath() {
for(PathOverlay path : paths)
path.clearPath();
curIdx=0;
}
public PathOverlays(int color, float width,
Context ctx, MapView osmView) {
this.color=color;
this.width=width;
this.ctx=ctx;
this.osmView = osmView;
addPath();
havePoint=false;
}
public void addPoint(double lat, double lon) {
if(curIdx >= paths.size())
addPath();
paths.get(curIdx).addPoint(lat, lon);
havePoint=true;
}
public void nextSegment() {
if(havePoint)
curIdx++;
havePoint=false;
}
}