Class UtfGrid

java.lang.Object
dev.avelar.mapnik.UtfGrid

public final class UtfGrid extends Object
A UTFGrid: a coarse picture in which each cell names the feature drawn there, so a web map can highlight a feature or show its details when the pointer is over it. Get one from MapnikMap.renderGrid(java.lang.String, java.lang.String, java.util.Collection<java.lang.String>, int), send toJson() to the browser, or look cells up here with pixel coordinates of the image it accompanies.
  • Method Summary

    Modifier and Type
    Method
    Description
    attributesAt(int pixelX, int pixelY)
    The attributes of the feature at a pixel, or an empty map where there is none.
    int
    Cells across and down.
    data(String key)
    The attribute data for one feature, or null if there is none for that key.
    int
     
    int
    Size in pixels of the image this grid covers.
    keyAt(int pixelX, int pixelY)
    The key of the feature at a pixel of the image, or an empty string where there is none.
    The names of the features that appear in the grid, in order of first appearance.
    static UtfGrid
    parse(String json, int resolution, int width, int height)
    Read a UTFGrid from JSON, given the size of the image it covers and how many pixels make a cell.
    int
    Pixels of the image per cell of the grid.
    int
     
    The JSON, ready to send to a web map.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • parse

      public static UtfGrid parse(String json, int resolution, int width, int height)
      Read a UTFGrid from JSON, given the size of the image it covers and how many pixels make a cell.
    • toJson

      public String toJson()
      The JSON, ready to send to a web map.
    • resolution

      public int resolution()
      Pixels of the image per cell of the grid.
    • imageWidth

      public int imageWidth()
      Size in pixels of the image this grid covers.
    • imageHeight

      public int imageHeight()
    • columns

      public int columns()
      Cells across and down.
    • rows

      public int rows()
    • keys

      public List<String> keys()
      The names of the features that appear in the grid, in order of first appearance.
    • data

      public Map<String,Object> data(String key)
      The attribute data for one feature, or null if there is none for that key.
    • keyAt

      public String keyAt(int pixelX, int pixelY)
      The key of the feature at a pixel of the image, or an empty string where there is none.
    • attributesAt

      public Map<String,Object> attributesAt(int pixelX, int pixelY)
      The attributes of the feature at a pixel, or an empty map where there is none.
    • toString

      public String toString()
      Overrides:
      toString in class Object