Package dev.avelar.mapnik
Class Datasource
java.lang.Object
dev.avelar.mapnik.Datasource
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
JavaDatasource,MemoryDatasource
A Mapnik datasource, such as a shapefile or a GeoJSON file. Create one with
create(java.util.Map<java.lang.String, ?>) and
attach it to a Layer. Needs the matching input plugin registered with
Mapnik.registerDatasources(java.lang.String).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA named attribute column.static enumstatic enumstatic enum -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Release this handle.static DatasourceCreate a datasource.encoding()The text encoding of attribute data, for exampleutf-8.envelope()The extent of the data, in the datasource's own projection.Features whose bounding box touchesbox.features(FeatureQuery query) Features matching the query.featuresAtPoint(double x, double y, double tolerance) Features withintoleranceof a point, in the datasource's projection.fields()Attribute columns.The name the datasource gives its data, such as a table or layer name.static DatasourceVector tiles from an MBTiles file (Mapnik Vector Tile data in a SQLite database).The parameters the datasource holds, in key order: the ones you passed, plus any the plugin filled in.static DatasourceAsmbtiles(java.nio.file.Path, java.lang.String), for a PMTiles archive.static DatasourcetilesFromUrl(String url, String layer) Tiles fetched over HTTP:urlis a TileJSON document (.json) or a template such ashttp://host/{z}/{x}/{y}.pbf(or.mvt; other endings are read as raster tiles).type()
-
Method Details
-
create
Create a datasource. Mapnik memory-maps data files and caches the mapping, so do not overwrite a file in place while a process uses it: write a new file and rename it over the old one, then callMapnik.clearCaches().paramsmust containtype, the plugin name (for example"geojson"or"shape"), plus that plugin's options. Values may be String, Integer/Long, Double/Float or Boolean. -
mbtiles
Vector tiles from an MBTiles file (Mapnik Vector Tile data in a SQLite database).layeris the tile layer to draw, such as"places". It is required for vector tiles: with null, Mapnik reads the file as raster tiles (PNG or JPEG images), which is right only for an MBTiles file of pictures. Use it in a layer whose projection isepsg:3857: tiles are Web Mercator. Needs Mapnik'stilesinput plugin, which the prebuilt natives include. -
pmtiles
Asmbtiles(java.nio.file.Path, java.lang.String), for a PMTiles archive. -
tilesFromUrl
Tiles fetched over HTTP:urlis a TileJSON document (.json) or a template such ashttp://host/{z}/{x}/{y}.pbf(or.mvt; other endings are read as raster tiles). The connection is encrypted and the server's certificate is checked against the bundled list of trusted authorities (or the file named bySSL_CERT_FILE, or set withMapnik.setTrustedCertificates(java.nio.file.Path)); an untrusted server's tiles are not drawn.layeras inmbtiles(java.nio.file.Path, java.lang.String): required for vector tiles. -
type
-
geometryType
-
envelope
The extent of the data, in the datasource's own projection. -
fields
Attribute columns. -
features
Features matching the query. Close the result. -
features
Features whose bounding box touchesbox. Close the result. -
featuresAtPoint
Features withintoleranceof a point, in the datasource's projection. Close the result. -
layerName
The name the datasource gives its data, such as a table or layer name. May be empty. -
encoding
The text encoding of attribute data, for exampleutf-8. -
parameters
-
close
public void close()Release this handle. A layer that already uses the datasource keeps its own reference.- Specified by:
closein interfaceAutoCloseable
-