Search in sources :

Example 1 with StyleSetEntry

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

the class StylesResource method getStyleSet.

@Override
public Response getStyleSet() {
    List<UUID> ids = jdbi.withHandle(handle -> handle.createQuery("select id from styles").mapTo(UUID.class).list());
    StyleSet styleSet = new StyleSet();
    List<StyleSetEntry> entries = new ArrayList<>();
    String address = uriInfo.getRequestUri().toString();
    for (UUID id : ids) {
        Link link = new Link();
        link.setHref(address + id);
        link.setType("application/vnd.mapbox.style+json");
        link.setRel("stylesheet");
        StyleSetEntry entry = new StyleSetEntry();
        entry.setId(id);
        entry.setLinks(List.of(link));
        entries.add(entry);
    }
    styleSet.setStyles(entries);
    return Response.ok(styleSet).build();
}
Also used : StyleSetEntry(com.baremaps.model.StyleSetEntry) ArrayList(java.util.ArrayList) UUID(java.util.UUID) StyleSet(com.baremaps.model.StyleSet) Link(com.baremaps.model.Link)

Aggregations

Link (com.baremaps.model.Link)1 StyleSet (com.baremaps.model.StyleSet)1 StyleSetEntry (com.baremaps.model.StyleSetEntry)1 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1