Search in sources :

Example 1 with TileCache

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;
}
Also used : CorsFilter(com.baremaps.server.common.CorsFilter) TileStore(com.baremaps.tile.TileStore) PostgresTileStore(com.baremaps.tile.postgres.PostgresTileStore) Conversions.asPostgresQuery(com.baremaps.server.ogcapi.Conversions.asPostgresQuery) PostgresQuery(com.baremaps.tile.postgres.PostgresQuery) AbstractBinder(org.glassfish.hk2.utilities.binding.AbstractBinder) CaffeineSpec(com.github.benmanes.caffeine.cache.CaffeineSpec) DataSource(javax.sql.DataSource) HttpJerseyRouterBuilder(io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder) BlockingStreamingHttpService(io.servicetalk.http.api.BlockingStreamingHttpService) ServerContext(io.servicetalk.transport.api.ServerContext) TileJSON(com.baremaps.model.TileJSON) PostgresTileStore(com.baremaps.tile.postgres.PostgresTileStore) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) TileCache(com.baremaps.tile.TileCache) DefaultObjectMapper.defaultObjectMapper(com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BlobStore(com.baremaps.blob.BlobStore)

Aggregations

BlobStore (com.baremaps.blob.BlobStore)1 TileJSON (com.baremaps.model.TileJSON)1 CorsFilter (com.baremaps.server.common.CorsFilter)1 DefaultObjectMapper.defaultObjectMapper (com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper)1 Conversions.asPostgresQuery (com.baremaps.server.ogcapi.Conversions.asPostgresQuery)1 TileCache (com.baremaps.tile.TileCache)1 TileStore (com.baremaps.tile.TileStore)1 PostgresQuery (com.baremaps.tile.postgres.PostgresQuery)1 PostgresTileStore (com.baremaps.tile.postgres.PostgresTileStore)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 CaffeineSpec (com.github.benmanes.caffeine.cache.CaffeineSpec)1 BlockingStreamingHttpService (io.servicetalk.http.api.BlockingStreamingHttpService)1 HttpJerseyRouterBuilder (io.servicetalk.http.router.jersey.HttpJerseyRouterBuilder)1 ServerContext (io.servicetalk.transport.api.ServerContext)1 DataSource (javax.sql.DataSource)1 AbstractBinder (org.glassfish.hk2.utilities.binding.AbstractBinder)1 ResourceConfig (org.glassfish.jersey.server.ResourceConfig)1