当前位置: 首页>>代码示例>>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;未经允许,请勿转载。