Package dev.avelar.mapnik
Class JavaDatasource
java.lang.Object
dev.avelar.mapnik.Datasource
dev.avelar.mapnik.JavaDatasource
- All Implemented Interfaces:
AutoCloseable
A datasource whose features come from your own code, called when Mapnik renders or queries: a
database with your own access rules, a web service, generated data, a cache. Unlike a
MemoryDatasource, nothing is held up front and each render asks for just the area it needs.
FeatureSource source = request -> myIndex.query(request.bbox()); // a list of Feature
try (JavaDatasource ds = JavaDatasource.create(source, worldExtent)) {
layer.setDatasource(ds);
}
Features' coordinates must be in the projection of the layer. The source is kept alive for as long as Mapnik still uses the datasource, even after you close this handle, for example while a map whose layer uses it is open.
-
Nested Class Summary
Nested classes/interfaces inherited from class dev.avelar.mapnik.Datasource
Datasource.Field, Datasource.FieldType, Datasource.GeometryType, Datasource.Type -
Method Summary
Modifier and TypeMethodDescriptionstatic JavaDatasourcecreate(FeatureSource source, Box2d envelope) Create one.static JavaDatasourcecreate(FeatureSource source, Box2d envelope, List<Datasource.Field> fields) Ascreate(FeatureSource, Box2d), also declaring the attribute columns, which show up inDatasource.fields().setEnvelope(Box2d envelope) Change the extent reported for the data, for example as it grows.Methods inherited from class dev.avelar.mapnik.Datasource
close, create, encoding, envelope, features, features, featuresAtPoint, fields, geometryType, layerName, mbtiles, parameters, pmtiles, tilesFromUrl, type
-
Method Details
-
create
Create one.envelopeis the extent of all the data, in the layer's projection. -
create
public static JavaDatasource create(FeatureSource source, Box2d envelope, List<Datasource.Field> fields) Ascreate(FeatureSource, Box2d), also declaring the attribute columns, which show up inDatasource.fields(). Mapnik does not check that features have them. -
setEnvelope
Change the extent reported for the data, for example as it grows.
-