Documentation for maplib/API.kt
- enum class StatusCode
Operation status codes enumeration.
UNKNOWN = 0
CONTINUE = 100 : Continue
PENDING = 101 : Pending
IN_PROCESS = 102 : In process
SUCCESS = 200 : Success
CANCELED = 201 : Canceled
FINISHED = 202 : Finished
WARNING = 300 : Warning, not error
UNEXPECTED_ERROR = 400 : Unexpected error
NOT_SPECIFIED = 401 : Path, value, etc. is not specified
INVALID = 402 : Path, map, structure, etc. is invalid
UNSUPPORTED = 403 : The feature is unsupported
CREATE_FAILED = 404 : Create failed
DELETE_FAILED = 405 : Failed to delete file, folder or something else
SAVE_FAILED = 406 : Failed to save file, folder or something else
SET_FAILED = 407 : Failed to set value
GET_FAILED = 408 : Failed to get value
OPEN_FAILED = 409 : Failed to open file, folder or something else
INSERT_FAILED = 410 : Insert new feature failed
UPDATE_FAILED = 411 : Update feature failed
INIT_FAILED = 412 : Initialize failed
COPY_FAILED = 413 : Copy failed
MOVE_FAILED = 414 : Move failed
CLOSE_FAILED = 415 : Close failed
LOAD_FAILED = 416 : Load failed
RENAME_FAILED = 417 : Rename failed
DRAW_FAILED = 418 : Draw failed
REQUEST_FAILED = 419 : URL Request failed
- object API
Singleton object. Entry point for library interaction.
- init()
Use to load the ‘ngstore’ library on application startup.
- init(context: Context, sentryDSN: String = "")
Initialize library. Should be executed as soon as possible.
- Parameters
context – Context of executed object.
sentryDSN – Sentry URL. Empty string disable sentry (default behaviour)
- fun version(component: String = "") : Int
Returns library version as number.
- Parameters
component – Component value may be one of the following: self, gdal, sqlite, tiff, jpeg, png, jsonc, proj, geotiff, expat, iconv, zlib, openssl.
- Returns
version number.
- fun versionString(component: String = "") : String
Returns library version as string.
- Parameters
component – Component value may be one of the following: self, gdal, sqlite, tiff, jpeg, png, jsonc, proj, geotiff, expat, iconv, zlib, openssl.
- Returns
version string.
- fun getProperty(key: String, defaultValue: String) : String
Get library property.
- Parameters
key – Key value.
value – Default value if not exists.
- Returns
property value corespondent to key.
- fun setProperty(key: String, value: String)
Set library property.
- Parameters
key – Key value.
value – Value to set.
- fun addAuth(auth: Auth) : Boolean
Add authorization to use in HTTP requests and automatically update access tokens if needed.
- Parameters
auth – Authorization class instance.
- fun removeAuth(auth: Auth)
Remove authorization
- Parameters
auth – Authorization class instance to remove.
- fun getCatalog() : Catalog?
Get catalog class instance. The catalog object is singleton.
- Returns
Catalog class instance.
- fun getMap(name: String) : MapDocument?
Get map by name.
- Parameters
name – Map file name. If map file name extension is not set it will append.
- Returns
MapDocument class instance or null.
- fun getStore(name: String = Constants.Store.name) : Store?
Get NextGIS store catalog object. The NextGIS store is geopackage file with some additions needed for library.
- Parameters
name – File name. If file name extension is not set it will append.
- Returns
Catalog object instance or null.
- fun getLastStoreName() : String
Get last store name get by getStore function or default name. Use in TrackerService to get Tracks table from store.
- Returns
Last store name string.
- fun getDataDirectory() : Object?
Get library data directory. Directory to store various data include maps, files, etc.
- Returns
Catalog object instance or null.
- fun getTmpDirectory() : Object?
Get library temp directory.
- Returns
Catalog object instance or null.
- fun backup(name: String, destination: Object, callback: ((status: StatusCode, complete: Double, message: String) -> Boolean)? = null) : Boolean
Create backup zip archive of data and settings.
- Parameters
name – Archive name.
destination – Directory to create backup archive.
callback – Function executed periodically to indicate progress or cancel executing. May be null.
- Returns
True on success.
- fun addNotifyFunction(code: ChangeCode, callback: (uri: String, code: ChangeCode) -> Unit)
Add function executed on various events.
- Parameters
code – Event codes or combination on which callback will execute.
callback – Function to execute.
- fun removeNotifyFunction(callback: (uri: String, code: ChangeCode) -> Unit)
Remove function from notify functions list.
- Parameters
callback – Function to remove.
- fun getCurrentDirectory() : String
Get current directory
- Returns
Current directory path is operating system.
- fun md5(value: String) : String
Create MD5 hash from text.
- Parameters
value – Text to create MD5 hash.
- Returns
MD5 hash string created from text.