public void onLocationChanged(Location location) { Log.i("", "onLocationChanged: " + location); if (atStop() && lastLocation != null && distanceFromLocation(currentStop.location, lastLocation) > MIN_DISTANCE * 2) { captureActivity.triggerTransitStopDepature(); } if (currentCapture != null && location.getAccuracy() < MIN_ACCURACY * 2) { RoutePoint rp = new RoutePoint(); rp.location = location; rp.time = SystemClock.elapsedRealtime(); currentCapture.points.add(rp); if (lastLocation != null) { currentCapture.distance += distanceFromLocation(lastLocation, location); if (captureActivity != null) captureActivity.updateDistance(); } lastLocation = location; if (captureActivity != null) captureActivity.updateGpsStatus(); } }
private void parseGPXFile(GPXFile gpx) { this.gpx = gpx; Route rt = getRoute(); currentPoints.clear(); if (rt != null) { TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); String locName = targetPointsHelper.getPointNavigateDescription(); for (int i = 0; i < rt.points.size(); i++) { WptPt wptPt = rt.points.get(i); RoutePoint rtp = new RoutePoint(); rtp.gpxOrder = i; rtp.wpt = wptPt; String time = wptPt.getExtensionsToRead().get(VISITED_KEY); try { rtp.visitedTime = Long.parseLong(time); } catch (NumberFormatException e) { } rtp.isNextNavigate = rtp.visitedTime == 0 && locName != null && locName.equals(wptPt.name); if (rtp.isNextNavigate) { locName = null; } currentPoints.add(rtp); } sortPoints(); } }
public int[] routeToArray() { int[] arr = new int[route.size() * 3]; int index = 0; for (RoutePoint routePoint : route) { routePoint.writeAtLocation(arr, index); index += 3; } return arr; }
public int getVisitedCount() { int k = 0; for (RoutePoint rp : currentPoints) { if (rp.isVisited()) { k++; } } return k; }
public void navigateToPoint(RoutePoint rp) { if (!currentPoints.isEmpty()) { if (currentPoints.get(0).isNextNavigate()) { currentPoints.get(0).isNextNavigate = false; } } rp.isNextNavigate = true; sortPoints(); app.getTargetPointsHelper().navigateToPoint(rp.getPoint(), true, -1, rp.getName()); }
public void markPoint(RoutePoint point, boolean visited) { if (point.isNextNavigate() && visited) { naviateToNextPoint(); return; } if (visited) { point.setVisitedTime(System.currentTimeMillis()); } else { point.setVisitedTime(0); } sortPoints(); }
public void updateCurrentTargetPoint() { TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); String locName = targetPointsHelper.getPointNavigateDescription(); for (int i = 0; i < currentPoints.size(); i++) { RoutePoint rtp = currentPoints.get(i); rtp.isNextNavigate = rtp.visitedTime == 0 && locName != null && locName.equals(rtp.getName()); if (rtp.isNextNavigate) { locName = null; } } sortPoints(); }
public boolean naviateToNextPoint() { if (!currentPoints.isEmpty()) { RoutePoint rp = currentPoints.get(0); if (rp.isNextNavigate) { rp.setVisitedTime(System.currentTimeMillis()); sortPoints(); } RoutePoint first = currentPoints.get(0); if (!first.isVisited()) { app.getTargetPointsHelper().navigateToPoint(first.getPoint(), true, -1, first.getName()); first.isNextNavigate = true; return true; } else { app.getTargetPointsHelper().clearPointToNavigate(true); } } return false; }
public String getDistance(RoutePoint rp) { double d = MapUtils.getDistance(rp.getPoint(), getPoint()); String distance = OsmAndFormatter.getFormattedDistance((float) d, app); return distance; }