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


Java GeocoderNominatim类代码示例

本文整理汇总了Java中org.osmdroid.bonuspack.location.GeocoderNominatim的典型用法代码示例。如果您正苦于以下问题:Java GeocoderNominatim类的具体用法?Java GeocoderNominatim怎么用?Java GeocoderNominatim使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeocoderNominatim类属于org.osmdroid.bonuspack.location包,在下文中一共展示了GeocoderNominatim类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doInBackground

import org.osmdroid.bonuspack.location.GeocoderNominatim; //导入依赖的package包/类
@Override
    protected Void doInBackground(Void... voids) {
        GeocoderNominatim nominatim = new GeocoderNominatim(context.getResources().getString(R.string.user_agent));
        try {
            List<Address> addresses = nominatim.getFromLocation(latitude, longitude, 1);//only get one location
            if (addresses != null && addresses.size() > 0) {
                reverseGeocodedAddress = addresses.get(0);
                Bundle bundle = addresses.get(0).getExtras();
                String osm_type = bundle.getString("osm_type");
                AppLog.log(addresses.get(0));
                //only osm nodes are filtered though
//                if (osm_type.equals("node")) {
                double nodeLat = reverseGeocodedAddress.getLatitude();
                double nodeLon = reverseGeocodedAddress.getLongitude();
                //The geocoding is considered as valid if the node location
                //is under the distance 4 meters form the provided location (user click location on map)
                AppLog.log(distance(latitude, nodeLat, longitude, nodeLon, 0, 0));
                if (distance(latitude, nodeLat, longitude, nodeLon, 0, 0) < 4) {
                    long osm_id = bundle.getLong("osm_id");
                    getNode(connection, osm_id);
                }
//                } else {
//                    //Do noting
//                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
 
开发者ID:CityZenApp,项目名称:Android-Development,代码行数:31,代码来源:ReverseGeocodingTask.java

示例2: doInBackground

import org.osmdroid.bonuspack.location.GeocoderNominatim; //导入依赖的package包/类
@Override
protected List<Address> doInBackground(String... addresses) {
    List<Address> addressList = null;

    GeocoderNominatim geoNom = new GeocoderNominatim("");
    try {
        // we are only getting a maximum of 50 matching addresses
        addressList = geoNom.getFromLocationName(addresses[0], 50);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return addressList;
}
 
开发者ID:CMPUT301F16T01,项目名称:Carrier,代码行数:14,代码来源:ElasticRequestController.java

示例3: getAddress

import org.osmdroid.bonuspack.location.GeocoderNominatim; //导入依赖的package包/类
/**
 * Reverse Geocoding
 */
public String getAddress(GeoPoint p) {
	GeocoderNominatim geocoder = new GeocoderNominatim(this);
	String theAddress;
	try {
		double dLatitude = p.getLatitudeE6() * 1E-6;
		double dLongitude = p.getLongitudeE6() * 1E-6;
		List<Address> addresses = geocoder.getFromLocation(dLatitude,
				dLongitude, 1);
		StringBuilder sb = new StringBuilder();
		if (addresses.size() > 0) {
			Address address = addresses.get(0);
			int n = address.getMaxAddressLineIndex();
			for (int i = 0; i <= n; i++) {
				if (i != 0)
					sb.append(", ");
				sb.append(address.getAddressLine(i));
			}
			theAddress = new String(sb.toString());
		} else {
			theAddress = null;
		}
	} catch (IOException e) {
		theAddress = null;
	}
	if (theAddress != null) {
		return theAddress;
	} else {
		return "";
	}
}
 
开发者ID:nirabpudasaini,项目名称:Mero-Bhada-Meter,代码行数:34,代码来源:MapActivity.java


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