use of com.baremaps.tile.TileCache in project baremaps by baremaps.
the class View method call.
@Override
public Integer call() throws Exception {
ObjectMapper objectMapper = defaultObjectMapper();
BlobStore blobStore = options.blobStore();
TileJSON tileJSON = objectMapper.readValue(blobStore.get(this.tileset).getInputStream(), TileJSON.class);
CaffeineSpec caffeineSpec = CaffeineSpec.parse(cache);
DataSource datasource = PostgresUtils.datasource(database);
List<PostgresQuery> queries = asPostgresQuery(tileJSON);
TileStore tileStore = new PostgresTileStore(datasource, queries);
TileStore tileCache = new TileCache(tileStore, caffeineSpec);
// Configure the application
ResourceConfig application = new ResourceConfig().register(CorsFilter.class).register(ViewerResources.class).register(contextResolverFor(objectMapper)).register(new AbstractBinder() {
@Override
protected void configure() {
bind(tileset).to(URI.class).named("tileset");
bind(style).to(URI.class).named("style");
bind(blobStore).to(BlobStore.class);
bind(tileCache).to(TileStore.class);
}
});
BlockingStreamingHttpService httpService = new HttpJerseyRouterBuilder().buildBlockingStreaming(application);
ServerContext serverContext = HttpServers.forPort(port).listenBlockingStreamingAndAwait(httpService);
logger.info("Listening on {}", serverContext.listenAddress());
serverContext.awaitShutdown();
return 0;
}
Aggregations