Package dev.avelar.mapnik
Class Mapnik
java.lang.Object
dev.avelar.mapnik.Mapnik
Global Mapnik setup.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathThe directory the bundle was unpacked to, or null if the natives are not bundled.static Set<Capability>What this Mapnik was built with.static voidDrop cached marker images and memory-mapped files.static StringThe directories plugins were registered from, separated by colons.Names of the registered input plugins, for examplegeojsonandshape.static voidenableProjNetwork(boolean enable) Let PROJ download the datum-shift grids it needs but does not have (for example to convert NAD27 to NAD83 exactly) from its content network, and keep them in its cache.static StringVersion of Mapnik this wrapper release was built and tested against.Names of every font face registered in this process, sorted, for use asface-name.The font file that provides a face, or empty if no registered face has that name.static booleanhasCairo()True if Mapnik was built with Cairo, which PDF, SVG and PostScript output needs.static booleanTrue if the native libraries came from amapnik-java-natives-*bundle on the class path, so this Mapnik, its dependencies, input plugins, fonts and PROJ data all ship with the program.static booleanTrue when the loaded Mapnik has the same major.minor version asexpectedVersion().static booleanisDatasourceRegistered(String name) True if an input plugin with this name, such asgeojson, is registered.static longHow many native objects (maps, images, layers and so on) have been garbage collected without being closed since the JVM started.static voidregisterDatasource(Path pluginFile) Register one input plugin file.static voidLoad input plugins (postgis, shape, gdal...) from dir.static voidregisterFontFile(Path file) Register one font file.static voidregisterFonts(String dir) Register fonts from dir.static doublescaleDenominator(double mapUnitsPerPixel, boolean geographic) The scale denominator for a map scale in projection units per pixel.static voidsetTrustedCertificates(Path pemFile) Trust the certificates in a PEM file for HTTPS tile sources (seeDatasource.tilesFromUrl(java.lang.String, java.lang.String)), instead of the bundled list or the system's.static booleansupports(Capability capability) static Stringversion()Version of the Mapnik library the native shim is loaded against.static intNumeric Mapnik version: major * 100000 + minor * 100 + patch, for example 400302 for 4.3.2.
-
Method Details
-
version
Version of the Mapnik library the native shim is loaded against. -
versionNumber
public static int versionNumber()Numeric Mapnik version: major * 100000 + minor * 100 + patch, for example 400302 for 4.3.2. -
datasourcePlugins
Names of the registered input plugins, for examplegeojsonandshape. -
scaleDenominator
public static double scaleDenominator(double mapUnitsPerPixel, boolean geographic) The scale denominator for a map scale in projection units per pixel. Passgeographictrue for degrees. This is the number layers and rules compare against their scale ranges. -
isBundled
public static boolean isBundled()True if the native libraries came from amapnik-java-natives-*bundle on the class path, so this Mapnik, its dependencies, input plugins, fonts and PROJ data all ship with the program. -
bundledDirectory
The directory the bundle was unpacked to, or null if the natives are not bundled. -
hasCairo
public static boolean hasCairo()True if Mapnik was built with Cairo, which PDF, SVG and PostScript output needs. -
capabilities
What this Mapnik was built with. -
supports
-
fontFaces
Names of every font face registered in this process, sorted, for use asface-name. -
fontFile
The font file that provides a face, or empty if no registered face has that name. -
registerFontFile
Register one font file. ThrowsMapnikExceptionif Mapnik cannot read it as a font. -
registerDatasource
Register one input plugin file. ThrowsMapnikExceptionif it cannot be loaded. -
isDatasourceRegistered
True if an input plugin with this name, such asgeojson, is registered. -
datasourcePluginDirectories
The directories plugins were registered from, separated by colons. -
setTrustedCertificates
Trust the certificates in a PEM file for HTTPS tile sources (seeDatasource.tilesFromUrl(java.lang.String, java.lang.String)), instead of the bundled list or the system's. Use it for a server with a private certificate authority. Applies to datasources created afterwards. The same can be done with theSSL_CERT_FILEenvironment variable. It also setsCURL_CA_BUNDLE, which PROJ's downloader reads. The setting is for the whole process, so it also applies to PROJ's downloads (seeenableProjNetwork(boolean)) and anything else in the process that readsSSL_CERT_FILE. -
enableProjNetwork
public static void enableProjNetwork(boolean enable) Let PROJ download the datum-shift grids it needs but does not have (for example to convert NAD27 to NAD83 exactly) from its content network, and keep them in its cache. Off by default, because it makes network requests. Call it before the first projection is used on a thread: PROJ reads the setting when it first starts on that thread. The same can be done with thePROJ_NETWORK=ONenvironment variable. -
clearCaches
public static void clearCaches()Drop cached marker images and memory-mapped files. Call it after changing files Mapnik has already read. -
expectedVersion
Version of Mapnik this wrapper release was built and tested against. -
isCompatible
public static boolean isCompatible()True when the loaded Mapnik has the same major.minor version asexpectedVersion(). -
registerDatasources
Load input plugins (postgis, shape, gdal...) from dir. Call once at startup. -
registerFonts
Register fonts from dir. Call once at startup. -
leakedHandles
public static long leakedHandles()How many native objects (maps, images, layers and so on) have been garbage collected without being closed since the JVM started. Each one is a native memory leak. The first few are logged as warnings; set-Dmapnik.leakTrace=trueto include where they were created.
-