當前位置: 首頁>>代碼示例>>Java>>正文


Java GeoNamesPOIProvider類代碼示例

本文整理匯總了Java中org.osmdroid.bonuspack.location.GeoNamesPOIProvider的典型用法代碼示例。如果您正苦於以下問題:Java GeoNamesPOIProvider類的具體用法?Java GeoNamesPOIProvider怎麽用?Java GeoNamesPOIProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GeoNamesPOIProvider類屬於org.osmdroid.bonuspack.location包,在下文中一共展示了GeoNamesPOIProvider類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.osmdroid.bonuspack.location.GeoNamesPOIProvider; //導入依賴的package包/類
/**
 * Retrieves the POI string for a given location object 
 * and sends it to the task's cache.
 */
@Override
public void run() {
	task.setGetPOIThread(Thread.currentThread());
	android.os.Process
			.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
	task.handleGetPOIState(STATE_GET_POI_RUNNING);
	try {
		if (Thread.interrupted()) {
			throw new InterruptedException();
		}
		POI poi;
		// get the Geonames provider
		GeoNamesPOIProvider poiProvider = new GeoNamesPOIProvider(
				"bradleyjsimons");
		GeoLocation location = task.getLocation();
		GeoPoint geoPoint = new GeoPoint(location.getLatitude(),
				location.getLongitude());
		ArrayList<POI> pois = poiProvider.getPOICloseTo(geoPoint, 1, 0.8);
		if (Thread.interrupted()) {
			throw new InterruptedException();
		}
		if (pois.size() > 0 && pois != null) {
			poi = pois.get(0);
		} else {
			poi = null;
		}
		task.setPOICache(poi.mType);
	} catch (Exception e) {
		task.setPOICache("Unknown Location");
		e.printStackTrace();
	} finally {
		if (task.getPOICache() == null
				|| task.getPOICache().equals("Unknown Location")) {
			task.setPOICache("Unknown Location ("
					+ task.getLocation().getLongitude() + ","
					+ task.getLocation().getLatitude() + ")");
			task.handleGetPOIState(STATE_GET_POI_FAILED);
		} else {
			task.handleGetPOIState(STATE_GET_POI_COMPLETE);
		}
		// task.setGetPOIThread(null);
		Thread.interrupted();
	}
}
 
開發者ID:CMPUT301W14T08,項目名稱:GeoChan,代碼行數:49,代碼來源:GetPOIRunnable.java

示例2: run

import org.osmdroid.bonuspack.location.GeoNamesPOIProvider; //導入依賴的package包/類
/**
 * Retrieves the POI string for a given location object 
 * and sends it to the task's cache.
 */
@Override
public void run() {
	task.setGetPOIThread(Thread.currentThread());
	android.os.Process
			.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
	task.handleGetPOIState(STATE_GET_POI_RUNNING);
	GeoLocation location = task.getLocation();
	try {
		if (Thread.interrupted()) {
			throw new InterruptedException();
		}
		// get the Geonames provider
		POI poi;
		// "bradleyjsimons" is the username on the service
		GeoNamesPOIProvider poiProvider = new GeoNamesPOIProvider(
				"bradleyjsimons");
		GeoPoint geoPoint = new GeoPoint(location.getLatitude(),
				location.getLongitude());
		ArrayList<POI> pois = poiProvider.getPOICloseTo(geoPoint, 1, 0.8);
		if (Thread.interrupted()) {
			throw new InterruptedException();
		}
		if (pois != null && pois.size() > 0) {
			poi = pois.get(0);
		} else {
			poi = null;
		}
		task.setPOICache(poi.mType);
	} catch (Exception e) {
		task.setPOICache("Unknown Location");
		e.printStackTrace();
	} finally {
		String poiString = task.getPOICache();
		if (poiString == null || poiString.equals("Unknown Location")) {
			poiString = "Unknown Location ("
					+ task.getLocation().getLongitude() + ","
					+ task.getLocation().getLatitude() + ")";
			task.setPOICache(poiString);
			task.getLocation().setLocationDescription(poiString);
			task.getComment().setLocation(task.getLocation());
			task.handleGetPOIState(STATE_GET_POI_FAILED);
		} else {
			task.getLocation().setLocationDescription(poiString);
			task.getComment().setLocation(task.getLocation());
			GeoLocationLog geoLocationLog = GeoLocationLog.getInstance();
			geoLocationLog.addLogEntry(location);
			task.handleGetPOIState(STATE_GET_POI_COMPLETE);
		}
		// task.setGetPOIThread(null);
		Thread.interrupted();
	}
}
 
開發者ID:CMPUT301W14T08,項目名稱:GeoChan,代碼行數:57,代碼來源:GetPOIOnPostRunnable.java


注:本文中的org.osmdroid.bonuspack.location.GeoNamesPOIProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。