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;
}
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());
}
Aggregations