當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。