-
- All Implemented Interfaces:
-
org.osmdroid.config.IConfigurationProvider
public class DefaultConfigurationProvider implements IConfigurationProvider
Default configuration provider for osmdroid Issue 481Created on 11/29/2016.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringDEFAULT_USER_AGENTprotected longgpsWaitTimeprotected booleandebugModeprotected booleandebugMapViewprotected booleandebugTileProvidersprotected booleandebugMapTileDownloaderprotected booleanisMapViewHardwareAcceleratedprotected StringuserAgentValueprotected StringuserAgentHttpHeaderprotected shortcacheMapTileCountprotected shorttileDownloadThreadsprotected shorttileFileSystemThreadsprotected shorttileDownloadMaxQueueSizeprotected shorttileFileSystemMaxQueueSizeprotected longtileFileSystemCacheMaxBytesprotected longtileFileSystemCacheTrimBytesprotected SimpleDateFormathttpHeaderDateTimeFormatprotected FileosmdroidBasePathprotected FileosmdroidTileCacheprotected ProxyhttpProxyprotected intanimationSpeedDefaultprotected intanimationSpeedShortprotected booleanenforceTileSystemBounds
-
Constructor Summary
Constructors Constructor Description DefaultConfigurationProvider()
-
Method Summary
Modifier and Type Method Description longgetGpsWaitTime()default is 20 seconds voidsetGpsWaitTime(long gpsWaitTime)The time we wait after the last gps location before using a non-gps location. voidsetDebugMode(boolean debugMode)voidsetDebugMapView(boolean debugMapView)voidsetDebugTileProviders(boolean debugTileProviders)voidsetDebugMapTileDownloader(boolean debugMapTileDownloader)booleanisMapViewHardwareAccelerated()default is false StringgetUserAgentValue()voidsetUserAgentValue(String userAgentValue)Enables you to override the default "osmdroid" value for HTTP user agents. StringgetUserAgentHttpHeader()"User-Agent" is the default value and standard used throughout all http servers, unlikely to changeWhen calling @link load, it is set to getPackageName which is defined your manifest filemade adjustable just in casefrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants voidsetUserAgentHttpHeader(String userAgentHttpHeader)"User-Agent" is the default value and standard used throughout all http servers, unlikely to changeWhen calling @link load, it is set to getPackageName which is defined your manifest filemade adjustable just in casefrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants shortgetCacheMapTileCount()Initial tile cache size (in memory). voidsetCacheMapTileCount(short cacheMapTileCount)Initial tile cache size (in memory). shortgetTileDownloadThreads()number of tile download threads, conforming to OSM policy:http://wiki.openstreetmap. voidsetTileDownloadThreads(short tileDownloadThreads)shortgetTileFileSystemThreads()used for both file system cache and the sqlite cache voidsetTileFileSystemThreads(short tileFileSystemThreads)used for both file system cache and the sqlite cache shortgetTileDownloadMaxQueueSize()voidsetTileDownloadMaxQueueSize(short tileDownloadMaxQueueSize)shortgetTileFileSystemMaxQueueSize()voidsetTileFileSystemMaxQueueSize(short tileFileSystemMaxQueueSize)longgetTileFileSystemCacheMaxBytes()default is 600 Mb voidsetTileFileSystemCacheMaxBytes(long tileFileSystemCacheMaxBytes)longgetTileFileSystemCacheTrimBytes()When the cache size exceeds maxCacheSize, tiles will be automatically removed to reach this target. voidsetTileFileSystemCacheTrimBytes(long tileFileSystemCacheTrimBytes)SimpleDateFormatgetHttpHeaderDateTimeFormat()voidsetHttpHeaderDateTimeFormat(SimpleDateFormat httpHeaderDateTimeFormat)FilegetOsmdroidBasePath()Base path for osmdroid files. FilegetOsmdroidBasePath(Context context)Base path for osmdroid files. FilegetOsmdroidTileCache()by default, maps to getOsmdroidBasePath() + "/tiles"By default, it is defined in SD card, osmdroid directory.Sets the location where the tile cache is stored. FilegetOsmdroidTileCache(Context context)by default, maps to getOsmdroidBasePath() + "/tiles"By default, it is defined in SD card, osmdroid directory.Sets the location where the tile cache is stored. ProxygetHttpProxy()voidsetHttpProxy(Proxy httpProxy)intgetAnimationSpeedDefault()Used during zoom animationshttps://github. voidsetAnimationSpeedDefault(int durationsMilliseconds)Used during zoom animationshttps://github. intgetAnimationSpeedShort()Used during zoom animationshttps://github. voidsetAnimationSpeedShort(int durationsMilliseconds)Used during zoom animationshttps://github. voidsetEnforceTileSystemBounds(boolean mValue)See isEnforceTileSystemBounds. booleanisDebugMode()Typically used to enable additional debuggingfrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants booleanisDebugMapView()Typically used to enable additional debugging booleanisDebugTileProviders()Typically used to enable additional debuggingfrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants booleanisDebugMapTileDownloader()voidsetMapViewHardwareAccelerated(boolean mapViewHardwareAccelerated)must be set before the mapview is created or inflated from a layout.If you're only using single point icons, then you can probably get away with setting this to trueotherwise (using polylines, paths, polygons) set it to false. Map<String, String>getAdditionalHttpRequestProperties()Enables you to set and get additional HTTP request properties. voidload(Context ctx, SharedPreferences prefs)loads the configuration from shared preferences, if the preferences defined in this file are not alreadyset, them they will be populated with defaults. voidsave(Context ctx, SharedPreferences prefs)saves the current configuration to the shared preference location longgetExpirationExtendedDuration()Returns the amount of time in ms added to server specified tile expiration timeAdded as part of issue https://github. voidsetExpirationExtendedDuration(long period)Optionally extends the amount of time that downloaded tiles remain in the cache beyond either theserver specified expiration time stamp or the default expiration time {DEFAULT_MAXIMUM_CACHED_FILE_AGE}Note: this setting only controls tiles as they are downloaded. voidsetExpirationOverrideDuration(Long period)Optional period of time in ms that will override any downloaded tile's expiration timestamp LonggetExpirationOverrideDuration()Optional period of time in ms that will override any downloaded tile's expiration timestamp booleanisMapViewRecyclerFriendly()If true, the map view will set .setHasTransientState(true) for API 16+ devices.This is now the default setting. voidsetMapViewRecyclerFriendly(boolean enabled)If true, the map view will set .setHasTransientState(true) for API 16+ devices.This is now the default setting. voidsetCacheMapTileOvershoot(short value)In memory tile count, used by the tiles overlay shortgetCacheMapTileOvershoot()In memory tile count, used by the tiles overlay longgetTileGCFrequencyInMillis()Delay between tile garbage collection calls voidsetTileGCFrequencyInMillis(long pMillis)intgetTileGCBulkSize()Tile garbage collection bulk size voidsetTileGCBulkSize(int pSize)longgetTileGCBulkPauseInMillis()Pause during tile garbage collection bulk deletions voidsetTileGCBulkPauseInMillis(long pMillis)voidsetMapTileDownloaderFollowRedirects(boolean value)enables/disables tile downloading following redirects. booleanisMapTileDownloaderFollowRedirects()StringgetNormalizedUserAgent()booleanisEnforceTileSystemBounds()Default is false for the DefaultConfigurationProviderIf true and a bounding box is beyond that of the org.osmdroid.util.TileSystem,then an exception is thrown by checks in org.osmdroid.util.BoundingBoxIf false, then no exception is thrown. -
-
Method Detail
-
getGpsWaitTime
long getGpsWaitTime()
default is 20 seconds
-
setGpsWaitTime
void setGpsWaitTime(long gpsWaitTime)
The time we wait after the last gps location before using a non-gps location.
-
setDebugMode
void setDebugMode(boolean debugMode)
-
setDebugMapView
void setDebugMapView(boolean debugMapView)
-
setDebugTileProviders
void setDebugTileProviders(boolean debugTileProviders)
-
setDebugMapTileDownloader
void setDebugMapTileDownloader(boolean debugMapTileDownloader)
-
isMapViewHardwareAccelerated
boolean isMapViewHardwareAccelerated()
default is false
-
getUserAgentValue
String getUserAgentValue()
-
setUserAgentValue
void setUserAgentValue(String userAgentValue)
Enables you to override the default "osmdroid" value for HTTP user agents. Used when downloading tiles
You MUST use this to set the user agent to some value specific to your application.Typical usage: Context.getApplicationContext().getPackageName();from org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants
-
getUserAgentHttpHeader
String getUserAgentHttpHeader()
"User-Agent" is the default value and standard used throughout all http servers, unlikely to changeWhen calling @link load, it is set to getPackageName which is defined your manifest file
made adjustable just in casefrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants
-
setUserAgentHttpHeader
void setUserAgentHttpHeader(String userAgentHttpHeader)
"User-Agent" is the default value and standard used throughout all http servers, unlikely to changeWhen calling @link load, it is set to getPackageName which is defined your manifest file
made adjustable just in casefrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants
-
getCacheMapTileCount
short getCacheMapTileCount()
Initial tile cache size (in memory). The size will be increased as required by calling ensureCapacity The tile cache will always be at least 3x3.from org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants used by MapTileCache
-
setCacheMapTileCount
void setCacheMapTileCount(short cacheMapTileCount)
Initial tile cache size (in memory). The size will be increased as required by calling ensureCapacity The tile cache will always be at least 3x3.from org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants used by MapTileCache
-
getTileDownloadThreads
short getTileDownloadThreads()
number of tile download threads, conforming to OSM policy:http://wiki.openstreetmap.org/wiki/Tile_usage_policydefault is 2
-
setTileDownloadThreads
void setTileDownloadThreads(short tileDownloadThreads)
-
getTileFileSystemThreads
short getTileFileSystemThreads()
used for both file system cache and the sqlite cache
-
setTileFileSystemThreads
void setTileFileSystemThreads(short tileFileSystemThreads)
used for both file system cache and the sqlite cache
-
getTileDownloadMaxQueueSize
short getTileDownloadMaxQueueSize()
-
setTileDownloadMaxQueueSize
void setTileDownloadMaxQueueSize(short tileDownloadMaxQueueSize)
-
getTileFileSystemMaxQueueSize
short getTileFileSystemMaxQueueSize()
-
setTileFileSystemMaxQueueSize
void setTileFileSystemMaxQueueSize(short tileFileSystemMaxQueueSize)
-
getTileFileSystemCacheMaxBytes
long getTileFileSystemCacheMaxBytes()
default is 600 Mb
-
setTileFileSystemCacheMaxBytes
void setTileFileSystemCacheMaxBytes(long tileFileSystemCacheMaxBytes)
-
getTileFileSystemCacheTrimBytes
long getTileFileSystemCacheTrimBytes()
When the cache size exceeds maxCacheSize, tiles will be automatically removed to reach this target. In bytes. Default is 500 Mb.
-
setTileFileSystemCacheTrimBytes
void setTileFileSystemCacheTrimBytes(long tileFileSystemCacheTrimBytes)
-
getHttpHeaderDateTimeFormat
SimpleDateFormat getHttpHeaderDateTimeFormat()
-
setHttpHeaderDateTimeFormat
void setHttpHeaderDateTimeFormat(SimpleDateFormat httpHeaderDateTimeFormat)
-
getOsmdroidBasePath
File getOsmdroidBasePath()
Base path for osmdroid files. Zip/sqlite/mbtiles/etc files are in this folder.Note: also used for offline tile sources
If no directory has been set before with setOsmdroidBasePath it triesto automatically detect one. On API>29 and for better results use getOsmdroidBasePath
-
getOsmdroidBasePath
File getOsmdroidBasePath(Context context)
Base path for osmdroid files. Zip/sqlite/mbtiles/etc files are in this folder.Note: also used for offline tile sources
If no directory has been set before with setOsmdroidBasePath it triesto automatically detect one. Passing a context gives better results than getOsmdroidBasePath and is required to find any location on API29.
-
getOsmdroidTileCache
File getOsmdroidTileCache()
by default, maps to getOsmdroidBasePath() + "/tiles"By default, it is defined in SD card, osmdroid directory.Sets the location where the tile cache is stored. Changes are only in effect when the { } is created. Changes made after it's creation (either pogrammatic or via layout inflator) haveno effect until the map is restarted or the setTileProvider is changed or recreated.
Note: basePath and tileCache directories can be changed independentlyThis has no effect on offline archives and can be changed independently
If no directory has been set before with setOsmdroidTileCache it triesto automatically detect one. On API>29 and for better results use getOsmdroidTileCache
-
getOsmdroidTileCache
File getOsmdroidTileCache(Context context)
by default, maps to getOsmdroidBasePath() + "/tiles"By default, it is defined in SD card, osmdroid directory.Sets the location where the tile cache is stored. Changes are only in effect when the org.osmdroid.views.MapView}is created. Changes made after it's creation (either pogrammatic or via layout inflator) haveno effect until the map is restarted or the setTileProvider is changed or recreated.
Note: basePath and tileCache directories can be changed independentlyThis has no effect on offline archives and can be changed independently
If no directory has been set before with setOsmdroidTileCache it triesto automatically detect one. Passing a context gives better results than getOsmdroidTileCache and is required to find any location on API29.
-
getHttpProxy
Proxy getHttpProxy()
-
setHttpProxy
void setHttpProxy(Proxy httpProxy)
-
getAnimationSpeedDefault
int getAnimationSpeedDefault()
Used during zoom animationshttps://github.com/osmdroid/osmdroid/issues/650
-
setAnimationSpeedDefault
void setAnimationSpeedDefault(int durationsMilliseconds)
Used during zoom animationshttps://github.com/osmdroid/osmdroid/issues/650
-
getAnimationSpeedShort
int getAnimationSpeedShort()
Used during zoom animationshttps://github.com/osmdroid/osmdroid/issues/650
-
setAnimationSpeedShort
void setAnimationSpeedShort(int durationsMilliseconds)
Used during zoom animationshttps://github.com/osmdroid/osmdroid/issues/650
-
setEnforceTileSystemBounds
void setEnforceTileSystemBounds(boolean mValue)
-
isDebugMode
boolean isDebugMode()
Typically used to enable additional debuggingfrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants
-
isDebugMapView
boolean isDebugMapView()
Typically used to enable additional debugging
-
isDebugTileProviders
boolean isDebugTileProviders()
Typically used to enable additional debuggingfrom org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants
-
isDebugMapTileDownloader
boolean isDebugMapTileDownloader()
-
setMapViewHardwareAccelerated
void setMapViewHardwareAccelerated(boolean mapViewHardwareAccelerated)
must be set before the mapview is created or inflated from a layout.If you're only using single point icons, then you can probably get away with setting this to trueotherwise (using polylines, paths, polygons) set it to false.
default is false
-
getAdditionalHttpRequestProperties
Map<String, String> getAdditionalHttpRequestProperties()
Enables you to set and get additional HTTP request properties. Used when downloading tiles.Mustn't be null, but will be empty in most cases.
A simple use case would be:Configuration.getInstance().getAdditionalHttpRequestProperties().put("Origin", "http://www.example-social-network.com");
See https://github.com/osmdroid/osmdroid/issues/570
-
load
void load(Context ctx, SharedPreferences prefs)
loads the configuration from shared preferences, if the preferences defined in this file are not alreadyset, them they will be populated with defaults. This also initializes the tile storage cache tothe largested writable storage partition available.
-
save
void save(Context ctx, SharedPreferences prefs)
saves the current configuration to the shared preference location
-
getExpirationExtendedDuration
long getExpirationExtendedDuration()
Returns the amount of time in ms added to server specified tile expiration timeAdded as part of issue https://github.com/osmdroid/osmdroid/issues/490
-
setExpirationExtendedDuration
void setExpirationExtendedDuration(long period)
Optionally extends the amount of time that downloaded tiles remain in the cache beyond either theserver specified expiration time stamp or the default expiration time {DEFAULT_MAXIMUM_CACHED_FILE_AGE}
Note: this setting only controls tiles as they are downloaded. tiles already in the cache arenot effected by this settingAdded as part of issue https://github.com/osmdroid/osmdroid/issues/490
- Parameters:
period- time in ms, if 0, no additional time to the 'server provided expiration' or the'default expiration time' is added.
-
setExpirationOverrideDuration
void setExpirationOverrideDuration(Long period)
Optional period of time in ms that will override any downloaded tile's expiration timestamp
- Parameters:
period- if null, this setting is unset, server value + getExpirationExtendedDuration applyif not null, this this value is used
-
getExpirationOverrideDuration
Long getExpirationOverrideDuration()
Optional period of time in ms that will override any downloaded tile's expiration timestamp
-
isMapViewRecyclerFriendly
boolean isMapViewRecyclerFriendly()
If true, the map view will set .setHasTransientState(true) for API 16+ devices.This is now the default setting. Set to false if this is causing you issues
-
setMapViewRecyclerFriendly
void setMapViewRecyclerFriendly(boolean enabled)
If true, the map view will set .setHasTransientState(true) for API 16+ devices.This is now the default setting. Set to false if this is causing you issues
-
setCacheMapTileOvershoot
void setCacheMapTileOvershoot(short value)
In memory tile count, used by the tiles overlay
-
getCacheMapTileOvershoot
short getCacheMapTileOvershoot()
In memory tile count, used by the tiles overlay
-
getTileGCFrequencyInMillis
long getTileGCFrequencyInMillis()
Delay between tile garbage collection calls
-
setTileGCFrequencyInMillis
void setTileGCFrequencyInMillis(long pMillis)
-
getTileGCBulkSize
int getTileGCBulkSize()
Tile garbage collection bulk size
-
setTileGCBulkSize
void setTileGCBulkSize(int pSize)
-
getTileGCBulkPauseInMillis
long getTileGCBulkPauseInMillis()
Pause during tile garbage collection bulk deletions
-
setTileGCBulkPauseInMillis
void setTileGCBulkPauseInMillis(long pMillis)
-
setMapTileDownloaderFollowRedirects
void setMapTileDownloaderFollowRedirects(boolean value)
enables/disables tile downloading following redirects. default is true
-
isMapTileDownloaderFollowRedirects
boolean isMapTileDownloaderFollowRedirects()
-
getNormalizedUserAgent
String getNormalizedUserAgent()
-
isEnforceTileSystemBounds
boolean isEnforceTileSystemBounds()
Default is false for the DefaultConfigurationProviderIf true and a bounding box is beyond that of the org.osmdroid.util.TileSystem,then an exception is thrown by checks in org.osmdroid.util.BoundingBoxIf false, then no exception is thrown.Historical note. Prior to late Feb 2018, which could have been around v6.0.2,the behavior was to NOT throw an exception, Starting with 6.0.2, it starting throwing.This caused a number of issues when importing content from other sources.July 2022, this method was added to help reduce the pain associated with this withthe default set to false (do not throw).Keep in mind, that coordinates beyond that of the tile system may render inaccurately orhave strange behavior.
-
-
-
-