Skip to content

Name values to uppercase in post process tile hook #816

Answered by msbarry
wipfli asked this question in Q&A
Discussion options

You must be logged in to vote

You could do something like:

    for (var item : items) {
      Object name = item.attrs().get("name");
      if (name instanceof String s) { // also filters out nulls
        item.attrs().put("name", s.toUpperCase());
      }
    }

or with the new full-tile hook:

  for (var layer : layers.values()) {
    for (var item: layer) {
      Object name = item.attrs().get("name");
      if (name instanceof String s) {
        item.attrs().put("name", s.toUpperCase());
      }
    }
  }

There's also a 1-liner for the get/modify/set:

item.attrs().computeIfPresent("name", (k, v) -> v instanceof String s ? s.toUpperCase() : v);

But you could also do this client-side with maplibre's upcase?

["upcase", [

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@wipfli
Comment options

Comment options

You must be logged in to vote
3 replies
@wipfli
Comment options

@wipfli
Comment options

@wipfli
Comment options

Answer selected by wipfli
Comment options

You must be logged in to vote
2 replies
@msbarry
Comment options

@wipfli
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants