本文整理汇总了Java中org.osmdroid.util.GeoPoint.distanceTo方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPoint.distanceTo方法的具体用法?Java GeoPoint.distanceTo怎么用?Java GeoPoint.distanceTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osmdroid.util.GeoPoint
的用法示例。
在下文中一共展示了GeoPoint.distanceTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateDirections
import org.osmdroid.util.GeoPoint; //导入方法依赖的package包/类
public void generateDirections() {
if (_audioPoints.size() == 0)
return;
int audioPointIndex = 0;
for(int i = 0; i < _geoPoints.size() - 1; i++) {
GeoPoint current = _geoPoints.get(i).Position;
GeoPoint next = _geoPoints.get(i + 1).Position;
AudioPoint audioPoint = _audioPoints.get(audioPointIndex);
while (current.distanceTo(next) > current.distanceTo(audioPoint.Position))
{
audioPoint.Direction = new Vector2(current, next).normalize();
if (++audioPointIndex == _audioPoints.size())
return;
audioPoint = _audioPoints.get(audioPointIndex);
}
}
}
示例2: createCluster
import org.osmdroid.util.GeoPoint; //导入方法依赖的package包/类
private StaticCluster createCluster(Marker m, MapView mapView) {
GeoPoint clusterPosition = m.getPosition();
StaticCluster cluster = new StaticCluster(clusterPosition);
cluster.add(m);
mClonedMarkers.remove(m);
if (mapView.getZoomLevel() > mMaxClusteringZoomLevel) {
//above max level => block clustering:
return cluster;
}
Iterator<Marker> it = mClonedMarkers.iterator();
while (it.hasNext()) {
Marker neighbour = it.next();
int distance = clusterPosition.distanceTo(neighbour.getPosition());
if (distance <= mRadiusInMeters) {
cluster.add(neighbour);
it.remove();
}
}
return cluster;
}
示例3: calculateFare
import org.osmdroid.util.GeoPoint; //导入方法依赖的package包/类
@Override
public String calculateFare(Location location) {
GeoPoint geo1 = this.geoLocation;
GeoPoint geo2 = location.getGeoLocation();
float distanceInMeters = geo1.distanceTo(geo2);
float distanceInKm = distanceInMeters/1000;
double costPerKm = 1.48;
//http://stackoverflow.com/questions/13791409/java-format-double-value-as-dollar-amount
DecimalFormat dFormat = new DecimalFormat("#.##");
double cost = (double) distanceInKm * costPerKm;
return ("$" + dFormat.format(cost));
}
示例4: calculateDistanceInKm
import org.osmdroid.util.GeoPoint; //导入方法依赖的package包/类
/**
* Calculate distance between this Location and another.
* @param location the target location
* @return distance between the locations
*/
public double calculateDistanceInKm(Location location) {
GeoPoint geo1 = this.geoLocation;
GeoPoint geo2 = location.getGeoLocation();
float distanceInMeters = geo1.distanceTo(geo2);
float distanceInKm = distanceInMeters / 1000;
return (double) distanceInKm;
}