Package org.geomajas.layer.tile

Examples of org.geomajas.layer.tile.InternalTile


    this.coordWidth = coordWidth;
    this.coordHeight = coordHeight;
  }

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    InternalTile tile = (InternalTile) object;
    String style = null;
    for (InternalFeature feature : tile.getFeatures()) {
      FeatureStyleInfo featureStyle = feature.getStyleInfo();
      if (null != featureStyle) {
        String nextStyle = Integer.toString(featureStyle.getIndex());
        if (style == null || !style.equals(nextStyle)) {
          if (style != null) {
View Full Code Here


* @author Pieter De Graef
*/
public class SvgTileWriter implements GraphicsWriter {

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    InternalTile tile = (InternalTile) object;
    document.writeElement("g", true);
    document.writeId("features." + tile.getCode().toString());
    String style = null;
    for (InternalFeature feature : tile.getFeatures()) {
      FeatureStyleInfo featureStyle = feature.getStyleInfo();
      if (null != featureStyle) {
        String nextStyle = Integer.toString(featureStyle.getIndex());
        if (style == null || !style.equals(nextStyle)) {
          if (style != null) {
View Full Code Here

    this.textService = textService;
    this.factory = new GeometryFactory();
  }

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    InternalTile tile = (InternalTile) object;
    FeatureStyleInfo bgStyle = labelStyle.getBackgroundStyle();
    document.writeElement("g", asChild);
    document.writeId("labels." + tile.getCode().toString());
    for (InternalFeature feature : tile.getFeatures()) {
      Coordinate pos = geoService.calcDefaultLabelPosition(feature);
      if (null != pos) {
        Point p = factory.createPoint(pos);
        Point labelPos;
        try {
View Full Code Here

    return ExecutionMode.EXECUTE_ALL;
  }

  public void afterSteps(PipelineContext context, GetTileContainer response) throws GeomajasException {
    recorder.record(CacheCategory.TILE, "Put item in cache");
    InternalTile tile = response.getTile();
    tile.setFeatures(null); // clear features to reduce amount of cached data, not converted to VectorTile anyway
    putContainer(context, CacheCategory.TILE, KEYS, CacheStepConstant.CACHE_TILE_KEY,
        CacheStepConstant.CACHE_TILE_CONTEXT, new TileCacheContainer(tile), tile.getBounds());
  }
View Full Code Here

    this.id = id;
  }

  public void execute(PipelineContext context, GetTileContainer response) throws GeomajasException {
    // Determine transformation to apply
    InternalTile tile = response.getTile();
    CrsTransform transform = context.get(PipelineCode.CRS_TRANSFORM_KEY, CrsTransform.class);

    // convert feature geometries to layer, need to copy to assure cache is not affected
    List<InternalFeature> features = new ArrayList<InternalFeature>();
    for (InternalFeature feature : tile.getFeatures()) {
      if (null != feature.getGeometry()) {
        InternalFeature newFeature = feature.cloneWithoutGeometry();
        newFeature.setGeometry(geoService.transform(feature.getGeometry(), transform));
        features.add(newFeature);
      }
    }
    // replace the contents of the list
    tile.setFeatures(features);
  }
View Full Code Here

  public void setId(String id) {
    this.id = id;
  }

  public void execute(PipelineContext context, GetTileContainer response) throws GeomajasException {
    InternalTile tile = response.getTile();
    if (null == tile.getFeatureContent()) {
      VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
      TileMetadata metadata = context.get(PipelineCode.TILE_METADATA_KEY, TileMetadata.class);

      tile.setContentType(VectorTile.VectorTileContentType.STRING_CONTENT);
      Coordinate panOrigin = new Coordinate(metadata.getPanOrigin().getX(), metadata.getPanOrigin().getY());
      TilePainter tilePainter = new StringContentTilePainter(layer, metadata.getStyleInfo(), metadata
          .getRenderer(), metadata.getScale(), panOrigin, geoService, textService);
      tilePainter.setPaintGeometries(metadata.isPaintGeometries());
      tilePainter.setPaintLabels(metadata.isPaintLabels());
      log.debug("Going to paint features {}", tile.getFeatures());

      tilePainter.paint(tile);
    }
  }
View Full Code Here

  public void setId(String id) {
    this.id = id;
  }

  public void execute(PipelineContext context, GetTileContainer response) throws GeomajasException {
    InternalTile tile = response.getTile();
    tile.setContentType(VectorTile.VectorTileContentType.URL_CONTENT);
    String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
    String cacheKey = context.get(RasterizingPipelineCode.IMAGE_ID_KEY, String.class);
    StringBuilder url = new StringBuilder(200);
    url.append(dispatcherUrlService.getDispatcherUrl());
    url.append("/rasterizing/layer/");
    url.append(layerId);
    url.append("/");
    url.append(cacheKey);
    url.append(".png");
    // must add a random parameter to force reload in some browsers like FF
    // better solution would be to use a cache version id ?
    url.append("?q=");
    url.append(randomString(8));
    tile.setFeatureContent(url.toString());
  }
View Full Code Here

    ThreadScopeContextHolder.clear();
  }

  @Test
  public void testRasterizeFromCache() throws Exception {
    InternalTile tile;
    // create metadata
    GetVectorTileRequest metadata = new GetVectorTileRequest();
    metadata.setCode(new TileCode(4, 8, 8));
    metadata.setCrs("EPSG:4326");
    metadata.setLayerId(layerBeans.getId());
    metadata.setPanOrigin(new Coordinate(0, 0));
    metadata.setScale(16);
    metadata.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    metadata.setStyleInfo(layerBeansStyleInfo);
    metadata.setPaintLabels(false);
    metadata.setPaintGeometries(true);
    // get tile
    recorder.clear();
    tile = vectorLayerService.getTile(metadata);
    Assert.assertEquals("", recorder.matches(CacheCategory.RASTER));
    // find the key
    String url = tile.getFeatureContent();
    Assert.assertTrue(url.startsWith("http://test/rasterizing/layer/beans/"));
    Assert.assertTrue(url.contains("?"));
    String key = url.substring("http://test/rasterizing/layer/beans/".length(), url.indexOf(".png"));
    Object o = cacheManager.get(layerBeans, CacheCategory.REBUILD, key);
    Assert.assertNotNull("Missing rebuild data in cache", o);
View Full Code Here


  @Test
  public void getTile()  throws Exception {
    TileMetadata tileMetadata = getTileMetadata();
    InternalTile tile = layerService.getTile(tileMetadata);
    Assert.assertNotNull(tile);
    Assert.assertNotNull(tile.getFeatures());
    Assert.assertEquals(3, tile.getFeatures().size());
  }
View Full Code Here

  @Test
  public void getFilteredTile()  throws Exception {
    TileMetadata tileMetadata = getTileMetadata();
    tileMetadata.setFilter("doubleAttr is null");
    InternalTile tile = layerService.getTile(tileMetadata);
    Assert.assertNotNull(tile);
    Assert.assertNotNull(tile.getFeatures());
    Assert.assertEquals(2, tile.getFeatures().size());

  }
View Full Code Here

TOP

Related Classes of org.geomajas.layer.tile.InternalTile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.