本文整理汇总了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;
}
}
示例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();
}
示例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;
}
示例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");
}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}