Tabnine Logo
TileCode
Code IndexAdd Tabnine to your IDE (free)

How to use
TileCode
in
org.geomajas.layer.tile

Best Java code snippets using org.geomajas.layer.tile.TileCode (Showing top 20 results out of 315)

origin: org.geomajas/geomajas-api

/**
 * Create a clone from this object.
 *
 * @return cloned tile code
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "CN_IDIOM_NO_SUPER_CALL",
    justification = "needed for GWT")
public TileCode clone() { // NOSONAR super.clone() not supported by GWT
  return new TileCode(tileLevel, x, y);
}
origin: org.geomajas/geomajas-api

/**
 * Convert to readable string.
 *
 * @return readable string
 */
public String toString() {
  if (code == null) {
    return "[bounds=" + bounds + ",url=" + url + "]";
  }
  return "[z=" + code.getTileLevel() + ",x=" + code.getX() + ",y=" + code.getY() + ",bounds=" + bounds + ",url="
      + url + "]";
}
origin: org.geomajas/geomajas-gwt-client-impl

public VectorTilePresenter addTile(TileCode tileCode) {
  VectorTilePresenter tilePresenter = tiles.get(tileCode.toString());
  if (tilePresenter == null) {
    tilePresenter = new VectorTilePresenter(commandService, this, tileCode.clone(), scale, crs,
        new TileLoadCallback());
    nrLoadingTiles++;
    tiles.put(tileCode.toString(), tilePresenter);
  }
  return tilePresenter;
}
origin: org.geomajas.plugin/geomajas-layer-tms

  /**
   * @param relativeUrl just the part with level/x/y.extension
   * @return
   */
  public static TileCode parseTileCode(String relativeUrl) {
    TileCode tc = new TileCode();
    StringTokenizer tokenizer = new StringTokenizer(relativeUrl, "/");
    tc.setTileLevel(Integer.parseInt(tokenizer.nextToken()));
    tc.setX(Integer.parseInt(tokenizer.nextToken()));
    tc.setY(Integer.parseInt(tokenizer.nextToken().split("\\.")[0]));
    return tc;
  }
}
origin: org.geomajas.plugin/geomajas-plugin-printing

private Bbox getPixelBounds(List<RasterTile> tiles) {
  Bbox bounds = null;
  int imageWidth = configurationService.getRasterLayerInfo(getLayerId()).getTileWidth();
  int imageHeight = configurationService.getRasterLayerInfo(getLayerId()).getTileHeight();
  for (RasterTile tile : tiles) {
    Bbox tileBounds = new Bbox(tile.getCode().getX() * imageWidth, tile.getCode().getY() * imageHeight,
        imageWidth, imageHeight);
    if (bounds == null) {
      bounds = new Bbox(tileBounds.getX(), tileBounds.getY(), tileBounds.getWidth(), tileBounds.getHeight());
    } else {
      double minx = Math.min(tileBounds.getX(), bounds.getX());
      double maxx = Math.max(tileBounds.getMaxX(), bounds.getMaxX());
      double miny = Math.min(tileBounds.getY(), bounds.getY());
      double maxy = Math.max(tileBounds.getMaxY(), bounds.getMaxY());
      bounds = new Bbox(minx, miny, maxx - minx, maxy - miny);
    }
  }
  return bounds;
}
origin: org.geomajas.plugin/geomajas-plugin-wmsclient

@Override
public List<RasterTile> getTiles(double scale, Bbox worldBounds) {
  List<TileCode> codes = tileService.getTileCodesForBounds(getViewPort(), tileConfig, worldBounds, scale);
  List<RasterTile> tiles = new ArrayList<RasterTile>();
  if (!codes.isEmpty()) {
    double actualScale = viewPort.getZoomStrategy().getZoomStepScale(codes.get(0).getTileLevel());
    for (TileCode code : codes) {
      Bbox bounds = tileService.getWorldBoundsForTile(getViewPort(), tileConfig, code);
      RasterTile tile = new RasterTile(getScreenBounds(actualScale, bounds), code.toString());
      tile.setCode(code);
      tile.setUrl(wmsService.getMapUrl(getConfig(), getCrs(), bounds, tileConfig.getTileWidth(),
          tileConfig.getTileHeight()));
      tiles.add(tile);
    }
  }
  return tiles;
}
origin: org.geomajas.plugin/geomajas-plugin-printing

private boolean isYIndexUp(List<RasterTile> tiles) {
  RasterTile first = tiles.iterator().next();
  for (RasterTile tile : tiles) {
    if (tile.getCode().getY() > first.getCode().getY()) {
      return tile.getBounds().getY() > first.getBounds().getY();
    } else if (tile.getCode().getY() < first.getCode().getY()) {
      return tile.getBounds().getY() < first.getBounds().getY();
    }
  }
  return false;
}
origin: org.geomajas/geomajas-gwt-client-impl

public VectorTilePresenter getTile(TileCode tileCode) {
  return tiles.get(tileCode.toString());
}
origin: org.geomajas.plugin/geomajas-plugin-printing

double xOffset = result.getRasterImage().getCode().getX() * imageWidth
    - pixelBounds.getX();
double yOffset = 0;
  yOffset = result.getRasterImage().getCode().getY() * imageHeight
      - pixelBounds.getY();
} else {
  yOffset = (float) (pixelBounds.getMaxY() - (result.getRasterImage().getCode()
      .getY() + 1)
origin: org.geomajas.plugin/geomajas-plugin-wmsclient

public void render(Bbox bounds) {
  if (layer.isShowing()) {
    List<TileCode> tilesForBounds = tileService.getTileCodesForBounds(layer.getViewPort(),
        layer.getTileConfig(), bounds, scale);
    for (TileCode tileCode : tilesForBounds) {
      if (!tiles.containsKey(tileCode.toString())) {
        RasterTile tile = createTile(tileCode);
        // Add the tile to the list and render it:
        tiles.put(tileCode.toString(), tile);
        nrLoadingTiles++;
        renderTile(tile, new ImageCounter());
      }
    }
  }
}
origin: org.geomajas.plugin/geomajas-layer-tms

@Override
public String buildUrl(TileCode tileCode, String baseTmsUrl) {
  StringBuilder builder = new StringBuilder(baseTmsUrl);
  if (!baseTmsUrl.endsWith("/")) {
    builder.append("/");
  }
  builder.append(tileCode.getTileLevel());
  builder.append("/");
  builder.append(tileCode.getX());
  builder.append("/");
  builder.append(tileCode.getY());
  builder.append(extension);
  return builder.toString();
}

origin: org.geomajas/geomajas-gwt-client-impl

codes.add(new TileCode(currentTileLevel, x, y));
origin: org.geomajas/geomajas-gwt-client-impl

@Override
public void render(Bbox bbox) {
  // Only fetch when inside the layer bounds:
  if (BboxService.intersects(bbox, layerBounds) && vectorLayer.isShowing()) {
    // Find needed tile codes:
    List<TileCode> tempCodes = calcCodesForBounds(bbox);
    for (TileCode tileCode : tempCodes) {
      VectorTilePresenter tilePresenter = tiles.get(tileCode.toString());
      if (tilePresenter == null) {
        // New tile
        tilePresenter = addTile(tileCode);
        tilePresenter.render();
      } else if (tilePresenter.getSiblingStatus() == VectorTilePresenter.STATUS.EMPTY) {
        // Tile already exists, but the siblings have not yet been loaded:
        tilePresenter.renderSiblings();
      }
    }
  }
}
origin: org.geomajas.plugin/geomajas-layer-tms

private static String buildUrl(TileCode tileCode, TileMap tileMap, String baseTmsUrl) {
  if (tileCode == null || tileMap == null || baseTmsUrl == null) {
    throw new IllegalArgumentException("All parameters are required");
  }
  
  StringBuilder builder;
  // assuming they are ordered:
  TileSet tileSet = tileMap.getTileSets().getTileSets().get(tileCode.getTileLevel());
  String href = tileSet.getHref();
  if (href.startsWith("http://") || href.startsWith("https://")) {
    builder = new StringBuilder(href);
    if (!href.endsWith("/")) {
      builder.append("/");
    }
  } else {
    builder = new StringBuilder(baseTmsUrl);
    if (!baseTmsUrl.endsWith("/")) {
      builder.append("/");
    }
    builder.append(href);
    builder.append("/");
  }
  builder.append(tileCode.getX());
  builder.append("/");
  builder.append(tileCode.getY());
  builder.append(".");
  builder.append(tileMap.getTileFormat().getExtension());
  return builder.toString();
}

origin: org.geomajas.plugin/geomajas-plugin-wmsclient

  @Override
  public TileCode getTileCodeForLocation(ViewPort viewPort, WmsTileConfiguration tileConfig, Coordinate location,
      double scale) {
    double actualScale = viewPort.getZoomStrategy().checkScale(scale, ZoomOption.LEVEL_CLOSEST);
    int tileLevel = viewPort.getZoomStrategy().getZoomStepIndex(actualScale);
    double resolution = 1 / actualScale;
    double worldTileWidth = tileConfig.getTileWidth() * resolution;
    double worldTileHeight = tileConfig.getTileHeight() * resolution;

    Coordinate tileOrigin = tileConfig.getTileOrigin();
    int x = (int) Math.floor((location.getX() - tileOrigin.getX()) / worldTileWidth);
    int y = (int) Math.floor((location.getY() - tileOrigin.getY()) / worldTileHeight);

    return new TileCode(tileLevel, x, y);
  }
}
origin: org.geomajas.plugin/geomajas-plugin-wmsclient

private RasterTile createTile(TileCode tileCode) {
  Bbox worldBounds = tileService.getWorldBoundsForTile(layer.getViewPort(), layer.getTileConfig(), tileCode);
  RasterTile tile = new RasterTile(getScreenBounds(worldBounds), tileCode.toString());
  tile.setCode(tileCode);
  tile.setUrl(wmsService.getMapUrl(layer.getConfig(), layer.getCrs(), worldBounds, layer.getTileConfig()
      .getTileWidth(), layer.getTileConfig().getTileHeight()));
  return tile;
}
origin: org.geomajas/geomajas-gwt-client-impl

  private Coordinate getTilePosition() {
    org.geomajas.geometry.Bbox layerBounds = renderer.getLayer().getLayerInfo().getMaxExtent();

    // Calculate tile width and height for tileLevel=tileCode.getTileLevel(); This is in world space.
    double div = Math.pow(2, tileCode.getTileLevel());
    double tileWidth = Math.ceil((scale * layerBounds.getWidth()) / div) / scale;
    double tileHeight = Math.ceil((scale * layerBounds.getHeight()) / div) / scale;

    // Now get the top-left corner for the tile in world space:
    double x = layerBounds.getX() + tileCode.getX() * tileWidth;
    double y = layerBounds.getY() + tileCode.getY() * tileHeight;

    // Convert to screen space. Note that the Y-axis is inverted, and so the top corner from the tile BBOX (world)
    // becomes the bottom corner (screen). That is why the tileHeight is added before compensating with the scale.
    x *= scale;
    y = -Math.round(scale * (y + tileHeight));
    return new Coordinate(x, y);
  }
}
origin: org.geomajas.plugin/geomajas-plugin-wmsclient

codes.add(new TileCode(tileLevel, x, y));
origin: org.geomajas.plugin/geomajas-plugin-wmsclient

@Override
public Bbox getWorldBoundsForTile(ViewPort viewPort, WmsTileConfiguration tileConfig, TileCode tileCode) {
  double resolution = 1 / viewPort.getZoomStrategy().getZoomStepScale(tileCode.getTileLevel());
  double worldTileWidth = tileConfig.getTileWidth() * resolution;
  double worldTileHeight = tileConfig.getTileHeight() * resolution;
  double x = tileConfig.getTileOrigin().getX() + tileCode.getX() * worldTileWidth;
  double y = tileConfig.getTileOrigin().getY() + tileCode.getY() * worldTileHeight;
  return new Bbox(x, y, worldTileWidth, worldTileHeight);
}
origin: org.geomajas.plugin/geomajas-layer-googlemaps

image.setCode(new TileCode(zoomLevel, i, j));
image.setUrl(url);
log.debug("adding image {}", image);
org.geomajas.layer.tileTileCode

Javadoc

A unique spatial code determining the location of a tile. It implements the Serializable interface as it is often used as a data transfer object.

Tiling mechanisms are usually build in several levels, where the top level has only one tile, and for each level that you go deeper, the number of tiles doubles in both the X and the Y directions. All 3 parameters (tileLevel, X and Y) must always be positive integers.

Note that at a certain tile level, X and Y must always be a value between 0 and (2^tileLevel) - 1. For example:

  • Tile level = 0: X=0, Y=0
  • Tile level = 1: X=[0, 1], Y=[0, 1]
  • Tile level = 2: X=[0, 3], Y=[0, 3]
  • Tile level = 3: X=[0, 7], Y=[0, 7]
  • Tile level = N: X=[0, (2^N) - 1], Y=[0, (2^N) - 1]

Most used methods

  • <init>
    The only constructor available. It requires you to immediately set all it's values.
  • getX
    Get the X-ordinate at the given level: X=[0, (2^tileLevel) - 1].
  • getY
    Get the Y-ordinate at the given level: Y=[0, (2^tileLevel) - 1].
  • getTileLevel
    Get the tiling depth level. Where 0 means the top level. Make sure this is always a positive integer
  • toString
    Return the values as a readable text: TileLevel-X-Y.
  • clone
    Create a clone from this object.
  • setTileLevel
    set the tiling depth level. Where 0 means the top level. Make sure this is always a positive integer
  • setX
    The X-ordinate at the given level: X=[0, (2^tileLevel) - 1].
  • setY
    The Y-ordinate at the given level: Y=[0, (2^tileLevel) - 1].

Popular in Java

  • Finding current android device location
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • scheduleAtFixedRate (Timer)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • Collectors (java.util.stream)
  • Reference (javax.naming)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now