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


Java OpenStreetMapTileProviderConstants类代码示例

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


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


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