public float getLen() { List<LocationX> pms = getPlaceMarks(); LocationX pm1 = null; float len = 0; for (LocationX pm : pms) { if (pm1 != null) len += pm.distanceTo(pm1); pm1 = pm; } return len; }
public LocationX getNearest(LocationX l) { double dist = -1; LocationX pmNearest = null; for (LocationX pm : getPlaceMarks()) { // double dx = pm.getLongitude() - l.getLongitude(); // double dy = pm.getLatitude() - l.getLatitude(); // double d = dx * dx + dy * dy; double d = l.distanceTo(pm); if (pmNearest == null || d < dist) { pmNearest = pm; dist = d; } } return pmNearest; }