Search in sources :

Example 1 with MbStyle

use of com.baremaps.model.MbStyle in project baremaps by baremaps.

the class Init method call.

@Override
public Integer call() throws BlobStoreException, IOException {
    BlobStore blobStore = options.blobStore();
    ObjectMapper mapper = defaultObjectMapper();
    if (style != null) {
        MbStyle styleObject = new MbStyle();
        styleObject.setName("Baremaps");
        MbStyleSources sources = new MbStyleSources();
        sources.setType("vector");
        sources.setUrl("http://localhost:9000/tiles.json");
        styleObject.setSources(Map.of("baremaps", sources));
        blobStore.put(style, Blob.builder().withByteArray(mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(styleObject)).build());
        logger.info("Style initialized: {}", style);
    }
    if (tileset != null) {
        TileJSON tilesetObject = new TileJSON();
        tilesetObject.setTilejson("2.2.0");
        tilesetObject.setName("Baremaps");
        tilesetObject.setTiles(Arrays.asList("http://localhost:9000/tiles.json"));
        blobStore.put(tileset, Blob.builder().withByteArray(mapper.writerWithDefaultPrettyPrinter().writeValueAsBytes(tilesetObject)).build());
        logger.info("Tileset initialized: {}", tileset);
    }
    return 0;
}
Also used : MbStyleSources(com.baremaps.model.MbStyleSources) TileJSON(com.baremaps.model.TileJSON) BlobStore(com.baremaps.blob.BlobStore) DefaultObjectMapper.defaultObjectMapper(com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MbStyle(com.baremaps.model.MbStyle)

Example 2 with MbStyle

use of com.baremaps.model.MbStyle in project baremaps by baremaps.

the class StylesResourceIntegrationTest method test.

@Test
public void test() {
    // List the styles
    StyleSet styles = target().path("/styles").request().get(StyleSet.class);
    assertEquals(0, styles.getStyles().size());
    // Create a new style with the service
    MbStyle style = new MbStyle();
    style.setName("test");
    target().path("/styles").request(MediaType.APPLICATION_JSON).post(Entity.entity(style, MediaType.valueOf("application/vnd.mapbox.style+json")));
    // List the styles
    styles = target().path("/styles").request().get(StyleSet.class);
    assertEquals(1, styles.getStyles().size());
    // Get the style
    UUID id = styles.getStyles().get(0).getId();
    style = target().path("/styles/" + id).request().get(MbStyle.class);
    assertEquals("test", style.getName());
    // Delete the style
    target().path("/styles/" + styles.getStyles().get(0).getId()).request().delete();
    // List the styles
    styles = target().path("/styles").request().get(StyleSet.class);
    assertEquals(0, styles.getStyles().size());
}
Also used : UUID(java.util.UUID) StyleSet(com.baremaps.model.StyleSet) MbStyle(com.baremaps.model.MbStyle) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

MbStyle (com.baremaps.model.MbStyle)2 BlobStore (com.baremaps.blob.BlobStore)1 MbStyleSources (com.baremaps.model.MbStyleSources)1 StyleSet (com.baremaps.model.StyleSet)1 TileJSON (com.baremaps.model.TileJSON)1 DefaultObjectMapper.defaultObjectMapper (com.baremaps.server.common.DefaultObjectMapper.defaultObjectMapper)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 UUID (java.util.UUID)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1 Test (org.junit.Test)1