• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java OpenStreetMapTileProviderConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createFolderAndCheckIfExists

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
private boolean createFolderAndCheckIfExists(final File pFile) {
	if (pFile.mkdirs()) {
		return true;
	}
	if (OpenStreetMapTileProviderConstants.DEBUGMODE) {
		Log.d(IMapView.LOGTAG,"Failed to create " + pFile + " - wait and check again");
	}

	// if create failed, wait a bit in case another thread created it
	try {
		Thread.sleep(500);
	} catch (final InterruptedException ignore) {
	}
	// and then check again
	if (pFile.exists()) {
		if (OpenStreetMapTileProviderConstants.DEBUGMODE) {
			Log.d(IMapView.LOGTAG,"Seems like another thread created " + pFile);
		}
		return true;
	} else {
		if (OpenStreetMapTileProviderConstants.DEBUGMODE) {
			Log.d(IMapView.LOGTAG,"File still doesn't exist: " + pFile);
		}
		return false;
	}
}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:27,代码来源:SafeTileWriter.java


示例2: SafeTileWriter

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
public SafeTileWriter(Context context) {

		if (context.checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
			safeTilePathBase = OpenStreetMapTileProviderConstants.TILE_PATH_BASE;
		} else {
			safeTilePathBase = new File(context.getExternalCacheDir(), "tiles");
		}

		// do this in the background because it takes a long time
		final Thread t = new Thread() {
			@Override
			public void run() {
				mUsedCacheSpace = 0; // because it's static

				calculateDirectorySize(safeTilePathBase);

				if (mUsedCacheSpace > OpenStreetMapTileProviderConstants.TILE_MAX_CACHE_SIZE_BYTES) {
					cutCurrentCache();
				}
				if (OpenStreetMapTileProviderConstants.DEBUGMODE) {
					Log.d(IMapView.LOGTAG,"Finished init thread");
				}
			}
		};
		t.setPriority(Thread.MIN_PRIORITY);
		t.start();
	}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:28,代码来源:SafeTileWriter.java


示例3: saveFile

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public boolean saveFile(final ITileSource pTileSource, final MapTile pTile,
						final InputStream pStream) {

	final File file = new File(safeTilePathBase, pTileSource.getTileRelativeFilenameString(pTile)
			+ OpenStreetMapTileProviderConstants.TILE_PATH_EXTENSION);

	final File parent = file.getParentFile();
	if (!parent.exists() && !createFolderAndCheckIfExists(parent)) {
		return false;
	}

	BufferedOutputStream outputStream = null;
	try {
		outputStream = new BufferedOutputStream(new FileOutputStream(file.getPath()),
				StreamUtils.IO_BUFFER_SIZE);
		final long length = StreamUtils.copy(pStream, outputStream);

		mUsedCacheSpace += length;
		if (mUsedCacheSpace > OpenStreetMapTileProviderConstants.TILE_MAX_CACHE_SIZE_BYTES) {
			cutCurrentCache(); // TODO perhaps we should do this in the background
		}
	} catch (final IOException e) {
		return false;
	} finally {
		if (outputStream != null) {
			StreamUtils.closeStream(outputStream);
		}
	}
	return true;
}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:32,代码来源:SafeTileWriter.java


示例4: cutCurrentCache

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
/**
 * If the cache size is greater than the max then trim it down to the trim level. This method is
 * synchronized so that only one thread can run it at a time.
 */
private void cutCurrentCache() {

	final File lock=safeTilePathBase;
	synchronized (lock) {

		if (mUsedCacheSpace > OpenStreetMapTileProviderConstants.TILE_TRIM_CACHE_SIZE_BYTES) {

			Log.d(IMapView.LOGTAG,"Trimming tile cache from " + mUsedCacheSpace + " to "
					+ OpenStreetMapTileProviderConstants.TILE_TRIM_CACHE_SIZE_BYTES);

			final List<File> z = getDirectoryFileList(safeTilePathBase);

			// order list by files day created from old to new
			final File[] files = z.toArray(new File[0]);
			Arrays.sort(files, new Comparator<File>() {
				@Override
				public int compare(final File f1, final File f2) {
					return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
				}
			});

			for (final File file : files) {
				if (mUsedCacheSpace <= OpenStreetMapTileProviderConstants.TILE_TRIM_CACHE_SIZE_BYTES) {
					break;
				}

				final long length = file.length();
				if (file.delete()) {
					mUsedCacheSpace -= length;
				}
			}

			Log.d(IMapView.LOGTAG,"Finished trimming tile cache");
		}
	}
}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:41,代码来源:SafeTileWriter.java


示例5: SafeMapTileFilesystemProvider

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
/**
 * Provides a file system based cache tile provider. Other providers can register and store data
 * in the cache.
 *
 * @param pRegisterReceiver
 */
public SafeMapTileFilesystemProvider(Context context, final IRegisterReceiver pRegisterReceiver,
									 final ITileSource pTileSource, final long pMaximumCachedFileAge, int pThreadPoolSize,
									 int pPendingQueueSize) {
	super(pRegisterReceiver, pThreadPoolSize, pPendingQueueSize);
	if (context.checkCallingOrSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
		safeTilePathBase = OpenStreetMapTileProviderConstants.TILE_PATH_BASE;
	} else {
		safeTilePathBase = new File(context.getExternalCacheDir(), "tiles");
	}
	setTileSource(pTileSource);

	mMaximumCachedFileAge = pMaximumCachedFileAge;
}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:20,代码来源:SafeMapTileFilesystemProvider.java


示例6: getMaximumZoomLevel

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public int getMaximumZoomLevel() {
	int result = OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL;
	synchronized (mTileProviderList) {
		for (final MapTileModuleProviderBase tileProvider : mTileProviderList) {
			if (tileProvider.getMaximumZoomLevel() > result) {
				result = tileProvider.getMaximumZoomLevel();
			}
		}
	}
	return result;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:13,代码来源:MapTileProviderArray.java


示例7: computeZoomLevels

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
private void computeZoomLevels() {
    boolean first = true;
    minZoomLevel = OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL;
    for (final MapTileModuleProviderBase provider : mProviders) {
        final int otherMin = provider.getMinimumZoomLevel();;
        if (first) {
            first = false;
            minZoomLevel = otherMin;
        } else {
            minZoomLevel = Math.min(minZoomLevel, otherMin);
        }
    }
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:14,代码来源:MapTileApproximater.java


示例8: approximateTileFromLowerZoom

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
/**
 * Approximate a tile from a lower zoom level
 *
 * @since 6.0.0
 * @param pMapTile Destination tile, for the same place on the planet as the source, but on a higher zoom
 * @return
 */
public Bitmap approximateTileFromLowerZoom(final MapTile pMapTile) {
    for (int zoomDiff = 1; pMapTile.getZoomLevel() - zoomDiff >= OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL ; zoomDiff ++) {
        final Bitmap bitmap = approximateTileFromLowerZoom(pMapTile, zoomDiff);
        if (bitmap != null) {
            return bitmap;
        }
    }
    return null;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:17,代码来源:MapTileApproximater.java


示例9: MapTileProviderTTbox

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
/**
 * Creates a {@link MapTileProviderTTbox}.
 */

public MapTileProviderTTbox(final Context pContext, final IRegisterReceiver pRegisterReceiver, final INetworkAvailablityCheck aNetworkAvailablityCheck, final ITileSource pTileSource,
		int cacheSizeInBytes) {
	super(pTileSource, pRegisterReceiver, cacheSizeInBytes);
	this.context = pContext;
	// super(pTileSource, pRegisterReceiver);
	final TileWriter tileWriter = new TileWriter();

	final MapTileFilesystemProviderTTbox fileSystemProvider = new MapTileFilesystemProviderTTbox(pRegisterReceiver, pTileSource, OpenStreetMapTileProviderConstants.ONE_WEEK * 26,
			aNetworkAvailablityCheck);

	// final MapTileFilesystemProvider fileSystemProvider = new
	// MapTileFilesystemProvider(pRegisterReceiver, pTileSource,
	// OpenStreetMapTileProviderConstants.ONE_WEEK );

	mTileProviderList.add(fileSystemProvider);

	// final MapTileFileArchiveProvider archiveProvider = new
	// MapTileFileArchiveProvider(
	// pRegisterReceiver, pTileSource);
	// mTileProviderList.add(archiveProvider);

	final MapTileSpdyDownloaderTTbox downloaderProvider = new MapTileSpdyDownloaderTTbox(pTileSource, tileWriter, aNetworkAvailablityCheck);
	mTileProviderList.add(downloaderProvider);
	// Memory Management
	initMemoryListener(pContext);
}
 
开发者ID:gabuzomeu,项目名称:osmLib,代码行数:31,代码来源:MapTileProviderTTbox.java


示例10: onPreferenceClick

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
	if (preference.getKey().equals("clear_map_tiles_cache")) {
		File cacheDir = OpenStreetMapTileProviderConstants.OSMDROID_PATH;
		new DeleteCacheTask().execute(cacheDir);
	}
	return true;
}
 
开发者ID:Mapzen-POI-Collector,项目名称:Mapzen-Android,代码行数:9,代码来源:MapzenPreferenceActivity.java


示例11: updateCacheSizeOnUI

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
private void updateCacheSizeOnUI() {
	long cacheDirSize = dirSize(OpenStreetMapTileProviderConstants.OSMDROID_PATH);
	String cacheSize = String.format("%.1f", cacheDirSize/1024f/1024f);
	
	Preference clearMapTilesPref = findPreference("clear_map_tiles_cache");
	clearMapTilesPref.setOnPreferenceClickListener(this);
	StringBuilder sb = new StringBuilder(getString(R.string.current_cache_size))
		.append(": ")
		.append(cacheSize)
		.append(" Mb");
	clearMapTilesPref.setSummary(sb.toString());
}
 
开发者ID:Mapzen-POI-Collector,项目名称:Mapzen-Android,代码行数:13,代码来源:MapzenPreferenceActivity.java


示例12: getFileName

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
public File getFileName(ITileSource tileSource, MapTile tile){
	final File file = new File(OpenStreetMapTileProviderConstants.TILE_PATH_BASE,
			tileSource.getTileRelativeFilenameString(tile) + OpenStreetMapTileProviderConstants.TILE_PATH_EXTENSION);
	return file;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:6,代码来源:CacheManager.java


示例13: currentCacheUsage

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
/** @return volume currently use in the osmdroid local filesystem cache, in bytes. 
 * Note that this method currently takes a while. 
 * */
public long currentCacheUsage(){
	//return TileWriter.getUsedCacheSpace(); //returned value is not stable! Increase and decrease, for unknown reasons. 
	return directorySize(OpenStreetMapTileProviderConstants.TILE_PATH_BASE);
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:8,代码来源:CacheManager.java


示例14: cacheCapacity

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
/** @return the capacity of the osmdroid local filesystem cache, in bytes. 
 * This capacity is currently a hard-coded constant inside osmdroid. */
public long cacheCapacity(){
	return OpenStreetMapTileProviderConstants.TILE_MAX_CACHE_SIZE_BYTES;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:6,代码来源:CacheManager.java


示例15: getMinimumZoomLevel

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public int getMinimumZoomLevel() {
	ITileSource tileSource = mTileSource.get();
	return tileSource != null ? tileSource.getMinimumZoomLevel() : OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL;
}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:6,代码来源:SafeMapTileFilesystemProvider.java


示例16: loadTile

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public Drawable loadTile(final MapTileRequestState pState) throws CantContinueException {

	ITileSource tileSource = mTileSource.get();
	if (tileSource == null) {
		return null;
	}

	final MapTile tile = pState.getMapTile();

	// if there's no sdcard then don't do anything
	if (!getSdCardAvailable()) {
		if (OpenStreetMapTileProviderConstants.DEBUGMODE) {
			Log.d(IMapView.LOGTAG,"No sdcard - do nothing for tile: " + tile);
		}
		return null;
	}

	// Check the tile source to see if its file is available and if so, then render the
	// drawable and return the tile
	final File file = new File(safeTilePathBase,
			tileSource.getTileRelativeFilenameString(tile) + OpenStreetMapTileProviderConstants.TILE_PATH_EXTENSION);
	if (file.exists()) {

		try {
			final Drawable drawable = tileSource.getDrawable(file.getPath());

			// Check to see if file has expired
			final long now = System.currentTimeMillis();
			final long lastModified = file.lastModified();
			final boolean fileExpired = lastModified < now - mMaximumCachedFileAge;

			if (fileExpired && drawable != null) {
				if (OpenStreetMapTileProviderConstants.DEBUGMODE) {
					Log.d(IMapView.LOGTAG,"Tile expired: " + tile);
				}
				ExpirableBitmapDrawable.setDrawableExpired(drawable);
			}

			return drawable;
		} catch (final LowMemoryException e) {
			// low memory so empty the queue
			Log.w(IMapView.LOGTAG,"LowMemoryException downloading MapTile: " + tile + " : " + e);
			throw new CantContinueException(e);
		}
	}

	// If we get here then there is no file in the file cache
	return null;
}
 
开发者ID:microg,项目名称:android_frameworks_mapsv1,代码行数:51,代码来源:SafeMapTileFilesystemProvider.java


示例17: MapTileFilesystemProvider

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
public MapTileFilesystemProvider(final IRegisterReceiver pRegisterReceiver,
		final ITileSource aTileSource) {
	this(pRegisterReceiver, aTileSource, Configuration.getInstance().getExpirationExtendedDuration() + OpenStreetMapTileProviderConstants.DEFAULT_MAXIMUM_CACHED_FILE_AGE);
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:5,代码来源:MapTileFilesystemProvider.java


示例18: getMinimumZoomLevel

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public int getMinimumZoomLevel() {
	OnlineTileSourceBase tileSource = mTileSource.get();
	return (tileSource != null ? tileSource.getMinimumZoomLevel() : OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL);
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:6,代码来源:MapTileDownloader.java


示例19: getMinimumZoomLevel

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
@Override
public int getMinimumZoomLevel() {
    ITileSource tileSource = mTileSource.get();
    return tileSource != null ? tileSource.getMinimumZoomLevel() : OpenStreetMapTileProviderConstants.MINIMUM_ZOOMLEVEL;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:6,代码来源:MapTileSqlCacheProvider.java


示例20: getFileName

import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; //导入依赖的package包/类
public static File getFileName(ITileSource tileSource, MapTile tile) {
    final File file = new File(Configuration.getInstance().getOsmdroidTileCache(),
            tileSource.getTileRelativeFilenameString(tile) + OpenStreetMapTileProviderConstants.TILE_PATH_EXTENSION);
    return file;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:6,代码来源:CacheManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UserDetailsByNameServiceWrapper类代码示例发布时间:2022-05-22
下一篇:
Java FilterFactoryImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap