当前位置: 首页>>代码示例>>Java>>正文


Java GeoPoint.distanceTo方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:LenaShervarly,项目名称:TreasureHunting,代码行数:22,代码来源:Route.java

示例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;
}
 
开发者ID:BackPackerDz,项目名称:Android-Tariki.dz,代码行数:26,代码来源:RadiusMarkerClusterer.java

示例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));
}
 
开发者ID:CMPUT301F16T19,项目名称:SeekARide,代码行数:13,代码来源:MockLocation.java

示例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;
}
 
开发者ID:CMPUT301F16T19,项目名称:SeekARide,代码行数:13,代码来源:Location.java


注:本文中的org.osmdroid.util.GeoPoint.distanceTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。